mirror of
https://github.com/coleam00/bolt.new-any-llm
synced 2024-12-27 22:33:03 +00:00
fix: Prompt Enhance
Prompt Enhance option stopped, this fixes it
This commit is contained in:
parent
0ee3736297
commit
05146c18d6
@ -114,14 +114,30 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const parsed = JSON.parse(line);
|
||||
// Handle token-based streaming format
|
||||
if (line.includes('0:"')) {
|
||||
// Extract all token contents and join them
|
||||
const tokens = line.match(/0:"([^"]+)"/g) || [];
|
||||
const content = tokens
|
||||
.map(token => token.slice(3, -1)) // Remove the '0:"' prefix and '"' suffix
|
||||
.join('');
|
||||
|
||||
if (content) {
|
||||
controller.enqueue(encoder.encode(content));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to parse as JSON if it's not token-based format
|
||||
const parsed = JSON.parse(line);
|
||||
if (parsed.type === 'text') {
|
||||
controller.enqueue(encoder.encode(parsed.value));
|
||||
}
|
||||
} catch (e) {
|
||||
// skip invalid JSON lines
|
||||
console.warn('Failed to parse stream part:', line, e);
|
||||
// If not JSON and not token-based, treat as plain text
|
||||
if (!line.includes('e:') && !line.includes('d:')) { // Skip metadata lines
|
||||
controller.enqueue(encoder.encode(line));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user