adds eslint

This commit is contained in:
geoffsee
2025-06-24 17:29:52 -04:00
committed by Geoff Seemueller
parent 9698fc6f3b
commit 02c3253343
169 changed files with 4896 additions and 4804 deletions

View File

@@ -22,15 +22,9 @@ interface StreamResponse {
};
}
const handleStreamData = (
controller: ReadableStreamDefaultController,
encoder: TextEncoder,
) => {
return (
data: StreamResponse,
transformFn?: (data: StreamResponse) => StreamResponse,
) => {
if (!data?.type || data.type !== "chat") {
const handleStreamData = (controller: ReadableStreamDefaultController, encoder: TextEncoder) => {
return (data: StreamResponse, transformFn?: (data: StreamResponse) => StreamResponse) => {
if (!data?.type || data.type !== 'chat') {
return;
}
@@ -39,17 +33,14 @@ const handleStreamData = (
if (transformFn) {
transformedData = transformFn(data);
} else {
if (
data.data.type === "content_block_start" &&
data.data.content_block?.type === "text"
) {
if (data.data.type === 'content_block_start' && data.data.content_block?.type === 'text') {
transformedData = {
type: "chat",
type: 'chat',
data: {
choices: [
{
delta: {
content: data.data.content_block.text || "",
content: data.data.content_block.text || '',
},
logprobs: null,
finish_reason: null,
@@ -59,7 +50,7 @@ const handleStreamData = (
};
} else if (data.data.delta?.text) {
transformedData = {
type: "chat",
type: 'chat',
data: {
choices: [
{
@@ -74,7 +65,7 @@ const handleStreamData = (
};
} else if (data.data.choices?.[0]?.delta?.content) {
transformedData = {
type: "chat",
type: 'chat',
data: {
choices: [
{
@@ -95,9 +86,7 @@ const handleStreamData = (
}
}
controller.enqueue(
encoder.encode(`data: ${JSON.stringify(transformedData)}\n\n`),
);
controller.enqueue(encoder.encode(`data: ${JSON.stringify(transformedData)}\n\n`));
};
};