Skip to content

Commit

Permalink
403rd Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Nov 19, 2024
1 parent c47c3b8 commit 2f2376f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/src/routes/sse/model/+handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export default (async (app) => {
```ts
import { stream } from 'fetch-event-stream';
await stream('http://127.0.0.1:3000/api/sse/model', {
const events = await stream('http://127.0.0.1:3000/api/sse/model', {
method: 'POST',
body: JSON.stringify({ message: 'What is GenAI?' }),
});
JSON.parse(event.data as string)?.kwargs?.content;
for await (const event of events) {
JSON.parse(event.data as string)?.kwargs?.content;
}
```
*/
app.post('', async (request, reply) => {
Expand Down Expand Up @@ -117,9 +119,11 @@ export default (async (app) => {
```ts
import { stream } from 'fetch-event-stream';
await stream('http://127.0.0.1:3000/api/sse/model/query');
const events = await stream('http://127.0.0.1:3000/api/sse/model/query');
JSON.parse(event.data as string)?.answer || '';
for await (const event of events) {
JSON.parse(event.data as string)?.answer || '';
}
```
*/
app.get('/query', async (request, reply) => {
Expand Down

0 comments on commit 2f2376f

Please sign in to comment.