mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
adds eslint
This commit is contained in:

committed by
Geoff Seemueller

parent
9698fc6f3b
commit
02c3253343
@@ -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`));
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user