支持ai对话切换通义千问,

This commit is contained in:
XIE7654
2025-07-22 15:14:29 +08:00
parent 890487e5b1
commit 6f3fe91014
5 changed files with 149 additions and 39 deletions

View File

@@ -5,9 +5,10 @@ export async function getConversations() {
return await res.json();
}
export async function createConversation() {
export async function createConversation(platform: string) {
const response = await fetchWithAuth('chat/conversations', {
method: 'POST',
body: JSON.stringify({ platform }),
});
if (!response.ok) {
throw new Error('创建对话失败');
@@ -25,16 +26,18 @@ export async function getMessages(conversationId: number) {
// 你原有的fetchAIStream方法保留
export interface FetchAIStreamParams {
content: string;
platform: string;
conversation_id?: null | number;
}
export async function fetchAIStream({
content,
platform,
conversation_id,
}: FetchAIStreamParams) {
const res = await fetchWithAuth('chat/stream', {
method: 'POST',
body: JSON.stringify({ content, conversation_id }),
body: JSON.stringify({ content, platform, conversation_id }),
});
if (!res.body) throw new Error('No stream body');
const reader = res.body.getReader();