Skip to main content
This example demonstrates how to build a simple Upsonic LLM agent that extracts all person names mentioned in a given text using structured output.

Overview

The agent takes a paragraph of text as input and returns a list of all people mentioned in it. This is useful for:
  • Named Entity Recognition (NER) — extracting people from articles, documents, or transcripts
  • Contact Discovery — identifying key individuals mentioned in meeting notes or emails
  • Data Extraction — parsing unstructured text for specific information
  • Content Analysis — understanding who is mentioned in text content
The agent uses a single LLM Task with a structured response format to ensure consistent output.

Key Features

  • Structured Output: Uses Pydantic models for type-safe responses
  • Comprehensive Extraction: Identifies all person names in text
  • Flexible Input: Works with any text content
  • Easy Integration: Simple API for text processing
  • Extensible: Can be adapted for other entity types

Code Structure

Response Model

Agent Setup

Task Definition

Complete Implementation

How It Works

  1. Input: The agent receives a paragraph of text containing mentions of various people
  2. Processing: The LLM analyzes the text and identifies all person names
  3. Output: Returns a structured PeopleResponse object with a list of names in the people field

Usage

Setup

Run the example

Example Output

Advanced Usage

Custom Text Processing

Batch Processing

Enhanced Entity Extraction

Use Cases

  • Meeting Notes: Extract attendees and mentioned people from meeting transcripts
  • News Analysis: Identify people mentioned in news articles
  • Social Media: Extract people from social media posts and comments
  • Legal Documents: Identify parties mentioned in legal texts
  • Academic Papers: Extract authors and cited researchers
  • Customer Support: Identify people mentioned in support tickets

File Structure

Performance Considerations

  • Text Length: Works best with paragraphs up to 2000 words
  • Name Variations: Handles nicknames, titles, and formal names
  • Context Awareness: Uses surrounding text to identify people
  • Accuracy: High accuracy for well-known names, may vary for uncommon names

Notes

  • Fully autonomous: The LLM performs all reasoning — no manual logic or regex
  • Minimal architecture: One Task, one prompt, one result
  • Extendable: Easily add new entity types or modify extraction logic
  • Use case: Ideal for content analysis, data extraction, and information processing

Repository

View the complete example: Extract People Example