feat: Add agent configuration and cleanup scripts for database migrations
This commit is contained in:
@@ -18,6 +18,11 @@ export async function knowledgeChat(data: { session_id: string; query: string; }
|
||||
return postChat(`/api/v1/knowledge-chat/${data.session_id}`, { query: data.query });
|
||||
}
|
||||
|
||||
// Agent chat with streaming support
|
||||
export async function agentChat(data: { session_id: string; query: string; }) {
|
||||
return postChat(`/api/v1/agent-chat/${data.session_id}`, { query: data.query });
|
||||
}
|
||||
|
||||
export async function getMessageList(data: { session_id: string; limit: number, created_at: string }) {
|
||||
if (data.created_at) {
|
||||
return get(`/api/v1/messages/${data.session_id}/load?before_time=${encodeURIComponent(data.created_at)}&limit=${data.limit}`);
|
||||
|
||||
@@ -100,8 +100,16 @@ export function checkOllamaStatus(): Promise<{ available: boolean; version?: str
|
||||
});
|
||||
}
|
||||
|
||||
// 列出已安装的 Ollama 模型
|
||||
export function listOllamaModels(): Promise<string[]> {
|
||||
// Ollama 模型详细信息接口
|
||||
export interface OllamaModelInfo {
|
||||
name: string;
|
||||
size: number;
|
||||
digest: string;
|
||||
modified_at: string;
|
||||
}
|
||||
|
||||
// 列出已安装的 Ollama 模型(详细信息)
|
||||
export function listOllamaModels(): Promise<OllamaModelInfo[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
get('/api/v1/initialization/ollama/models')
|
||||
.then((response: any) => {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import { get, post, put, del } from '../../utils/request';
|
||||
|
||||
// 模型类型定义
|
||||
export interface ModelConfig {
|
||||
id?: string;
|
||||
tenant_id?: number;
|
||||
name: string;
|
||||
type: 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM';
|
||||
source: 'local' | 'remote';
|
||||
description?: string;
|
||||
parameters: {
|
||||
base_url?: string;
|
||||
api_key?: string;
|
||||
embedding_parameters?: {
|
||||
dimension?: number;
|
||||
truncate_prompt_tokens?: number;
|
||||
};
|
||||
interface_type?: 'ollama' | 'openai'; // VLLM专用
|
||||
};
|
||||
is_default?: boolean;
|
||||
status?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
deleted_at?: string | null;
|
||||
}
|
||||
|
||||
// 创建模型
|
||||
export function createModel(data: ModelConfig): Promise<ModelConfig> {
|
||||
return new Promise((resolve, reject) => {
|
||||
post('/api/v1/models', data)
|
||||
.then((response: any) => {
|
||||
if (response.success && response.data) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
reject(new Error(response.message || '创建模型失败'));
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('创建模型失败:', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 获取模型列表
|
||||
export function listModels(type?: string): Promise<ModelConfig[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = type ? `/api/v1/models?type=${type}` : '/api/v1/models';
|
||||
get(url)
|
||||
.then((response: any) => {
|
||||
if (response.success && response.data) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
resolve([]);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('获取模型列表失败:', error);
|
||||
resolve([]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 获取单个模型
|
||||
export function getModel(id: string): Promise<ModelConfig> {
|
||||
return new Promise((resolve, reject) => {
|
||||
get(`/api/v1/models/${id}`)
|
||||
.then((response: any) => {
|
||||
if (response.success && response.data) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
reject(new Error(response.message || '获取模型失败'));
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('获取模型失败:', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 更新模型
|
||||
export function updateModel(id: string, data: Partial<ModelConfig>): Promise<ModelConfig> {
|
||||
return new Promise((resolve, reject) => {
|
||||
put(`/api/v1/models/${id}`, data)
|
||||
.then((response: any) => {
|
||||
if (response.success && response.data) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
reject(new Error(response.message || '更新模型失败'));
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('更新模型失败:', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 删除模型
|
||||
export function deleteModel(id: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
del(`/api/v1/models/${id}`)
|
||||
.then((response: any) => {
|
||||
if (response.success) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(response.message || '删除模型失败'));
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('删除模型失败:', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { get } from '@/utils/request'
|
||||
import { get, put } from '@/utils/request'
|
||||
|
||||
export interface SystemInfo {
|
||||
version: string
|
||||
@@ -7,6 +7,32 @@ export interface SystemInfo {
|
||||
go_version?: string
|
||||
}
|
||||
|
||||
export interface ToolDefinition {
|
||||
name: string
|
||||
label: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export interface AgentConfig {
|
||||
enabled: boolean
|
||||
max_iterations: number
|
||||
reflection_enabled: boolean
|
||||
allowed_tools: string[]
|
||||
temperature: number
|
||||
thinking_model_id: string
|
||||
rerank_model_id: string
|
||||
knowledge_bases?: string[]
|
||||
available_tools?: ToolDefinition[] // GET 响应中包含,POST/PUT 不需要
|
||||
}
|
||||
|
||||
export function getSystemInfo(): Promise<{ data: SystemInfo }> {
|
||||
return get('/api/v1/system/info')
|
||||
}
|
||||
|
||||
export function getAgentConfig(): Promise<{ data: AgentConfig }> {
|
||||
return get('/api/v1/tenants/agent-config')
|
||||
}
|
||||
|
||||
export function updateAgentConfig(config: AgentConfig): Promise<{ data: AgentConfig }> {
|
||||
return put('/api/v1/tenants/agent-config', config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user