36 lines
2.1 KiB
Markdown
36 lines
2.1 KiB
Markdown
|
|
# Model Gateway And Prompt Identity Plan
|
||
|
|
|
||
|
|
**Goal:** Put every existing AI call behind a provider-neutral model gateway and make queued AI tasks execute with an immutable Prompt/model identity.
|
||
|
|
|
||
|
|
**Architecture:** `AiGenerateServiceImpl` keeps the current domain-specific user Prompt builders, but delegates invocation to `AiModelInvoker`. The invoker resolves a versioned `PromptRelease`, routes through `ModelGatewayRouter`, and honors a task-scoped pinned identity supplied by `AiGenerationTaskWorker`. `DeepSeekModelGateway` is the first provider adapter and supports an explicit model override.
|
||
|
|
|
||
|
|
## Task 1: Contracts
|
||
|
|
|
||
|
|
- [x] Define Prompt release, registry, invocation plan, model request/result, gateway descriptor, and stream contracts.
|
||
|
|
- [x] Define a task execution context that safely restores nested/thread-local state.
|
||
|
|
- [x] Reject unknown Prompt releases, providers, model mismatches, and fingerprint drift.
|
||
|
|
|
||
|
|
## Task 2: Legacy-Compatible Implementations
|
||
|
|
|
||
|
|
- [x] Publish built-in Prompt releases for every current generation type.
|
||
|
|
- [x] Wrap `IDeepSeekClient` with `DeepSeekModelGateway` and route explicit model IDs.
|
||
|
|
- [x] Add `AiModelInvoker` and retain a legacy fallback for existing direct unit fixtures.
|
||
|
|
|
||
|
|
## Task 3: Task Traceability
|
||
|
|
|
||
|
|
- [x] Persist Prompt code, version, and fingerprint beside provider/model on AI tasks.
|
||
|
|
- [x] Include Prompt/model identity in task idempotency hashes and API status responses.
|
||
|
|
- [x] Execute queued work inside the pinned identity context.
|
||
|
|
|
||
|
|
## Task 4: Migration And Verification
|
||
|
|
|
||
|
|
- [x] Update base SQL, workbench SQL, task upgrade SQL, and add an existing-schema upgrade.
|
||
|
|
- [x] Add contract, gateway, context, task persistence, mapper, and SQL tests.
|
||
|
|
- [x] Run focused and broad backend regressions, frontend tests/build, and `git diff --check`.
|
||
|
|
|
||
|
|
## Boundaries
|
||
|
|
|
||
|
|
- User Prompt builders remain in `AiGenerateServiceImpl` during P2-B1 and are identified by an immutable builder contract string.
|
||
|
|
- Database-editable Prompt templates, publish/rollback APIs, and the RuoYi Prompt administration UI are P2-B2.
|
||
|
|
- Requirement planning into ProjectSpec Draft/Patch and Stage Handler checkpoints remain later P2 work.
|