fix: resolve conversation API issues
1. Fixed double data unwrapping in AgentChatPage 2. Fixed API URL in sendMessageStream (use relative path /api/v1) Verified working: AI can now respond to messages
This commit is contained in:
@@ -91,7 +91,8 @@ export const sendMessageStream = async (
|
||||
onError: (error: Error) => void
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/conversations/message/stream`, {
|
||||
// 使用相对路径,通过Vite代理转发到后端
|
||||
const response = await fetch('/api/v1/conversations/message/stream', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -71,8 +71,8 @@ const AgentChatPage = () => {
|
||||
title: `与${agent.name}的对话`,
|
||||
})
|
||||
|
||||
if (response.data.success && response.data.data) {
|
||||
setConversation(response.data.data)
|
||||
if (response.success && response.data) {
|
||||
setConversation(response.data)
|
||||
setMessages([])
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user