Files
2026-05-27 13:54:37 +00:00

37 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Task 69dd4221f309a98be0006b2e Structured Assignment Card
## What this project does
This repository contains a small Python package that turns an informal assignment description into a **structured data card**. The card is represented by a Pydantic model and can be used downstream in pipelines for filtering, storage or further processing.
The core logic lives in `models.py` (the data schema) and `agent.py` (the LangChain chain that calls the LLM). The entry point `main.py` demonstrates three different example inputs.
## File structure
- **requirements.txt** Python dependencies required to run the code.
- **README.md** this documentation file.
- **models.py** Pydantic model for the assignment card.
- **agent.py** LangChain chain that parses a raw text into the model.
- **main.py** example usage and simple CLI.
## Installation
```bash
pip install -r requirements.txt
```
Make sure you have an OpenAI compatible key set in `JOURNAL_MCP_PAT` environment variable (the BroJS endpoint).
## Usage examples
```python
from agent import parse_assignment
text = "Сдайте к пятнице мини-отчёт по LangChain: 2 страницы, упор на агентов. Оценка: за полноту и за пример кода."
card = parse_assignment(text)
print(card.model_dump())
```
## Architecture
1. **PromptTemplate** contains a short instruction and the format instructions from `PydanticOutputParser`.
2. **ChatOpenAI** calls BroJS LLM.
3. **PydanticOutputParser** validates that the model output matches the schema.
4. The chain is a simple *prompt → llm → parser* pipeline.
The code is intentionally straightforward to keep the focus on structured output generation.