Zhichao commited on
Commit
a031dc6
1 Parent(s): 1c2515f

fix: change content-type to json (#117)

Browse files

Related 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.

Files changed (1) hide show
  1. 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, mediaUrl, chatId, messageId } = json;
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: formData,
135
  },
136
  );
137
 
@@ -363,15 +360,15 @@ export const POST = withLogging(
363
  controller.enqueue(
364
  encoder.encode(
365
  '2:' +
366
- JSON.stringify([
367
- {
368
- type: 'init',
369
- payload: {
370
- messageId,
371
- },
372
  },
373
- ]) +
374
- '\n',
 
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) {