changing based on PR review
This commit is contained in:
@@ -30,15 +30,15 @@ function parseCookies(cookieHeader) {
|
||||
}
|
||||
|
||||
async function chatAction({ context, request }: ActionFunctionArgs) {
|
||||
// console.log('=== API CHAT LOGGING START ===');
|
||||
// console.log('Request received:', request.url);
|
||||
|
||||
|
||||
const { messages, imageData } = await request.json<{
|
||||
messages: Messages,
|
||||
imageData?: string[]
|
||||
}>();
|
||||
|
||||
const cookieHeader = request.headers.get("Cookie");
|
||||
|
||||
// Parse the cookie's value (returns an object or null if no cookie exists)
|
||||
const apiKeys = JSON.parse(parseCookies(cookieHeader).apiKeys || "{}");
|
||||
|
||||
const stream = new SwitchableStream();
|
||||
@@ -71,13 +71,6 @@ async function chatAction({ context, request }: ActionFunctionArgs) {
|
||||
|
||||
const result = await streamText(messages, context.cloudflare.env, options, apiKeys);
|
||||
|
||||
// console.log('=== API CHAT LOGGING START ===');
|
||||
// console.log('StreamText:', JSON.stringify({
|
||||
// messages,
|
||||
// result,
|
||||
// }, null, 2));
|
||||
// console.log('=== API CHAT LOGGING END ===');
|
||||
|
||||
stream.switchSource(result.toAIStream());
|
||||
|
||||
return new Response(stream.readable, {
|
||||
|
||||
Reference in New Issue
Block a user