Files
task-6a1865008a94f887e50d471c/README.md
T
2026-06-04 23:19:41 +00:00

49 lines
1.3 KiB
Markdown
Raw 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.
# Structured Output Extraction with LangChain & Pydantic
This repository demonstrates how to extract structured data from freeform text using **LangChain** and **Pydantic**. Two schemas are supported:
1. **PersonInfo** name, optional age, profession, skills.
2. **MeetingNotes** date, participants, topics, decisions, next steps.
The extraction is performed in a single LLM call with a prompt that includes the JSON schema. The result is parsed into a validated Pydantic model.
## Requirements
```text
langchain>=1.0.0
langchain-openai>=0.0.0
pydantic>=2.0.0
python-dotenv
```
Install with:
```bash
pip install -r requirements.txt
```
## Usage
```bash
# Person example
python main.py "Анна, 28 лет, Python-разработчик. Навыки: FastAPI, Docker."
# Meeting example
python main.py "Meeting on 2024-10-01. Participants: Alice, Bob. Topics: Budget, Timeline. Decisions: Increase budget. Next steps: Prepare report."
```
The script will automatically detect the type of text and output the parsed Pydantic model.
## Running from the CLI
You can also run the script interactively:
```bash
python main.py
Enter text (or press Ctrl-D to exit):
Анна, 28 лет, Python-разработчик. Навыки: FastAPI, Docker.
```
## License
MIT