From f9cccbebc9a798c9c9083047dec5fdd24be89658 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: Thu, 28 May 2026 16:37:26 +0000 Subject: [PATCH] =?UTF-8?q?=D1=81=D1=8B=D1=80=D0=BE=D0=B9=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=E2=86=92=20=D0=BF=D0=BB=D0=BE=D1=81=D0=BA=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=BA=D0=B0:=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1b7d93..1b5dfb0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,118 @@ -# task-69dd4221-syroy-tekst-zadaniya-plos +# Project: Raw Text → Flat Task Card -Решения домашних заданий \ No newline at end of file +## 📖 Overview + +This project turns a natural‑language description of an assignment into a **structured, machine‑readable card**. +Given a single sentence or short paragraph from a teacher (e.g., “Write a report on LangChain”), the script uses OpenAI via LangChain to produce a validated `TaskCard` object containing: + +| Field | Description | +|-------|-------------| +| `title` | Short title of the task | +| `subject` | Subject area (optional) | +| `deadline_hint` | Free‑form hint about when it’s due | +| `deliverable_type` | What to submit (report, code, presentation…) | +| `grading_hints` | List of grading criteria mentioned | + +The output is printed as JSON and a concise summary. + +--- + +## 🚀 Installation + +```bash +# Clone the repo (or copy the file) +git clone https://github.com/your‑repo/task‑card.git +cd task-card + +# Create virtual environment (optional but recommended) +python -m venv .venv +source .venv/bin/activate # Windows: .venv\\Scripts\\activate + +# Install dependencies +pip install langchain-core langchain-openai pydantic python-dotenv +``` + +> **Environment variables** +> The script uses `OPENAI_API_KEY`. Create a `.env` file in the project root: + +```dotenv +OPENAI_API_KEY=sk-... +``` + +or export it directly: + +```bash +export OPENAI_API_KEY="sk-..." +``` + +--- + +## 📦 Usage + +The main entry point is `solution.py`. + +### 1. Run with an inline string + +```bash +python solution.py "Write a short report on LangChain and its applications." +``` + +**Output** + +```json +{ + "title": "Short Report on LangChain", + "subject": null, + "deadline_hint": "Submit by the end of the week.", + "deliverable_type": "report", + "grading_hints": [ + "Clarity of explanation", + "Depth of examples" + ] +} +``` + +### 2. Run with a file + +Create `task.txt` containing your assignment description: + +```text +Develop a Python script that uses LangChain to parse user input and produce a structured task card. +``` + +Run: + +```bash +python solution.py -f task.txt +``` + +The same JSON will be printed. + +### 3. Using the output programmatically + +You can import `TaskCard` from `solution.py` in another Python script: + +```python +from solution import TaskCard, parse_task_description + +description = "Create a presentation on AI ethics." +card: TaskCard = parse_task_description(description) +print(card.title) # -> "Presentation on AI Ethics" +``` + +--- + +## 🛠️ How It Works + +1. **Prompt** – A `PromptTemplate` instructs the model to output JSON matching the `TaskCard` schema. +2. **LLM** – `ChatOpenAI` (any OpenAI-compatible model) processes the prompt. +3. **Parser** – `PydanticOutputParser` validates and converts the raw text into a `TaskCard`. +4. **Result** – The script prints the JSON representation and a short human‑readable summary. + +--- + +## 📄 License + +MIT © 2026 + +--- \ No newline at end of file