From c80bd8b57519480884e039de7dd03eba3f251529 Mon Sep 17 00:00:00 2001 From: p208p2002 Date: Mon, 6 May 2024 14:20:41 +0800 Subject: [PATCH] post: SSE --- public/docs/server-sent-events/document.md | 8 ++++---- src/tailwindcss.css | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/docs/server-sent-events/document.md b/public/docs/server-sent-events/document.md index 6db6b42..6c2853e 100644 --- a/public/docs/server-sent-events/document.md +++ b/public/docs/server-sent-events/document.md @@ -2,7 +2,7 @@ - tags: #SSE#text-streaming -- date: YYYY/MM/dd +- date: 2024/05/06 Streaming text is a popular feature in chatting with AI systems just as ChatGPT does. @@ -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 @@ -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' diff --git a/src/tailwindcss.css b/src/tailwindcss.css index 06e17a5..81af1d3 100644 --- a/src/tailwindcss.css +++ b/src/tailwindcss.css @@ -676,6 +676,10 @@ video { padding: 0.25rem; } +.p-2 { + padding: 0.5rem; +} + .pb-3 { padding-bottom: 0.75rem; }