Skip to content

Commit

Permalink
adapt to worker-ai stream output
Browse files Browse the repository at this point in the history
Signed-off-by: oilbeater <[email protected]>
  • Loading branch information
oilbeater committed Oct 5, 2024
1 parent 2722143 commit 0fc9933
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/providers/workersAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export const workersAIProvider: AIProvider = {
handleRequest: async (c: Context<{ Bindings: Env }>) => {
const response = await c.env.AI.run("@cf/meta/llama-3.1-8b-instruct",
await c.req.json());

return new Response(JSON.stringify(response));
if (response instanceof ReadableStream) {
return new Response(response);
}
return new Response(response.response);
}
};

Expand Down

0 comments on commit 0fc9933

Please sign in to comment.