Skip to content

Commit b5146f2

Browse files
committed
fix: change fetch to http service
1 parent a3059a7 commit b5146f2

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

designer-demo/src/composable/http/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const preResponse = (res) => {
4646
return Promise.reject(res.data.error)
4747
}
4848

49-
return res.data?.data
49+
return res.data?.data || res.data
5050
}
5151

5252
const openLogin = () => {

packages/plugins/robot/src/mcp/MarkdownRenderer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const defaultMarkdownItOptions = {
2626
}
2727
2828
const props = defineProps<{
29-
type: 'markdown' | 'text'
29+
type?: 'markdown' | 'text'
3030
content: string
3131
options?: MarkdownItOptions
3232
}>()

packages/plugins/robot/src/mcp/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { toRaw } from 'vue'
22
import useMcpServer from './useMcp'
33
import type { LLMMessage, RobotMessage } from './types'
44
import type { LLMRequestBody, LLMResponse, ReponseToolCall, RequestOptions, RequestTool } from './types'
5+
import { META_SERVICE, getMetaApi } from '@opentiny/tiny-engine-meta-register'
56

67
let requestOptions: RequestOptions = {}
78

@@ -14,13 +15,11 @@ const fetchLLM = async (messages: LLMMessage[], tools: RequestTool[], options: R
1415
if (tools.length > 0) {
1516
bodyObj.tools = toRaw(tools)
1617
}
17-
return fetch(options?.url || '/app-center/api/chat/completions', {
18-
method: 'POST',
18+
return getMetaApi(META_SERVICE.Http).post(options?.url || '/app-center/api/chat/completions', bodyObj, {
1919
headers: {
2020
'Content-Type': 'application/json',
2121
...options?.headers
22-
},
23-
body: JSON.stringify(bodyObj)
22+
}
2423
})
2524
}
2625

@@ -82,7 +81,7 @@ const handleToolCall = async (
8281
result: toolCallResult.content
8382
}
8483
}
85-
const newResp = await fetchLLM(toolMessages, tools).then((res) => res.json())
84+
const newResp = await fetchLLM(toolMessages, tools)
8685
const hasToolCall = newResp.choices[0].message.tool_calls?.length > 0
8786
if (hasToolCall) {
8887
await handleToolCall(newResp, tools, messages, toolMessages)
@@ -103,7 +102,7 @@ export const sendMcpRequest = async (messages: LLMMessage[], options: RequestOpt
103102
}
104103
const tools = await useMcpServer().getLLMTools()
105104
requestOptions = options
106-
const res = await fetchLLM(messages.slice(0, -1), tools, options).then((res) => res.json())
105+
const res = await fetchLLM(messages.slice(0, -1), tools, options)
107106
const hasToolCall = res.choices[0].message.tool_calls?.length > 0
108107
if (hasToolCall) {
109108
await handleToolCall(res, tools, messages)

0 commit comments

Comments
 (0)