From f5594c25c530200d5cfea19ebb5ed58ebc5d4051 Mon Sep 17 00:00:00 2001 From: kuzakhmetovartur Date: Sun, 28 Jun 2026 12:46:52 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20solution=20for=20'=D0=AD=D0=BA=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D0=BD:=20=D0=A1=D0=B0=D0=BC=D0=BE=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=B8=D1=80=D1=83=D1=8E?= =?UTF-8?q?=D1=89=D0=B8=D0=B9=D1=81=D1=8F=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 102 +++++++++++++-------------------------------------- src/state.py | 9 +++++ src/tools.py | 12 ++++++ 3 files changed, 47 insertions(+), 76 deletions(-) create mode 100644 src/state.py create mode 100644 src/tools.py diff --git a/README.md b/README.md index 65d6849..41da028 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,34 @@ -# Assignment Card Extraction +# Экзамен: Самокорректирующийся агент -This project demonstrates how to convert a natural language assignment description into a structured data object using **LangChain** and **Pydantic**. +Главная +Мои задания +Экзамен: Самокорректирующийся агент +5Д +EN +Экзамен: Самокорректирующийся агент +Зачёт +Версия 1 +Дедлайн сдачи: 31.08.2026 -## Features +В работе -- Parses assignment details such as title, subject, deadline, deliverable type, and grading hints. -- Uses OpenAI's GPT model to interpret free‑form text. -- Validates the output with a Pydantic model to ensure type safety. +Редактирование ответа -## Prerequisites +Заполните ответ и отправьте работу на проверку преподавателю. -- Python 3.10 or newer -- An OpenAI API key +Тип ответа +Текст +Ссылка +Файлы +Текст ответа +Прикреплённые файлы +Загрузить файл +Отправить на проверку +Отменить -## Setup +Задание -1. **Clone the repository** (or copy the files into a directory): +Практическое задание: Самокорректирующийся агент +Цель - ```bash - git clone https://github.com/your-username/assignment-card-extractor.git - cd assignment-card-extractor - ``` - -2. **Create a virtual environment** (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. **Configure the OpenAI API key**: - - - Open the `.env` file. - - Replace `your_openai_api_key_here` with your actual key. - - ```dotenv - OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX - ``` - -## Running the Example - -```bash -python src/main.py -``` - -You should see output similar to: - -``` -=== Parsed Assignment Card === -{ - "title": "Мини-отчёт по LangChain", - "subject": "LangChain", - "deadline_hint": "к пятнице", - "deliverable_type": "отчёт", - "grading_hints": [ - "полнота", - "пример кода" - ] -} - -=== Human-readable Summary === -Title: Мини-отчёт по LangChain -Subject: LangChain -Deadline: к пятнице -Deliverable: отчёт -Grading Hints: полнота, пример кода -``` - -## Customization - -- **Change the LLM**: Edit `src/main.py` to use a different model or adjust temperature. -- **Add more fields**: Update the `AssignmentCard` model and the prompt template accordingly. -- **Use in a pipeline**: Import the `chain` object from `src/main.py` into your own application. - -## License - -MIT License \ No newline at end of file +Реализовать LangGraph-агента, который после выполнения задачи проверяет результат (LLM-as- \ No newline at end of file diff --git a/src/state.py b/src/state.py new file mode 100644 index 0000000..19f0b28 --- /dev/null +++ b/src/state.py @@ -0,0 +1,9 @@ +from typing import TypedDict, Optional + +class AgentState(TypedDict): + task: str + result: str + attempts: int + status: str # pending | success | failed | max_attempts + error: Optional[str] + max_attempts: int \ No newline at end of file diff --git a/src/tools.py b/src/tools.py new file mode 100644 index 0000000..e233377 --- /dev/null +++ b/src/tools.py @@ -0,0 +1,12 @@ +import random + +def unreliable_tool(task: str) -> str: + """ + Simulate a tool that fails 30% of the time. + """ + if random.random() < 0.3: + raise ValueError("Tool failed due to random error.") + # Simple implementation: if task contains arithmetic, compute it + if "2+2" in task: + return "4" + return "unknown" \ No newline at end of file