Ahh fix bloating size upload was to large
This commit is contained in:
+10
-6
@@ -1,18 +1,22 @@
|
||||
const AI_SERVICE = process.env.AI_SERVICE_URL || "http://localhost:3001"
|
||||
|
||||
export async function chatWithAI(message: string, jwtToken: string) {
|
||||
const res = await fetch(`${AI_SERVICE}/ai/chat`, {
|
||||
const url = `${AI_SERVICE}/ai/chat`
|
||||
const body = JSON.stringify({ message })
|
||||
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${jwtToken}` },
|
||||
body: JSON.stringify({ message }),
|
||||
headers: { "Content-Type": "application/json", Authorization: `Bearer ${jwtToken}` },
|
||||
body,
|
||||
})
|
||||
|
||||
const text = await res.text()
|
||||
|
||||
if (!res.ok) {
|
||||
const text = await res.text()
|
||||
throw new Error(`AI service error (${res.status}): ${text}`)
|
||||
throw new Error(`AI error ${res.status}: ${text.substring(0, 200)}`)
|
||||
}
|
||||
|
||||
const data = await res.json()
|
||||
const data = JSON.parse(text)
|
||||
return data.response || ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user