Compare commits
4 Commits
c18bb27794
...
5ad191684a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ad191684a | ||
|
|
1c28484091 | ||
|
|
d581b8668a | ||
|
|
65028e37ed |
@ -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', 'code_execution', 'web_fetch'],
|
defaultTools: ['web_search', 'web_fetch'],
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
language: 'zh-CN',
|
language: 'zh-CN',
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
|
|||||||
@ -122,7 +122,6 @@ const DEFAULT_SYSTEM_PROMPT = `你是一个专业、友好的 AI 助手。请遵
|
|||||||
|
|
||||||
## 工具使用
|
## 工具使用
|
||||||
- 当需要查询实时信息时,请使用 web_search 工具
|
- 当需要查询实时信息时,请使用 web_search 工具
|
||||||
- 当需要执行代码验证结果时,请使用 code_execution 工具
|
|
||||||
- 当需要获取网页内容时,请使用 web_fetch 工具
|
- 当需要获取网页内容时,请使用 web_fetch 工具
|
||||||
- **工具调用原则**:只为最新问题调用必要的工具,不要为历史问题调用工具
|
- **工具调用原则**:只为最新问题调用必要的工具,不要为历史问题调用工具
|
||||||
|
|
||||||
@ -133,21 +132,12 @@ 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)展示,而不是分开多次绘制
|
|
||||||
|
|
||||||
## 文档深度分析规范(重要)
|
## 文档深度分析规范(重要)
|
||||||
当用户上传文档/文件并要求分析时,请按以下框架进行**深度分析**,不要简单总结:
|
当用户上传文档/文件并要求分析时,请按以下框架进行**深度分析**,不要简单总结:
|
||||||
|
|
||||||
@ -1643,24 +1633,6 @@ 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 的网页内容。当用户提供了具体的网址并想了解该页面的内容时,请使用此工具。',
|
||||||
@ -1702,27 +1674,6 @@ 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: {
|
||||||
@ -1765,25 +1716,6 @@ 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',
|
||||||
|
|||||||
@ -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', 'code_execution', 'web_fetch'],
|
defaultTools: ['web_search', 'web_fetch'],
|
||||||
systemPrompt: '',
|
systemPrompt: '',
|
||||||
temperature: '0.7',
|
temperature: '0.7',
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
|
|||||||
@ -11,7 +11,10 @@ export async function GET() {
|
|||||||
orderBy: [asc(tools.sortOrder)],
|
orderBy: [asc(tools.sortOrder)],
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(toolList);
|
// 过滤掉 code_execution 工具
|
||||||
|
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(
|
||||||
|
|||||||
@ -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', 'code_execution', 'web_fetch']),
|
defaultTools: jsonb('default_tools').$type<string[]>().default(['web_search', '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)
|
||||||
|
|||||||
@ -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', 'code_execution', 'web_fetch'],
|
defaultTools: ['web_search', 'web_fetch'],
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
language: 'zh-CN',
|
language: 'zh-CN',
|
||||||
enableThinking: false,
|
enableThinking: false,
|
||||||
@ -46,24 +46,6 @@ 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',
|
||||||
@ -79,7 +61,7 @@ async function seedTools() {
|
|||||||
},
|
},
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
isDefault: true,
|
isDefault: true,
|
||||||
sortOrder: 3,
|
sortOrder: 2,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -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', 'code_execution', 'web_fetch'],
|
defaultTools: ['web_search', 'web_fetch'],
|
||||||
systemPrompt: '',
|
systemPrompt: '',
|
||||||
temperature: '0.7',
|
temperature: '0.7',
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user