Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion designer-demo/src/composable/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/robot/src/js/robotSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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的响应式数据
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/robot/src/mcp/MarkdownRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultMarkdownItOptions = {
}

const props = defineProps<{
type: 'markdown' | 'text'
type?: 'markdown' | 'text'
content: string
options?: MarkdownItOptions
}>()
Expand Down
11 changes: 5 additions & 6 deletions packages/plugins/robot/src/mcp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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)
}
})
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down