Compare commits
No commits in common. "5ad191684a7a077bdcd2d05790a00ae54ac50231" and "c18bb27794dd769b3981134daab95d72f4ecb83a" have entirely different histories.
5ad191684a
...
c18bb27794
@ -129,7 +129,7 @@ export async function POST(request: NextRequest) {
|
||||
cchApiKey: null,
|
||||
cchApiKeyConfigured: false,
|
||||
defaultModel: 'claude-sonnet-4-5-20250929',
|
||||
defaultTools: ['web_search', 'web_fetch'],
|
||||
defaultTools: ['web_search', 'code_execution', 'web_fetch'],
|
||||
theme: 'light',
|
||||
language: 'zh-CN',
|
||||
fontSize: 15,
|
||||
|
||||
@ -122,6 +122,7 @@ const DEFAULT_SYSTEM_PROMPT = `你是一个专业、友好的 AI 助手。请遵
|
||||
|
||||
## 工具使用
|
||||
- 当需要查询实时信息时,请使用 web_search 工具
|
||||
- 当需要执行代码验证结果时,请使用 code_execution 工具
|
||||
- 当需要获取网页内容时,请使用 web_fetch 工具
|
||||
- **工具调用原则**:只为最新问题调用必要的工具,不要为历史问题调用工具
|
||||
|
||||
@ -132,12 +133,21 @@ const DEFAULT_SYSTEM_PROMPT = `你是一个专业、友好的 AI 助手。请遵
|
||||
3. **格式示例**:
|
||||
- ✅ 正确:"今天北京天气晴朗,气温15°C。(来源:weather.com)"
|
||||
- ❌ 错误:把整个搜索结果复制出来
|
||||
4. **代码执行结果**:直接展示输出结果,说明代码运行是否成功
|
||||
|
||||
## 特别注意
|
||||
- 如果问题不明确,先确认理解是否正确
|
||||
- 如果有多种方案,说明各自的优缺点
|
||||
- 承认不确定的地方,不要编造信息
|
||||
|
||||
## 图表绘制规范(重要)
|
||||
当使用 code_execution 工具绘制图表时,请遵循以下规则:
|
||||
1. **只生成一段代码**:一个请求只调用一次 code_execution 工具绘制图表,不要生成多段重复的绘图代码
|
||||
2. **代码完整性**:确保一段代码中包含所有需要展示的图表内容
|
||||
3. **使用默认样式**:系统已默认配置 seaborn-whitegrid 风格,无需在代码中再次设置 plt.style.use()
|
||||
4. **中文支持**:系统已配置中文字体(Noto Sans SC),可以直接使用中文标签和标题
|
||||
5. **不要重复绘图**:即使是展示不同数据,也应该在一张图表中使用子图(subplot)展示,而不是分开多次绘制
|
||||
|
||||
## 文档深度分析规范(重要)
|
||||
当用户上传文档/文件并要求分析时,请按以下框架进行**深度分析**,不要简单总结:
|
||||
|
||||
@ -1633,6 +1643,24 @@ function buildClaudeToolDefinitions(toolIds: string[]) {
|
||||
required: ['query'],
|
||||
},
|
||||
},
|
||||
code_execution: {
|
||||
name: 'code_execution',
|
||||
description: '执行代码并返回结果。支持 Python、JavaScript、TypeScript、Java、C、C++、Go、Rust 等多种语言。当需要验证代码、进行计算或演示代码运行结果时,请使用此工具。',
|
||||
input_schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'string',
|
||||
description: '要执行的代码',
|
||||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
description: '编程语言 (python, javascript, typescript, java, c, cpp, go, rust, ruby, php 等)',
|
||||
},
|
||||
},
|
||||
required: ['code', 'language'],
|
||||
},
|
||||
},
|
||||
web_fetch: {
|
||||
name: 'web_fetch',
|
||||
description: '获取指定 URL 的网页内容。当用户提供了具体的网址并想了解该页面的内容时,请使用此工具。',
|
||||
@ -1674,6 +1702,27 @@ function buildOpenAIToolDefinitions(toolIds: string[]) {
|
||||
},
|
||||
},
|
||||
},
|
||||
code_execution: {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'code_execution',
|
||||
description: '执行代码并返回结果。支持 Python、JavaScript、TypeScript、Java、C、C++、Go、Rust 等多种语言。当需要验证代码、进行计算或演示代码运行结果时,请使用此工具。',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'string',
|
||||
description: '要执行的代码',
|
||||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
description: '编程语言 (python, javascript, typescript, java, c, cpp, go, rust, ruby, php 等)',
|
||||
},
|
||||
},
|
||||
required: ['code', 'language'],
|
||||
},
|
||||
},
|
||||
},
|
||||
web_fetch: {
|
||||
type: 'function',
|
||||
function: {
|
||||
@ -1716,6 +1765,25 @@ function buildCodexToolDefinitions(toolIds: string[]) {
|
||||
required: ['query'],
|
||||
},
|
||||
},
|
||||
code_execution: {
|
||||
type: 'function',
|
||||
name: 'code_execution',
|
||||
description: '执行代码并返回结果。支持 Python、JavaScript、TypeScript、Java、C、C++、Go、Rust 等多种语言。当需要验证代码、进行计算或演示代码运行结果时,请使用此工具。',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'string',
|
||||
description: '要执行的代码',
|
||||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
description: '编程语言 (python, javascript, typescript, java, c, cpp, go, rust, ruby, php 等)',
|
||||
},
|
||||
},
|
||||
required: ['code', 'language'],
|
||||
},
|
||||
},
|
||||
web_fetch: {
|
||||
type: 'function',
|
||||
name: 'web_fetch',
|
||||
|
||||
@ -11,7 +11,7 @@ const DEFAULT_SETTINGS = {
|
||||
cchApiKeyConfigured: false,
|
||||
apiFormat: 'claude' as 'claude' | 'openai', // API 格式:claude(原生)| openai(兼容)
|
||||
defaultModel: 'claude-sonnet-4-5-20250929',
|
||||
defaultTools: ['web_search', 'web_fetch'],
|
||||
defaultTools: ['web_search', 'code_execution', 'web_fetch'],
|
||||
systemPrompt: '',
|
||||
temperature: '0.7',
|
||||
theme: 'light',
|
||||
|
||||
@ -11,10 +11,7 @@ export async function GET() {
|
||||
orderBy: [asc(tools.sortOrder)],
|
||||
});
|
||||
|
||||
// 过滤掉 code_execution 工具
|
||||
const filteredTools = toolList.filter(tool => tool.toolId !== 'code_execution');
|
||||
|
||||
return NextResponse.json(filteredTools);
|
||||
return NextResponse.json(toolList);
|
||||
} catch (error) {
|
||||
console.error('Failed to get tools:', error);
|
||||
return NextResponse.json(
|
||||
|
||||
@ -67,7 +67,7 @@ export const userSettings = pgTable('user_settings', {
|
||||
apiFormat: varchar('api_format', { length: 20 }).default('claude'),
|
||||
// 默认设置
|
||||
defaultModel: varchar('default_model', { length: 64 }).default('claude-sonnet-4-5-20250929'),
|
||||
defaultTools: jsonb('default_tools').$type<string[]>().default(['web_search', 'web_fetch']),
|
||||
defaultTools: jsonb('default_tools').$type<string[]>().default(['web_search', 'code_execution', 'web_fetch']),
|
||||
// AI 行为设置
|
||||
systemPrompt: text('system_prompt'), // 系统提示词
|
||||
temperature: varchar('temperature', { length: 10 }).default('0.7'), // 温度参数 (0-1)
|
||||
|
||||
@ -14,7 +14,7 @@ async function seedUserSettings() {
|
||||
cchUrl: 'http://localhost:13500',
|
||||
cchApiKeyConfigured: false,
|
||||
defaultModel: 'claude-sonnet-4-5-20250929',
|
||||
defaultTools: ['web_search', 'web_fetch'],
|
||||
defaultTools: ['web_search', 'code_execution', 'web_fetch'],
|
||||
theme: 'light',
|
||||
language: 'zh-CN',
|
||||
enableThinking: false,
|
||||
@ -46,6 +46,24 @@ async function seedTools() {
|
||||
isDefault: true,
|
||||
sortOrder: 1,
|
||||
},
|
||||
{
|
||||
toolId: 'code_execution',
|
||||
name: 'code_execution',
|
||||
displayName: 'Code Execution',
|
||||
description: '执行代码片段并返回结果',
|
||||
icon: 'Terminal',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: { type: 'string', description: '要执行的代码' },
|
||||
language: { type: 'string', description: '编程语言' },
|
||||
},
|
||||
required: ['code', 'language'],
|
||||
},
|
||||
isEnabled: true,
|
||||
isDefault: true,
|
||||
sortOrder: 2,
|
||||
},
|
||||
{
|
||||
toolId: 'web_fetch',
|
||||
name: 'web_fetch',
|
||||
@ -61,7 +79,7 @@ async function seedTools() {
|
||||
},
|
||||
isEnabled: true,
|
||||
isDefault: true,
|
||||
sortOrder: 2,
|
||||
sortOrder: 3,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ const defaultSettings: Settings = {
|
||||
cchApiKeyConfigured: false,
|
||||
apiFormat: 'claude',
|
||||
defaultModel: 'claude-sonnet-4-5-20250929',
|
||||
defaultTools: ['web_search', 'web_fetch'],
|
||||
defaultTools: ['web_search', 'code_execution', 'web_fetch'],
|
||||
systemPrompt: '',
|
||||
temperature: '0.7',
|
||||
theme: 'light',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user