提交 d92065e4 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 8daae360
......@@ -22,7 +22,7 @@ function getCommonResponseMessage(res: any) {
const message = JSON.parse(res.data)
if (message.choices && message.choices.length > 0) {
const content = message.choices[0].delta?.content || ''
return { id: message.id, content, json: extractJSON(content) }
return { id: message.id, role: 'assistant', content, json: extractJSON(content) } as AIMessage
}
} catch (error) {
console.error(error)
......@@ -154,11 +154,9 @@ export async function openAIStream(data: AIData, options: InitOptions): Promise<
export async function openAI(data: AIData, options: InitOptions): Promise<void> {
try {
const response = await axios.post(
'/api/openai/chat/create',
{ stream: true, ...data },
{ headers: { 'Content-Type': 'application/json', Authorization: 'ezijing@20250331' } }
)
const response = await axios.post('/api/openai/chat/create', data, {
headers: { 'Content-Type': 'application/json', Authorization: 'ezijing@20250331' },
})
const content = response.data.choices[0]?.message?.content || ''
const message: AIMessage = {
id: response.data.id,
......
......@@ -25,5 +25,5 @@ export interface AIResponse {
}
export interface InitOptions extends FetchEventSourceInit {
onMessage?: (message: AIResponse) => void
onMessage?: (message: AIMessage) => void
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论