From cf225e1325a5261556c3427e9f50622801e4ac89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B8=D1=8F=20=D0=91=D0=B5=D1=80=D0=B4?= =?UTF-8?q?=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Wed, 27 May 2026 10:16:24 +0000 Subject: [PATCH] =?UTF-8?q?Delete=20directory=20'solutions/69a86305c46fd26?= =?UTF-8?q?feae6bcaa=5FHuman-in-the-Loop=5F=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=5Fmiddleware'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.md | 137 ------------------ .../requirements.txt | 1 - 2 files changed, 138 deletions(-) delete mode 100644 solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/README.md delete mode 100644 solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/requirements.txt diff --git a/solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/README.md b/solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/README.md deleted file mode 100644 index 3d8694e..0000000 --- a/solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/README.md +++ /dev/null @@ -1,137 +0,0 @@ -# Human‑in‑the‑Loop Middleware Demo -A minimal LangChain project that demonstrates how to pause an agent before every tool call and let a user approve or reject the action via the terminal. - ---- - -## Table of Contents -- [Project Overview](#project-overview) -- [Prerequisites](#prerequisites) -- [Installation](#installation) -- [Running the Demo](#running-the-demo) - - [1️⃣ `main.py` – Interactive Agent](#1-mainpy---interactive-agent) - - [2️⃣ `tool_example.py` – Custom Tool](#2-tool_exempley---custom-tool) -- [Example Interaction](#example-interaction) -- [Project Structure](#project-structure) - ---- - -## Project Overview -The agent is created with **HumanInTheLoopMiddleware**. -When the agent wants to use a tool (e.g., `get_weather`), it pauses, prints a prompt in the terminal, and waits for user input: - -| Decision | Effect | -|----------|--------| -| `approve` | Tool call proceeds | -| `reject` | Tool call is skipped; the agent continues reasoning | -| `edit` | (Optional) User can modify the tool arguments before resuming | - -The middleware automatically handles the pause/resume logic via `Command(resume={"decisions": [...]})`. - ---- - -## Prerequisites -- Python 3.10+ -- A working OpenAI API key (or any LLM provider supported by LangChain) - -Set your key in an environment variable: - -```bash -export OPENAI_API_KEY="sk-..." -``` - ---- - -## Installation - -1. **Clone the repo** - - ```bash - git clone https://github.com/yourusername/human-in-loop-demo.git - cd human-in-loop-demo - ``` - -2. **Create a virtual environment (optional but recommended)** - - ```bash - python -m venv .venv - source .venv/bin/activate # Windows: .venv\Scripts\activate - ``` - -3. **Install dependencies** - - ```bash - pip install -r requirements.txt - ``` - -> `requirements.txt` contains: -> ``` -> langchain==0.2.* -> langgraph==0.1.* -> python-dotenv # optional, for .env support -> ``` - ---- - -## Running the Demo - -### 1️⃣ `main.py` – Interactive Agent - -```bash -python main.py -``` - -You will see a prompt like: - -``` -Agent: What would you like to know? -User: Tell me the weather in London. -Agent: (pausing) Would you like to call tool 'get_weather' with arguments {'location': 'London'}? [approve/reject/edit] -> -``` - -Type `approve`, `reject`, or `edit` and press **Enter**. -If you choose `edit`, you’ll be prompted to modify the JSON arguments. - -### 2️⃣ `tool_example.py` – Custom Tool - -The demo includes a simple weather tool (`get_weather`). -You can add more tools by editing `tools/__init__.py` or creating new modules. - ---- - -## Example Interaction - -``` -$ python main.py -Agent: Hi! How can I help you today? -User: What's the weather in Paris? - -Agent: (pausing) Would you like to call tool 'get_weather' with arguments {'location': 'Paris'}? [approve/reject/edit] -> approve -Tool get_weather called. Result: "Sunny, 22°C" - -Agent: The current weather in Paris is Sunny, 22°C. -User: Thanks! -``` - -If you type `reject`, the agent will continue without calling the tool: - -``` -Agent: (pausing) Would you like to call tool 'get_weather' with arguments {'location': 'Paris'}? [approve/reject/edit] -> reject -Agent: I couldn't retrieve the weather. Could you provide more details? -``` - ---- - -## Project Structure - -``` -human-in-loop-demo/ -├── main.py # Entry point – runs the interactive agent -├── tool_example.py # Example custom tool (get_weather) -├── requirements.txt # Dependencies -└── README.md # This file -``` - -Feel free to extend the project by adding new tools, customizing prompts, or integrating a different LLM provider. Happy hacking! \ No newline at end of file diff --git a/solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/requirements.txt b/solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/requirements.txt deleted file mode 100644 index 5a23ccb..0000000 --- a/solutions/69a86305c46fd26feae6bcaa_Human-in-the-Loop_через_middleware/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -<|channel|>commentary to=repo_browser.print_tree code<|message|>{"path": "", "depth": 2} \ No newline at end of file