Files
task-6a1865008a94f887e50d471c/README.md
T
2026-05-28 18:08:55 +00:00

39 lines
1.6 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 Pydantic
## What this project does
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 `PydanticOutputParser` and the schemas format instructions.
## File structure
- `models.py` Pydantic models with field descriptions.
- `agent.py` Extraction logic: schema detection, prompt construction, LLM invocation.
- `main.py` CLI demonstrating three example inputs.
- `requirements.txt` Runtime dependencies.
- `README.md` Project description (this file).
## Installation
```bash
pip install -r requirements.txt
```
Make sure the environment variable **JOURNAL_MCP_PAT** is set to your BroJS API key.
## Usage examples
Run the script and follow the prompts:
```bash
python main.py
```
You will see three predefined inputs (person, meeting, custom) and the parsed JSON output.
## How it works
1. **Schema detection** a simple regex checks for words like *meeting* or *date* to choose between `PersonInfo` and `MeetingNotes`.
2. **Prompt** the same template is used; format instructions are injected from the chosen parser.
3. **LLM call** one request to BroJS GPTOSS20B.
4. **Parsing** `PydanticOutputParser.parse()` validates and returns a Pydantic instance.
## Extending
Add more schemas by creating new Pydantic models in `models.py` and extending `_detect_schema`. The rest of the pipeline remains unchanged.