Add README
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user