Files
AlphaPulse/web/src/apis/chat.ts
T
eezd 5db3ead883 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
2026-10-14 13:11:45 +08:00

53 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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")
}