mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
refactor: prune dead compatibility surfaces
This commit is contained in:
1 parent
02b9ccb59f
commit
1566cfcb2b
46 files changed
+24
-305
No files matched your search
@@ -70,16 +70,4 @@ export function registerAiAssistantRoutes(server: FastifyInstance, ctx: AiAssist
|
||||
server.post<{ Body: { rawMd: string } }>('/_web/ai/assistants/import', async (request) => {
|
||||
return mgr.importAssistantFromMd(request.body.rawMd)
|
||||
})
|
||||
|
||||
server.post<{ Body: { builtinId: string } }>('/_web/ai/assistants/import-builtin', async (request, reply) => {
|
||||
const result = mgr.importAssistant(request.body.builtinId)
|
||||
if (!result.success) return reply.code(400).send(result)
|
||||
return result
|
||||
})
|
||||
|
||||
server.post<{ Params: { id: string } }>('/_web/ai/assistants/:id/reimport', async (request, reply) => {
|
||||
const result = mgr.reimportAssistant(request.params.id)
|
||||
if (!result.success) return reply.code(400).send(result)
|
||||
return result
|
||||
})
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
import { parseAssistantFile, serializeAssistant } from './assistant-parser'
|
||||
import type { AssistantConfig, AssistantSummary } from './types'
|
||||
import { GENERAL_ASSISTANT_IDS } from '@openchatlab/shared-types'
|
||||
import type { AssistantUpgradeInfo, AssistantUpgradeResult, BuiltinAssistantInfo } from '@openchatlab/shared-types'
|
||||
import type { AssistantUpgradeInfo, AssistantUpgradeResult } from '@openchatlab/shared-types'
|
||||
|
||||
// ==================== Result types ====================
|
||||
|
||||
@@ -298,42 +298,12 @@ export class AssistantManager {
|
||||
return this.cache.has(id)
|
||||
}
|
||||
|
||||
getBuiltinCatalog(): BuiltinAssistantInfo[] {
|
||||
this.ensureInitialized()
|
||||
return []
|
||||
}
|
||||
|
||||
isGeneralAssistant(id: string): boolean {
|
||||
return this.generalIds.includes(id)
|
||||
}
|
||||
|
||||
// ==================== Import ====================
|
||||
|
||||
importAssistant(builtinId: string): AssistantSaveResult {
|
||||
this.ensureInitialized()
|
||||
|
||||
const builtinConfig = this.getBuiltinConfig(builtinId)
|
||||
if (!builtinConfig) return { success: false, error: `Builtin assistant not found: ${builtinId}` }
|
||||
|
||||
const existing = this.findByBuiltinId(builtinId)
|
||||
if (existing) return { success: false, error: `Assistant already imported: ${builtinId}` }
|
||||
|
||||
return this.saveToDisk(this.withBuiltinTracking(builtinConfig))
|
||||
}
|
||||
|
||||
reimportAssistant(id: string): AssistantSaveResult {
|
||||
this.ensureInitialized()
|
||||
|
||||
const existing = this.cache.get(id)
|
||||
if (!existing) return { success: false, error: `Assistant not found: ${id}` }
|
||||
if (!existing.builtinId) return { success: false, error: 'Only imported builtin assistants can be reimported' }
|
||||
|
||||
const builtinConfig = this.getBuiltinConfig(existing.builtinId)
|
||||
if (!builtinConfig) return { success: false, error: `Builtin template not found: ${existing.builtinId}` }
|
||||
|
||||
return this.saveToDisk(this.withBuiltinTracking(builtinConfig, existing.id))
|
||||
}
|
||||
|
||||
importAssistantFromMd(rawMd: string): AssistantSaveResult & { id?: string } {
|
||||
this.ensureInitialized()
|
||||
|
||||
@@ -454,10 +424,6 @@ export class AssistantManager {
|
||||
|
||||
// ==================== Internal ====================
|
||||
|
||||
private findByBuiltinId(builtinId: string): AssistantConfig | undefined {
|
||||
return Array.from(this.cache.values()).find((c) => c.builtinId === builtinId)
|
||||
}
|
||||
|
||||
private saveToDisk(config: AssistantConfig): AssistantSaveResult {
|
||||
try {
|
||||
const filePath = this.deps.fs.joinPath(this.deps.assistantsDir, `${config.id}.md`)
|
||||
|
||||
@@ -16,7 +16,6 @@ export type {
|
||||
AssistantSummary,
|
||||
AssistantUpgradeInfo,
|
||||
AssistantUpgradeResult,
|
||||
BuiltinAssistantInfo,
|
||||
} from '@openchatlab/shared-types'
|
||||
export type { SkillDef, SkillSummary } from './types'
|
||||
export { parseAssistantFile, serializeAssistant } from './assistant-parser'
|
||||
|
||||
@@ -209,13 +209,7 @@ export type { AuthProfileLlmConfigStoreDeps, CreateLlmRuntimeStoresOptions, LlmR
|
||||
|
||||
// Assistant Manager
|
||||
export { AssistantManager } from './ai'
|
||||
export type {
|
||||
AssistantInitResult,
|
||||
AssistantSaveResult,
|
||||
BuiltinAssistantInfo,
|
||||
AssistantManagerFs,
|
||||
AssistantManagerDeps,
|
||||
} from './ai'
|
||||
export type { AssistantInitResult, AssistantSaveResult, AssistantManagerFs, AssistantManagerDeps } from './ai'
|
||||
|
||||
// Compression
|
||||
export type { CompressionConfig, CompressionResult, CompressionLogger, CompressionLlmAdapter } from './ai'
|
||||
|
||||
@@ -223,15 +223,6 @@ export interface AssistantSummary {
|
||||
supportedLocales?: string[]
|
||||
}
|
||||
|
||||
export interface BuiltinAssistantInfo {
|
||||
id: string
|
||||
name: string
|
||||
systemPrompt: string
|
||||
applicableChatTypes?: ('group' | 'private')[]
|
||||
supportedLocales?: string[]
|
||||
imported: boolean
|
||||
}
|
||||
|
||||
export interface AssistantUpgradeInfo {
|
||||
assistantId: string
|
||||
builtinId: string
|
||||
|
||||
Reference in new issue
Block a user