Skip to content

Commit

Permalink
401st Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Nov 15, 2024
1 parent a74203a commit 2a199e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/routes/sse/model/+handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default (async (app) => {
method: 'POST',
body: JSON.stringify({ message: 'What is GenAI?' }),
});
JSON.parse(event.data as string)?.kwargs?.content;
```
*/
app.post('', async (request, reply) => {
Expand All @@ -33,7 +35,7 @@ export default (async (app) => {
const stream = await model.stream(body.message);

for await (const chunk of stream) {
reply.sse({ data: chunk.content });
reply.sse({ data: chunk.toJSON() });
}

request.raw.on('close', async () => {
Expand Down Expand Up @@ -116,6 +118,8 @@ export default (async (app) => {
import { stream } from 'fetch-event-stream';
await stream('http://127.0.0.1:3000/api/sse/model/query');
JSON.parse(event.data as string)?.answer || '';
```
*/
app.get('/query', async (request, reply) => {
Expand Down Expand Up @@ -155,7 +159,7 @@ export default (async (app) => {
const stream = await ragChain.stream({ input: 'biology' });

for await (const chunk of stream) {
reply.sse({ data: chunk.answer });
reply.sse({ data: chunk });
}

request.raw.on('close', async () => {
Expand Down

0 comments on commit 2a199e9

Please sign in to comment.