diff --git a/designer-demo/src/composable/http/index.js b/designer-demo/src/composable/http/index.js index f11538395a..633ccb1bc1 100644 --- a/designer-demo/src/composable/http/index.js +++ b/designer-demo/src/composable/http/index.js @@ -46,7 +46,7 @@ const preResponse = (res) => { return Promise.reject(res.data.error) } - return res.data?.data + return res.data?.data || res.data } const openLogin = () => { diff --git a/packages/plugins/robot/src/js/robotSetting.ts b/packages/plugins/robot/src/js/robotSetting.ts index ddbdf02343..999181a602 100644 --- a/packages/plugins/robot/src/js/robotSetting.ts +++ b/packages/plugins/robot/src/js/robotSetting.ts @@ -19,7 +19,7 @@ const DEFAULT_MODELS = [{ label: 'DeepSeek:DeepSeek-V3', value: 'deepseek-chat export const getAIModelOptions = () => { const aiRobotOptions = getOptions(meta.id)?.customCompatibleAIModels || [] - return [...DEFAULT_MODELS, ...aiRobotOptions] + return aiRobotOptions.length ? aiRobotOptions : DEFAULT_MODELS } // 这里存放的是aichat的响应式数据 diff --git a/packages/plugins/robot/src/mcp/MarkdownRenderer.vue b/packages/plugins/robot/src/mcp/MarkdownRenderer.vue index 6578667985..6fc7ba4ab6 100644 --- a/packages/plugins/robot/src/mcp/MarkdownRenderer.vue +++ b/packages/plugins/robot/src/mcp/MarkdownRenderer.vue @@ -26,7 +26,7 @@ const defaultMarkdownItOptions = { } const props = defineProps<{ - type: 'markdown' | 'text' + type?: 'markdown' | 'text' content: string options?: MarkdownItOptions }>() diff --git a/packages/plugins/robot/src/mcp/utils.ts b/packages/plugins/robot/src/mcp/utils.ts index 5ef759a8d2..8b785bca98 100644 --- a/packages/plugins/robot/src/mcp/utils.ts +++ b/packages/plugins/robot/src/mcp/utils.ts @@ -2,6 +2,7 @@ import { toRaw } from 'vue' import useMcpServer from './useMcp' import type { LLMMessage, RobotMessage } from './types' import type { LLMRequestBody, LLMResponse, ReponseToolCall, RequestOptions, RequestTool } from './types' +import { META_SERVICE, getMetaApi } from '@opentiny/tiny-engine-meta-register' let requestOptions: RequestOptions = {} @@ -14,13 +15,11 @@ const fetchLLM = async (messages: LLMMessage[], tools: RequestTool[], options: R if (tools.length > 0) { bodyObj.tools = toRaw(tools) } - return fetch(options?.url || '/app-center/api/chat/completions', { - method: 'POST', + return getMetaApi(META_SERVICE.Http).post(options?.url || '/app-center/api/chat/completions', bodyObj, { headers: { 'Content-Type': 'application/json', ...options?.headers - }, - body: JSON.stringify(bodyObj) + } }) } @@ -82,7 +81,7 @@ const handleToolCall = async ( result: toolCallResult.content } } - const newResp = await fetchLLM(toolMessages, tools).then((res) => res.json()) + const newResp = await fetchLLM(toolMessages, tools) const hasToolCall = newResp.choices[0].message.tool_calls?.length > 0 if (hasToolCall) { await handleToolCall(newResp, tools, messages, toolMessages) @@ -103,7 +102,7 @@ export const sendMcpRequest = async (messages: LLMMessage[], options: RequestOpt } const tools = await useMcpServer().getLLMTools() requestOptions = options - const res = await fetchLLM(messages.slice(0, -1), tools, options).then((res) => res.json()) + const res = await fetchLLM(messages.slice(0, -1), tools, options) const hasToolCall = res.choices[0].message.tool_calls?.length > 0 if (hasToolCall) { await handleToolCall(res, tools, messages)