Spaces:
Sleeping
Sleeping
Zhichao
commited on
fix: change content-type to json (#117)
Browse filesRelated PR: https://github.com/landing-ai/vision-agent-service/pull/22
Changes the POST request from `multipart/form-data` to the
`application/json`
Also removed the useless `mediaUrl` param.
- app/api/vision-agent/route.ts +11 -14
app/api/vision-agent/route.ts
CHANGED
@@ -110,16 +110,12 @@ export const POST = withLogging(
|
|
110 |
apiMessages: string;
|
111 |
chatId: string;
|
112 |
messageId: string;
|
113 |
-
mediaUrl: string;
|
114 |
},
|
115 |
request,
|
116 |
) => {
|
117 |
-
const { apiMessages,
|
118 |
const user = session?.user?.email ?? 'anonymous';
|
119 |
|
120 |
-
const formData = new FormData();
|
121 |
-
formData.append('input', apiMessages);
|
122 |
-
|
123 |
const fetchResponse = await fetch(
|
124 |
`${process.env.AGENT_HOST}/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,
|
125 |
{
|
@@ -130,8 +126,9 @@ export const POST = withLogging(
|
|
130 |
process.env.LND_TIER === 'production'
|
131 |
? 'land_sk_nMnUf8xiJJUjyw1l5QaIJJ4ZyrvPthzVmPAIG7TtJY7F9CW6lu' // prod key
|
132 |
: 'land_sk_DKeoYtaZZrYqJ9TMMiXe4BIQgJcZ0s3XAoB0JT3jv73FFqnr6k', // dev key
|
|
|
133 |
},
|
134 |
-
body:
|
135 |
},
|
136 |
);
|
137 |
|
@@ -363,15 +360,15 @@ export const POST = withLogging(
|
|
363 |
controller.enqueue(
|
364 |
encoder.encode(
|
365 |
'2:' +
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
},
|
372 |
},
|
373 |
-
|
374 |
-
|
|
|
375 |
),
|
376 |
);
|
377 |
for await (const chunk of fetchResponse.body as any) {
|
|
|
110 |
apiMessages: string;
|
111 |
chatId: string;
|
112 |
messageId: string;
|
|
|
113 |
},
|
114 |
request,
|
115 |
) => {
|
116 |
+
const { apiMessages, chatId, messageId } = json;
|
117 |
const user = session?.user?.email ?? 'anonymous';
|
118 |
|
|
|
|
|
|
|
119 |
const fetchResponse = await fetch(
|
120 |
`${process.env.AGENT_HOST}/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,
|
121 |
{
|
|
|
126 |
process.env.LND_TIER === 'production'
|
127 |
? 'land_sk_nMnUf8xiJJUjyw1l5QaIJJ4ZyrvPthzVmPAIG7TtJY7F9CW6lu' // prod key
|
128 |
: 'land_sk_DKeoYtaZZrYqJ9TMMiXe4BIQgJcZ0s3XAoB0JT3jv73FFqnr6k', // dev key
|
129 |
+
"content-type": "application/json"
|
130 |
},
|
131 |
+
body: JSON.stringify({ input: apiMessages }),
|
132 |
},
|
133 |
);
|
134 |
|
|
|
360 |
controller.enqueue(
|
361 |
encoder.encode(
|
362 |
'2:' +
|
363 |
+
JSON.stringify([
|
364 |
+
{
|
365 |
+
type: 'init',
|
366 |
+
payload: {
|
367 |
+
messageId,
|
|
|
368 |
},
|
369 |
+
},
|
370 |
+
]) +
|
371 |
+
'\n',
|
372 |
),
|
373 |
);
|
374 |
for await (const chunk of fetchResponse.body as any) {
|