Files
povtornyy-ekzamen-graf-s-re…/README.md
T

80 lines
2.0 KiB
Markdown

# Graph Reflection and Refinement Demo
This repository demonstrates how to integrate **LangChain LLMs** (OpenAI or Ollama) into a simple Python script that explains graph theory concepts. The project is intentionally minimal to focus on the LLM integration.
## Features
- **OpenAI LLM** support via `langchain-openai`.
- **Ollama LLM** support via `langchain-ollama`.
- Environment variable configuration using `.env` or system variables.
- Simple prompt chain that explains graph reflection and refinement.
## Setup
1. **Clone the repository**
```bash
git clone https://git.brojs.ru/kuzakhmetovartur/povtornyy-ekzamen-graf-s-refleksiey-i-do
cd povtornyy-ekzamen-graf-s-refleksiey-i-do
```
2. **Create a virtual environment (recommended)**
```bash
python3 -m venv .venv
source .venv/bin/activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Configure environment variables**
Create a `.env` file in the project root (or set system variables) with one of the following:
```dotenv
# For OpenAI
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-3.5-turbo
OPENAI_TEMPERATURE=0.7
# OR for Ollama
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=llama2
OLLAMA_TEMPERATURE=0.7
```
Only one of the two configurations is required.
## Usage
Run the script:
```bash
python src/main.py
```
You should see an LLM-generated explanation of graph reflection and refinement printed to the console.
## Project Structure
```
povtornyy-ekzamen-graf-s-refleksiey-i-do/
├── src/
│ └── main.py # Core script with LangChain integration
├── requirements.txt # All required Python packages
└── README.md # Project documentation
```
## Notes
- The script automatically selects the LLM based on the presence of environment variables.
- If neither `OPENAI_API_KEY` nor `OLLAMA_HOST` is set, the script will raise an error.
- Feel free to extend the prompt or chain logic to suit more complex use cases.
---
Happy coding!