Skip to content

Commit eb6d435

Browse files
authored
Merge pull request #784 from dustinwloring1988/fix/prompt-enhance #release
fix: prompt enhance patch
2 parents a233008 + d51b0dc commit eb6d435

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

app/routes/api.enhancer.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { streamText } from '~/lib/.server/llm/stream-text';
55
import { stripIndents } from '~/utils/stripIndent';
66
import type { IProviderSetting, ProviderInfo } from '~/types/model';
77

8-
const encoder = new TextEncoder();
9-
const decoder = new TextDecoder();
10-
118
export async function action(args: ActionFunctionArgs) {
129
return enhancerAction(args);
1310
}
@@ -107,29 +104,7 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
107104
providerSettings,
108105
});
109106

110-
const transformStream = new TransformStream({
111-
transform(chunk, controller) {
112-
const text = decoder.decode(chunk);
113-
const lines = text.split('\n').filter((line) => line.trim() !== '');
114-
115-
for (const line of lines) {
116-
try {
117-
const parsed = JSON.parse(line);
118-
119-
if (parsed.type === 'text') {
120-
controller.enqueue(encoder.encode(parsed.value));
121-
}
122-
} catch (e) {
123-
// skip invalid JSON lines
124-
console.warn('Failed to parse stream part:', line, e);
125-
}
126-
}
127-
},
128-
});
129-
130-
const transformedStream = result.toDataStream().pipeThrough(transformStream);
131-
132-
return new Response(transformedStream, {
107+
return new Response(result.textStream, {
133108
status: 200,
134109
headers: {
135110
'Content-Type': 'text/plain; charset=utf-8',

0 commit comments

Comments
 (0)