Update README.md
This commit is contained in:
@@ -1,3 +1,26 @@
|
||||
# task-6a1d75e5fd30e81cf3126b1a
|
||||
# Structured Output with Discriminated Union
|
||||
|
||||
Повторный экзамен: Structured output — Union событий API
|
||||
This repository demonstrates how to parse raw API logs into typed events using **Pydantic v2** and **LangChain ≥1.0**. The solution showcases:
|
||||
|
||||
* A discriminated union of two event types (`HttpOkEvent` and `HttpErrorEvent`).
|
||||
* Structured output from an LLM via `ChatOpenAI.with_structured_output`.
|
||||
* Batch parsing of multiple log lines.
|
||||
* A simple CLI that prints the parsed events and a summary table.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Run with the default example log
|
||||
python -m src.main
|
||||
|
||||
# Or provide your own raw log string
|
||||
python -m src.main --log "GET /api/test 200 30ms\nPOST /api/submit 500 Internal Server Error"
|
||||
```
|
||||
|
||||
The script prints each parsed event as a dictionary and a tabular summary.
|
||||
Reference in New Issue
Block a user