Skip to content

Commit

Permalink
post: SSE
Browse files Browse the repository at this point in the history
  • Loading branch information
p208p2002 committed May 6, 2024
1 parent 2d0eac1 commit c80bd8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions public/docs/server-sent-events/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<document-info>
- tags: #SSE#text-streaming
- date: YYYY/MM/dd
- date: 2024/05/06
</document-info>

Streaming text is a popular feature in chatting with AI systems just as ChatGPT does.
Expand All @@ -14,8 +14,8 @@ The technology behind is Server-Sent Events, which creates a long-lived connecti
It's very simple to implement in Python and JavaScript. The minimal example below creates an SSE server using FastAPI, and a client for sending requests in JS.

### Minimal SSE Example
#### Server (FastAPI)
## Minimal SSE Example
### Server (FastAPI)
```python
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
Expand All @@ -35,7 +35,7 @@ def text_completions():
return StreamingResponse(text_streamer())
```

#### Client (Vanilla JS)
### Client (Vanilla JS)
```javascript
fetch("http://127.0.0.1:8000/text-completions",{
method:'POST'
Expand Down
4 changes: 4 additions & 0 deletions src/tailwindcss.css
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ video {
padding: 0.25rem;
}

.p-2 {
padding: 0.5rem;
}

.pb-3 {
padding-bottom: 0.75rem;
}
Expand Down

0 comments on commit c80bd8b

Please sign in to comment.