From 168e892a6a6eb9807f97eb5a15c33780749211b7 Mon Sep 17 00:00:00 2001 From: balabanovan530 <175+balabanovan530@noreply.localhost> Date: Tue, 2 Jun 2026 14:51:58 +0000 Subject: [PATCH] Add README.md --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..14db6a6 --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# LangGraph CLI Agent + +## Overview +This repository contains a simple command‑line agent built with **LangGraph** and **LangChain OpenAI**. The agent: + +1. **Plans** a user‑supplied task into 3‑6 discrete steps. +2. **Executes** each step sequentially, collecting results. +3. **Summarises** the outcome after all steps are finished. + +The agent runs locally and can use either an OpenAI API key or a local Ollama model. + +## Installation +```bash +# Create a virtual environment (recommended) +python -m venv venv +source venv/bin/activate # On Windows use `venv\Scripts\activate` + +# Install dependencies +pip install -r requirements.txt +``` + +The `requirements.txt` file contains: +```text +langgraph>=1.0.0 +langchain-openai>=0.2.0 +langchain-ollama>=0.1.0 +``` + +## Configuration +The agent automatically chooses an LLM provider: + +| Environment Variable | Meaning | Default | +|----------------------|---------|---------| +| `OPENAI_API_KEY` | OpenAI API key | *None* | +| `CHAT_MODEL` | Model name for local Ollama | `llama3` | +| `OLLAMA_BASE_URL` | Base URL for local Ollama | `http://localhost:11434/v1` | + +If `OPENAI_API_KEY` is set, the agent uses the OpenAI endpoint. Otherwise it falls back to the local Ollama model. + +## Usage +```bash +python agent.py "Compare Python and JavaScript" +``` + +Typical output: +``` +===== PLAN ===== +1. Compare the syntax of Python and JavaScript. +2. Discuss performance considerations. +3. Evaluate ecosystem support. +4. Summarise key differences. + +===== RESULTS ===== +[Step 1] Python uses indentation for blocks, whereas JavaScript uses braces. +[Step 2] JavaScript is generally faster in the browser, but Python excels in data science. +[Step 3] Python has a richer scientific stack; JavaScript dominates web development. +[Step 4] Python is best for backend and data work; JavaScript is essential for frontend. + +===== SUMMARY ===== +Python offers strong support for scientific computing and backend tasks, while JavaScript remains the de‑facto language for web development. Both languages have robust ecosystems, but their strengths differ. +``` + +## Development +- **Graph**: The graph is defined in `agent.py` using `StateGraph`. The state is a `TypedDict` named `PlanningState`. +- **Error handling**: All LLM calls are wrapped in try/except blocks. Parsing errors raise descriptive exceptions. +- **Testing**: The project includes minimal unit tests for plan parsing and integration tests that run the graph on a sample task. + +Feel free to extend the graph with more sophisticated nodes or to plug in different LLMs.