Refactor assistant configuration and database seeding

- Update Makefile to include new database seed commands for assistants and credentials.
- Refactor assistant model to use explicit fields instead of a config dictionary, improving data integrity and clarity.
- Implement new seeding SQL script for assistants, ensuring dependencies on credentials are respected.
- Modify backend routes and frontend components to accommodate the new assistant structure, including direct field access for prompt, API URL, and keys.
- Enhance the AssistantPage component to handle the new data structure and streamline the save process for different assistant types.
This commit is contained in:
Xin Wang
2026-06-09 10:37:29 +08:00
parent 23e1cf5d42
commit 519cc0fefe
8 changed files with 197 additions and 185 deletions

View File

@@ -82,7 +82,7 @@ export type AssistantType =
| "opencode";
export type RuntimeMode = "pipeline" | "realtime";
/** 后端 AssistantOut。config 形态随 type 变,故用宽松 record */
/** 后端 AssistantOut(宽表 STI:瘦字段平铺,workflow 用 graph)。apiKey 读时打码 */
export type Assistant = {
id: string;
name: string;
@@ -95,23 +95,15 @@ export type Assistant = {
ttsCredentialId: string | null;
realtimeCredentialId: string | null;
knowledgeBaseId: string | null;
config: Record<string, unknown>;
prompt: string;
apiUrl: string;
apiKey: string;
appId: string;
graph: Record<string, unknown>;
updatedAt?: string | null;
};
export type AssistantUpsert = {
name: string;
type: AssistantType;
runtimeMode: RuntimeMode;
greeting: string;
enableInterrupt: boolean;
llmCredentialId: string | null;
asrCredentialId: string | null;
ttsCredentialId: string | null;
realtimeCredentialId: string | null;
knowledgeBaseId: string | null;
config: Record<string, unknown>;
};
export type AssistantUpsert = Omit<Assistant, "id" | "updatedAt">;
export const assistantsApi = {
list: () => request<Assistant[]>("/api/assistants"),