Add AI chat with skills management and model provider settings

- Model providers for OpenAI and Anthropic message formats (e.g. via
  Sub2API), with API keys encrypted at rest and never returned
- Skills tree with markdown editing, priorities, drafts, publishing and
  rollback; only published skills enter the chat prompt
- Chat page with tool calls over collected news and Binance USD-M
  klines, a persisted CONTEXT.md, reset, and stop-generation support
- Chat may only create skill drafts and update CONTEXT.md; publishing,
  deleting, moving and priority changes stay with the user
This commit is contained in:
eezd committed 2026-10-14 13:11:45 +08:00
1 parent f042f27013
commit 5db3ead883
34 files changed
+3196 -12

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
import { http } from "@/http"
export interface ToolCall {
id: string
name: string
arguments: Record<string, unknown>
}
export interface ChatMessage {
id: number
role: "user" | "assistant" | "tool"
/** user: {text};assistant: {text, tool_calls, stopped?, error?};tool: {tool_call_id, name, result} */
content: Record<string, any>
provider_id: number | null
usage: { input_tokens?: number, output_tokens?: number } | null
created_at: string
}
export interface ChatSession {
id: number
created_at: string
messages: ChatMessage[]
estimated_tokens: number
generating: boolean
}
export interface ChatContext {
id: number | null
content: string
source: "user" | "chat" | "reset" | null
created_at: string | null
}
export function getChatSession(): Promise<ChatSession> {
return http.get("/chat/session")
}
export function resetChat(clearContext: boolean): Promise<void> {
return http.post("/chat/reset", { clear_context: clearContext })
}
export function getChatContext(): Promise<ChatContext> {
return http.get("/chat/context")
}
export function saveChatContext(content: string): Promise<ChatContext> {
return http.put("/chat/context", { content })
}
export function listChatContextVersions(): Promise<ChatContext[]> {
return http.get("/chat/context/versions")
}