From a5b32d91fc9e166c83f3bd9adbf9e8151b7d40c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 24 May 2026 20:10:14 +0000 Subject: [PATCH] Add README --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0adc5df --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Stream‑режим AI‑агента + +This repository contains a minimal implementation of an **AI agent that streams responses** from OpenAI's ChatCompletion API. + +## Features + +* **Streaming** – receive model output token‑by‑token instead of waiting for the full response. +* **Simple API** – expose a single `stream_chat` generator that yields text fragments. +* **Example script** – quick demo showing how to use the streaming agent. + +## Getting Started + +1. **Clone the repository** + ```bash + git clone https://git.brojs.ru/RK-A/stream-ai-agent-task6.git + cd stream-ai-agent-task6 + ``` + +2. **Create a virtual environment** (optional but recommended) + ```bash + python -m venv venv + source venv/bin/activate # On Windows: venv\Scripts\activate + ``` + +3. **Install dependencies** + ```bash + pip install -r requirements.txt + ``` + +4. **Set your OpenAI API key** + ```bash + export OPENAI_API_KEY=sk-... + ``` + +5. **Run the demo** + ```bash + python main.py + ``` + +The demo will stream a short poem about the sea. + +## Usage in Your Own Code + +```python +from agent_stream import stream_chat + +messages = [ + {"role": "user", "content": "Tell me a joke."} +] + +for token in stream_chat(messages): + print(token, end='', flush=True) +``` + +## License +MIT © 2026 \ No newline at end of file