Spaces:
Running
Running
wuyiqunLu commited on
fix: timeout error not show in progress (#96)
Browse filesbecause previously was not properly encoded but this enqueue can be
removed since the chat will be refreshed with db data
<img width="982" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/132986242/cfd0bbd5-e1e7-4159-8a4f-14c0225a55fa">
app/api/vision-agent/route.ts
CHANGED
|
@@ -214,11 +214,6 @@ export const POST = withLogging(
|
|
| 214 |
if (lines.length === 0) {
|
| 215 |
if (Date.now() - time > TIMEOUT_MILI_SECONDS) {
|
| 216 |
results.push(FINAL_TIMEOUT_ERROR);
|
| 217 |
-
// https://github.com/vercel/ai/blob/f7002ad2c5aa58ce6ed83e8d31fe22f71ebdb7d7/packages/ui-utils/src/stream-parts.ts#L62
|
| 218 |
-
controller.enqueue(
|
| 219 |
-
'2:' +
|
| 220 |
-
encoder.encode(JSON.stringify(FINAL_TIMEOUT_ERROR) + '\n'),
|
| 221 |
-
);
|
| 222 |
return { done: true, reason: 'timeout' };
|
| 223 |
}
|
| 224 |
} else {
|
|
@@ -240,6 +235,7 @@ export const POST = withLogging(
|
|
| 240 |
return { done: true, reason: 'api_error', error };
|
| 241 |
} else if (parsedMsg) {
|
| 242 |
results.push(parsedMsg);
|
|
|
|
| 243 |
controller.enqueue(
|
| 244 |
encoder.encode('2:' + JSON.stringify([parsedMsg]) + '\n'),
|
| 245 |
);
|
|
|
|
| 214 |
if (lines.length === 0) {
|
| 215 |
if (Date.now() - time > TIMEOUT_MILI_SECONDS) {
|
| 216 |
results.push(FINAL_TIMEOUT_ERROR);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
return { done: true, reason: 'timeout' };
|
| 218 |
}
|
| 219 |
} else {
|
|
|
|
| 235 |
return { done: true, reason: 'api_error', error };
|
| 236 |
} else if (parsedMsg) {
|
| 237 |
results.push(parsedMsg);
|
| 238 |
+
// https://github.com/vercel/ai/blob/f7002ad2c5aa58ce6ed83e8d31fe22f71ebdb7d7/packages/ui-utils/src/stream-parts.ts#L62
|
| 239 |
controller.enqueue(
|
| 240 |
encoder.encode('2:' + JSON.stringify([parsedMsg]) + '\n'),
|
| 241 |
);
|