Skip to content

Commit

Permalink
chore: setup for stream
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 23, 2024
1 parent 3f347e3 commit 830847c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions web/core/lib/editor/action/AiActionExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BuiltinFunctionExecutor } from '@/editor/action/BuiltinFunctionExecutor

export class AiActionExecutor {
editor: Editor;
endpointUrl: string = '/api/completion/mock';
endpointUrl: string = '/api/completion';

constructor() {
}
Expand Down Expand Up @@ -38,11 +38,13 @@ export class AiActionExecutor {

const response = await fetch(this.endpoint(action), {
method: 'POST',
body: JSON.stringify({ prompt: prompt })
body: JSON.stringify({ prompt: prompt }),
headers: { Accept: 'text/event-stream' }
});

let allText = '';
let buffer = '';
console.info(response.body)
await response.body?.pipeThrough(new TextDecoderStream()).pipeTo(
new WritableStream({
write: (chunk) => {
Expand Down
2 changes: 1 addition & 1 deletion web/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studio-b3/web-core",
"version": "0.2.8",
"version": "0.2.10",
"type": "module",
"main": "dist/main.js",
"types": "dist-types/main.d.ts",
Expand Down

0 comments on commit 830847c

Please sign in to comment.