a5b32d91fc9e166c83f3bd9adbf9e8151b7d40c4
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_chatgenerator that yields text fragments. - Example script – quick demo showing how to use the streaming agent.
Getting Started
-
Clone the repository
git clone https://git.brojs.ru/RK-A/stream-ai-agent-task6.git cd stream-ai-agent-task6 -
Create a virtual environment (optional but recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies
pip install -r requirements.txt -
Set your OpenAI API key
export OPENAI_API_KEY=sk-... -
Run the demo
python main.py
The demo will stream a short poem about the sea.
Usage in Your Own Code
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
Description
Languages
Python
100%