Files
ekzamen-planiruyuschiy-agent/README.md
T

2.0 KiB
Raw Blame History

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 freeform 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):

    git clone https://github.com/your-username/assignment-card-extractor.git
    cd assignment-card-extractor
    
  2. Create a virtual environment (recommended):

    python -m venv .venv
    source .venv/bin/activate   # On Windows: .venv\Scripts\activate
    
  3. Install dependencies:

    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.
    OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX
    

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.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