diff --git a/README.md b/README.md index c7fdba5..faa6232 100644 --- a/README.md +++ b/README.md @@ -105,17 +105,3 @@ B <--mcp--> m(MCP Server) ``` and just press f5, いただきます - -## Flowchart - - -```mermaid -flowchart TB - A[用户输入问题] --> B[选择工具] - B --> C[大模型处理] - C --> D{是否有tool use?} - D -- 否 --> E[返回 content] - D -- 是 --> F[执行工具] - F --> G[返回工具执行结果] - G --> C -``` \ No newline at end of file diff --git a/renderer/src/App.vue b/renderer/src/App.vue index 013e3dd..69653c0 100644 --- a/renderer/src/App.vue +++ b/renderer/src/App.vue @@ -15,7 +15,7 @@ import MainPanel from '@/components/main-panel/index.vue'; import { setDefaultCss } from './hook/css'; import { greenLog, pinkLog } from './views/setting/util'; import { acquireVsCodeApi, useMessageBridge } from './api/message-bridge'; -import { connectionArgs, connectionMethods, connectionResult, doConnect, getServerVersion, launchConnect } from './views/connect/connection'; +import { connectionArgs, connectionMethods, doConnect, launchConnect } from './views/connect/connection'; import { loadSetting } from './hook/setting'; import { loadPanels } from './hook/panel'; @@ -29,7 +29,7 @@ bridge.addCommandListener('hello', data => { function initDebug() { - connectionArgs.commandString = 'uv run mcp run ../servers/main.py'; + connectionArgs.commandString = 'node C:/Users/K/code/servers/src/puppeteer/dist/index.js'; connectionMethods.current = 'STDIO'; setTimeout(async () => { diff --git a/renderer/src/components/k-input-object/index.vue b/renderer/src/components/k-input-object/index.vue new file mode 100644 index 0000000..51ea1bb --- /dev/null +++ b/renderer/src/components/k-input-object/index.vue @@ -0,0 +1,194 @@ + + + + + \ No newline at end of file diff --git a/renderer/src/components/main-panel/chat/chat.ts b/renderer/src/components/main-panel/chat/chat.ts index 9a0e6bb..7ded387 100644 --- a/renderer/src/components/main-panel/chat/chat.ts +++ b/renderer/src/components/main-panel/chat/chat.ts @@ -1,14 +1,27 @@ import { ToolItem } from "@/hook/type"; -import { ref } from "vue"; +import { Ref, ref } from "vue"; import type { OpenAI } from 'openai'; type ChatCompletionChunk = OpenAI.Chat.Completions.ChatCompletionChunk; +export enum MessageState { + ServerError = 'server internal error', + ReceiveChunkError = 'receive chunk error', + Timeout = 'timeout', + MaxEpochs = 'max epochs', + Unknown = 'unknown error', + Abort = 'abort', + ToolCall = 'tool call failed', + None = 'none', + Success = 'success' +} + export interface IExtraInfo { created: number, + state: MessageState, serverName: string, usage?: ChatCompletionChunk['usage']; - [key: string]: any + [key: string]: any; } export interface ChatMessage { @@ -53,6 +66,15 @@ export interface ToolCall { export const allTools = ref([]); +export interface IRenderMessage { + role: 'user' | 'assistant/content' | 'assistant/tool_calls' | 'tool'; + content: string; + toolResult?: string; + tool_calls?: ToolCall[]; + showJson?: Ref; + extraInfo: IExtraInfo; +} + export function getToolSchema(enableTools: EnableToolItem[]) { const toolsSchema = []; for (let i = 0; i < enableTools.length; i++) { diff --git a/renderer/src/components/main-panel/chat/index.vue b/renderer/src/components/main-panel/chat/index.vue index 937ac04..feec0c0 100644 --- a/renderer/src/components/main-panel/chat/index.vue +++ b/renderer/src/components/main-panel/chat/index.vue @@ -78,11 +78,11 @@ diff --git a/renderer/src/components/main-panel/chat/message/toolcall.vue b/renderer/src/components/main-panel/chat/message/toolcall.vue index 351d04b..28e6667 100644 --- a/renderer/src/components/main-panel/chat/message/toolcall.vue +++ b/renderer/src/components/main-panel/chat/message/toolcall.vue @@ -1,16 +1,16 @@ @@ -53,9 +62,10 @@ import { useI18n } from 'vue-i18n'; import type { FormInstance, FormRules } from 'element-plus'; import { tabs } from '../panel'; import { callTool, toolsManager, ToolStorage } from './tools'; -import { pinkLog } from '@/views/setting/util'; import { getDefaultValue, normaliseJavascriptType } from '@/hook/mcp'; +import KInputObject from '@/components/k-input-object/index.vue'; + defineComponent({ name: 'tool-executor' }); const { t } = useI18n(); @@ -74,6 +84,9 @@ if (!tabStorage.formData) { tabStorage.formData = {}; } +console.log(tabStorage.formData); + + const formRef = ref(); const loading = ref(false); @@ -81,6 +94,7 @@ const currentTool = computed(() => { return toolsManager.tools.find(tool => tool.name === tabStorage.currentToolName); }); + const formRules = computed(() => { const rules: FormRules = {}; if (!currentTool.value?.inputSchema?.properties) return rules; @@ -108,11 +122,13 @@ const initFormData = () => { if (!currentTool.value?.inputSchema?.properties) return; - const newSchemaDataForm: Record = {}; + const newSchemaDataForm: Record = {}; + + console.log(currentTool.value.inputSchema.properties); Object.entries(currentTool.value.inputSchema.properties).forEach(([name, property]) => { newSchemaDataForm[name] = getDefaultValue(property); - const originType = normaliseJavascriptType(typeof tabStorage.formData[name]); + const originType = normaliseJavascriptType(typeof tabStorage.formData[name]); if (tabStorage.formData[name] !== undefined && originType === property.type) { newSchemaDataForm[name] = tabStorage.formData[name]; @@ -145,4 +161,21 @@ watch(() => tabStorage.currentToolName, () => { border-radius: .5em; margin-bottom: 15px; } + +.tool-executor-container { + +} + +.tool-executor-container .el-switch .el-switch__action { + background-color: var(--main-color); +} + +.tool-executor-container .el-switch.is-checked .el-switch__action { + background-color: var(--sidebar); +} + +.tool-executor-container .el-switch__core { + border: 1px solid var(--main-color) !important; +} + \ No newline at end of file diff --git a/renderer/src/components/main-panel/tool/tools.ts b/renderer/src/components/main-panel/tool/tools.ts index 8e62fdd..fdcff66 100644 --- a/renderer/src/components/main-panel/tool/tools.ts +++ b/renderer/src/components/main-panel/tool/tools.ts @@ -12,7 +12,7 @@ export const toolsManager = reactive<{ export interface ToolStorage { currentToolName: string; lastToolCallResponse?: ToolCallResponse; - formData: Record; + formData: Record; } const bridge = useMessageBridge(); diff --git a/renderer/src/hook/mcp.ts b/renderer/src/hook/mcp.ts index 9e19f78..13a7b2c 100644 --- a/renderer/src/hook/mcp.ts +++ b/renderer/src/hook/mcp.ts @@ -1,14 +1,14 @@ -import { SchemaProperty } from "./type"; - interface TypeAble { type: string; } -export function getDefaultValue(property: TypeAble) { +export function getDefaultValue(property: TypeAble) { if (property.type === 'number' || property.type === 'integer') { return 0; } else if (property.type === 'boolean') { return false; + } else if (property.type === 'object') { + return {}; } else { return ''; } @@ -19,7 +19,7 @@ export function normaliseJavascriptType(type: string) { case 'integer': return 'number'; case 'number': - return 'integer'; + return 'number'; case 'boolean': return 'boolean'; case 'string': diff --git a/renderer/src/hook/type.ts b/renderer/src/hook/type.ts index d0af559..b64d3fe 100644 --- a/renderer/src/hook/type.ts +++ b/renderer/src/hook/type.ts @@ -2,6 +2,7 @@ export interface SchemaProperty { title: string; type: string; + description?: string; } export interface InputSchema { diff --git a/renderer/src/i18n/ar.json b/renderer/src/i18n/ar.json index bf13512..85d6e35 100644 --- a/renderer/src/i18n/ar.json +++ b/renderer/src/i18n/ar.json @@ -144,5 +144,6 @@ "single-dialog": "محادثة من جولة واحدة", "multi-dialog": "محادثة متعددة الجولات", "press-and-run": "اكتب سؤالاً لبدء الاختبار", - "connect-sigature": "توقيع الاتصال" + "connect-sigature": "توقيع الاتصال", + "finish-refresh": "تم التحديث" } \ No newline at end of file diff --git a/renderer/src/i18n/de.json b/renderer/src/i18n/de.json index f279f5b..4f8ef60 100644 --- a/renderer/src/i18n/de.json +++ b/renderer/src/i18n/de.json @@ -144,5 +144,6 @@ "single-dialog": "Einzelrunden-Dialog", "multi-dialog": "Mehrrundengespräch", "press-and-run": "Geben Sie eine Frage ein, um den Test zu starten", - "connect-sigature": "Verbindungssignatur" + "connect-sigature": "Verbindungssignatur", + "finish-refresh": "Aktualisierung abgeschlossen" } \ No newline at end of file diff --git a/renderer/src/i18n/en.json b/renderer/src/i18n/en.json index e1db33b..be37a10 100644 --- a/renderer/src/i18n/en.json +++ b/renderer/src/i18n/en.json @@ -144,5 +144,6 @@ "single-dialog": "Single-round dialogue", "multi-dialog": "Multi-turn conversation", "press-and-run": "Type a question to start the test", - "connect-sigature": "Connection signature" + "connect-sigature": "Connection signature", + "finish-refresh": "Refresh completed" } \ No newline at end of file diff --git a/renderer/src/i18n/fr.json b/renderer/src/i18n/fr.json index 75005fc..84fd9b9 100644 --- a/renderer/src/i18n/fr.json +++ b/renderer/src/i18n/fr.json @@ -144,5 +144,6 @@ "single-dialog": "Dialogue en un tour", "multi-dialog": "Conversation multi-tours", "press-and-run": "Tapez une question pour commencer le test", - "connect-sigature": "Signature de connexion" + "connect-sigature": "Signature de connexion", + "finish-refresh": "Actualisation terminée" } \ No newline at end of file diff --git a/renderer/src/i18n/ja.json b/renderer/src/i18n/ja.json index 1309121..dae39a5 100644 --- a/renderer/src/i18n/ja.json +++ b/renderer/src/i18n/ja.json @@ -144,5 +144,6 @@ "single-dialog": "単一ラウンドの対話", "multi-dialog": "マルチターン会話", "press-and-run": "テストを開始するには質問を入力してください", - "connect-sigature": "接続署名" + "connect-sigature": "接続署名", + "finish-refresh": "更新が完了しました" } \ No newline at end of file diff --git a/renderer/src/i18n/ko.json b/renderer/src/i18n/ko.json index b755e59..dbb3937 100644 --- a/renderer/src/i18n/ko.json +++ b/renderer/src/i18n/ko.json @@ -144,5 +144,6 @@ "single-dialog": "단일 라운드 대화", "multi-dialog": "다중 턴 대화", "press-and-run": "테스트를 시작하려면 질문을 입력하세요", - "connect-sigature": "연결 서명" + "connect-sigature": "연결 서명", + "finish-refresh": "새로 고침 완료" } \ No newline at end of file diff --git a/renderer/src/i18n/ru.json b/renderer/src/i18n/ru.json index 5e8d9dd..70edc40 100644 --- a/renderer/src/i18n/ru.json +++ b/renderer/src/i18n/ru.json @@ -144,5 +144,6 @@ "single-dialog": "Однораундовый диалог", "multi-dialog": "Многораундовый разговор", "press-and-run": "Введите вопрос, чтобы начать тест", - "connect-sigature": "Подпись соединения" + "connect-sigature": "Подпись соединения", + "finish-refresh": "Обновление завершено" } \ No newline at end of file diff --git a/renderer/src/i18n/zh-cn.json b/renderer/src/i18n/zh-cn.json index e11f387..c54e781 100644 --- a/renderer/src/i18n/zh-cn.json +++ b/renderer/src/i18n/zh-cn.json @@ -144,5 +144,6 @@ "single-dialog": "单轮对话", "multi-dialog": "多轮对话", "press-and-run": "键入问题以开始测试", - "connect-sigature": "连接签名" + "connect-sigature": "连接签名", + "finish-refresh": "完成刷新" } \ No newline at end of file diff --git a/renderer/src/i18n/zh-tw.json b/renderer/src/i18n/zh-tw.json index 223e2ed..d594731 100644 --- a/renderer/src/i18n/zh-tw.json +++ b/renderer/src/i18n/zh-tw.json @@ -144,5 +144,6 @@ "single-dialog": "單輪對話", "multi-dialog": "多輪對話", "press-and-run": "輸入問題以開始測試", - "connect-sigature": "連接簽名" + "connect-sigature": "連接簽名", + "finish-refresh": "刷新完成" } \ No newline at end of file diff --git a/renderer/src/views/connect/connection-log.vue b/renderer/src/views/connect/connection-log.vue index a49bbd0..0dceaf3 100644 --- a/renderer/src/views/connect/connection-log.vue +++ b/renderer/src/views/connect/connection-log.vue @@ -1,7 +1,7 @@