7dd5a51872e653356136849dc83b16d6cd4f8385
3
@ ddd2bdb8a9
8-deep-agents-from-scratch
@ 380e236ecf
human-in-the-loop-interrupt-resume
@ 3c81f16ab4
human-in-the-loop-middleware
@ 082d5fb669
llm-interrupt
@ 67ab81df8f
mcp
@ 1fbb6def58
rag
@ a8a8111eca
Assignment Card Extraction
This project demonstrates how to convert a natural language assignment description into a structured data object using LangChain and Pydantic.
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
-
Clone the repository (or copy the files into a directory):
git clone https://github.com/your-username/assignment-card-extractor.git cd assignment-card-extractor -
Create a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Configure the OpenAI API key:
- Open the
.envfile. - Replace
your_openai_api_key_herewith your actual key.
OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX - Open the
Running the Example
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.pyto use a different model or adjust temperature. - Add more fields: Update the
AssignmentCardmodel and the prompt template accordingly. - Use in a pipeline: Import the
chainobject fromsrc/main.pyinto your own application.
License
MIT License
Description
Languages
TypeScript
39.9%
Python
32.5%
JavaScript
22.5%
CSS
5.1%