Skip to content

Commit

Permalink
fix: route hadler
Browse files Browse the repository at this point in the history
  • Loading branch information
gsaivinay committed Mar 14, 2024
1 parent 546fa1f commit 2846d87
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/app/api/completion/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Anthropic from "@anthropic-ai/sdk";
import { AnthropicStream } from "ai";
import { AnthropicStream, StreamingTextResponse } from "ai";
import { metaprompt } from "@/lib/metaprompt";
import { NextResponse } from "next/server";
import { AnthropicError } from "@anthropic-ai/sdk/error";
Expand All @@ -8,21 +8,6 @@ import { MessageParam } from "@anthropic-ai/sdk/resources";
// IMPORTANT! Set the runtime to edge
export const runtime = "edge";

export class StreamingTextResponse extends Response {
constructor(res: ReadableStream, init?: ResponseInit) {
let processedStream = res;

super(processedStream as any, {
...init,
status: 200,
headers: {
"Content-Type": "text/plain; charset=utf-8",
...init?.headers,
},
});
}
}

function safeJSON(text: string) {
try {
return JSON.parse(text);
Expand Down

0 comments on commit 2846d87

Please sign in to comment.