Compare commits

..

No commits in common. "5ad191684a7a077bdcd2d05790a00ae54ac50231" and "c18bb27794dd769b3981134daab95d72f4ecb83a" have entirely different histories.

7 changed files with 93 additions and 10 deletions

View File

@ -129,7 +129,7 @@ export async function POST(request: NextRequest) {
cchApiKey: null, cchApiKey: null,
cchApiKeyConfigured: false, cchApiKeyConfigured: false,
defaultModel: 'claude-sonnet-4-5-20250929', defaultModel: 'claude-sonnet-4-5-20250929',
defaultTools: ['web_search', 'web_fetch'], defaultTools: ['web_search', 'code_execution', 'web_fetch'],
theme: 'light', theme: 'light',
language: 'zh-CN', language: 'zh-CN',
fontSize: 15, fontSize: 15,

View File

@ -122,6 +122,7 @@ const DEFAULT_SYSTEM_PROMPT = `你是一个专业、友好的 AI 助手。请遵
## 使 ## 使
- 使 web_search - 使 web_search
- 使 code_execution
- 使 web_fetch - 使 web_fetch
- **** - ****
@ -132,12 +133,21 @@ const DEFAULT_SYSTEM_PROMPT = `你是一个专业、友好的 AI 助手。请遵
3. **** 3. ****
- "今天北京天气晴朗气温15°C。来源weather.com" - "今天北京天气晴朗气温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'], 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: { web_fetch: {
name: 'web_fetch', name: 'web_fetch',
description: '获取指定 URL 的网页内容。当用户提供了具体的网址并想了解该页面的内容时,请使用此工具。', 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: { web_fetch: {
type: 'function', type: 'function',
function: { function: {
@ -1716,6 +1765,25 @@ function buildCodexToolDefinitions(toolIds: string[]) {
required: ['query'], 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: { web_fetch: {
type: 'function', type: 'function',
name: 'web_fetch', name: 'web_fetch',

View File

@ -11,7 +11,7 @@ const DEFAULT_SETTINGS = {
cchApiKeyConfigured: false, cchApiKeyConfigured: false,
apiFormat: 'claude' as 'claude' | 'openai', // API 格式claude原生| openai兼容 apiFormat: 'claude' as 'claude' | 'openai', // API 格式claude原生| openai兼容
defaultModel: 'claude-sonnet-4-5-20250929', defaultModel: 'claude-sonnet-4-5-20250929',
defaultTools: ['web_search', 'web_fetch'], defaultTools: ['web_search', 'code_execution', 'web_fetch'],
systemPrompt: '', systemPrompt: '',
temperature: '0.7', temperature: '0.7',
theme: 'light', theme: 'light',

View File

@ -11,10 +11,7 @@ export async function GET() {
orderBy: [asc(tools.sortOrder)], orderBy: [asc(tools.sortOrder)],
}); });
// 过滤掉 code_execution 工具 return NextResponse.json(toolList);
const filteredTools = toolList.filter(tool => tool.toolId !== 'code_execution');
return NextResponse.json(filteredTools);
} catch (error) { } catch (error) {
console.error('Failed to get tools:', error); console.error('Failed to get tools:', error);
return NextResponse.json( return NextResponse.json(

View File

@ -67,7 +67,7 @@ export const userSettings = pgTable('user_settings', {
apiFormat: varchar('api_format', { length: 20 }).default('claude'), apiFormat: varchar('api_format', { length: 20 }).default('claude'),
// 默认设置 // 默认设置
defaultModel: varchar('default_model', { length: 64 }).default('claude-sonnet-4-5-20250929'), 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 行为设置 // AI 行为设置
systemPrompt: text('system_prompt'), // 系统提示词 systemPrompt: text('system_prompt'), // 系统提示词
temperature: varchar('temperature', { length: 10 }).default('0.7'), // 温度参数 (0-1) temperature: varchar('temperature', { length: 10 }).default('0.7'), // 温度参数 (0-1)

View File

@ -14,7 +14,7 @@ async function seedUserSettings() {
cchUrl: 'http://localhost:13500', cchUrl: 'http://localhost:13500',
cchApiKeyConfigured: false, cchApiKeyConfigured: false,
defaultModel: 'claude-sonnet-4-5-20250929', defaultModel: 'claude-sonnet-4-5-20250929',
defaultTools: ['web_search', 'web_fetch'], defaultTools: ['web_search', 'code_execution', 'web_fetch'],
theme: 'light', theme: 'light',
language: 'zh-CN', language: 'zh-CN',
enableThinking: false, enableThinking: false,
@ -46,6 +46,24 @@ async function seedTools() {
isDefault: true, isDefault: true,
sortOrder: 1, 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', toolId: 'web_fetch',
name: 'web_fetch', name: 'web_fetch',
@ -61,7 +79,7 @@ async function seedTools() {
}, },
isEnabled: true, isEnabled: true,
isDefault: true, isDefault: true,
sortOrder: 2, sortOrder: 3,
}, },
]; ];

View File

@ -53,7 +53,7 @@ const defaultSettings: Settings = {
cchApiKeyConfigured: false, cchApiKeyConfigured: false,
apiFormat: 'claude', apiFormat: 'claude',
defaultModel: 'claude-sonnet-4-5-20250929', defaultModel: 'claude-sonnet-4-5-20250929',
defaultTools: ['web_search', 'web_fetch'], defaultTools: ['web_search', 'code_execution', 'web_fetch'],
systemPrompt: '', systemPrompt: '',
temperature: '0.7', temperature: '0.7',
theme: 'light', theme: 'light',