Spaces:
Sleeping
Sleeping
fix: revert failed deployment (#81)
Browse files
Files changed (2)
10 unmodified lines1112131415161774 unmodified lines9293949596979850 unmodified lines1491501511521531541554 unmodified lines1601611621631641651661671681691701711721731741751761771781791801811822 unmodified lines18518618718818919019119219319419519619719819920020120220320420520620720820921021110 unmodified lines// export const runtime = 'edge';export const dynamic = 'force-dynamic';export const maxDuration = 300; // This function can run for a maximum of 5 minutesconst TIMEOUT_MILI_SECONDS = 5 * 60 * 1000;const uploadBase64 = async (base64: string,74 unmodified linesconst fetchResponse = await fetch(`https://api.dev.landing.ai/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,// `http://localhost:5001/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,{method: 'POST',headers: {50 unmodified linesconst decoder = new TextDecoder('utf-8');let maxChunkSize = 0;let buffer = '';let time = Date.now();const stream = new ReadableStream({async start(controller) {// const parser = createParser(streamParser);4 unmodified linesconst lines = buffer.split('\n').filter(line => line.trim().length > 0);if (lines.length === 0) {if (Date.now() - time > TIMEOUT_MILI_SECONDS) {logger.info(session,{message: 'Agent timed out',},request,'__Agent_timeout__',);controller.error(`Haven't received any response in last ${TIMEOUT_MILI_SECONDS / 60000} minutes, agent timed out.`,);}} else {time = Date.now();}buffer = lines.pop() ?? ''; // Save the last incomplete line back to the bufferlet done = false;const parseLine = async (2 unmodified lines) => {try {const msg = JSON.parse(line);if (msg.type !== 'final_code' &&(msg.type !== 'code' ||msg.status === 'started' ||msg.status === 'running')) {return line;}if (msg.type === 'code') {msg.payload.result = JSON.stringify({...msg.payload.result,results: msg.payload.result.results.map((_result: any) => {return {..._result,png: undefined,mp4: undefined,};}),});return JSON.stringify(msg);}const result = JSON.parse(msg.payload.result) as ResultPayload;for (let index = 0; index < result.results.length; index++) {const png = result.results[index].png ?? '';10 unmodified lines11121314151674 unmodified lines9192939495969750 unmodified lines1481491501511521534 unmodified lines1581591601611621632 unmodified lines16616716816917017117217317410 unmodified lines// export const runtime = 'edge';export const dynamic = 'force-dynamic';export const maxDuration = 300; // This function can run for a maximum of 5 minutesconst uploadBase64 = async (base64: string,74 unmodified linesconst fetchResponse = await fetch(`https://api.dev.landing.ai/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,// `http://localhost:5001/v1/agent/chat?agent_class=vision_agent&self_reflection=${enableSelfReflection}`,{method: 'POST',headers: {50 unmodified linesconst decoder = new TextDecoder('utf-8');let maxChunkSize = 0;let buffer = '';const stream = new ReadableStream({async start(controller) {// const parser = createParser(streamParser);4 unmodified linesconst lines = buffer.split('\n').filter(line => line.trim().length > 0);buffer = lines.pop() ?? ''; // Save the last incomplete line back to the bufferlet done = false;const parseLine = async (2 unmodified lines) => {try {const msg = JSON.parse(line);if (msg.type !== 'final_code') {return line;}const result = JSON.parse(msg.payload.result) as ResultPayload;for (let index = 0; index < result.results.length; index++) {const png = result.results[index].png ?? '';
21 unmodified lines2223242526272821 unmodified linesmediaUrl:'https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/shark3_short.mp4',prompt:'Can you detect any surfboards or sharks in the video, draw a green line between the shark and the nearest paddle boarder and add the distance between them in meters assuming 30 pixels is 1 meter. Make the line red if the shark is within 10 meters of a surfboard. Sample the video at 3 frames per second and save the output video as output.mp4.',},];21 unmodified lines2223242526272821 unmodified linesmediaUrl:'https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/shark3_short.mp4',prompt:'Can you detect any surfboards or sharks in the video, draw a green line between the shark and the nearest surfboard and add the distance between them in meters assuming 30 pixels is 1 meter. Make the line red if the shark is within 10 meters of a surfboard. Sample the video at 1 frames per second and save the output video as output.mp4.',},];
app/api/vision-agent/route.ts+2-39
app/page.tsx+1-1