Skip to main content
This example demonstrates how to create and use an Upsonic Agent to research AI governance terms and provide structured educational content. The example showcases how to leverage Upsonic’s web search integration to gather authoritative information and generate comprehensive explanations with FAQs.

Overview

Upsonic framework provides seamless integration for AI agents with web search capabilities. This example showcases:
  1. Agent Integration — Using Upsonic Agent with specialized system prompts for educational content
  2. Web Research — Using DuckDuckGo for real-time AI governance term research
  3. Structured Output — Pydantic schemas for consistent, machine-readable responses
  4. Educational Content — Generating detailed explanations and FAQs for complex terms
  5. FastAPI Server — Running the agent as a production-ready API server
The agent acts as an AI Governance Lexicon Expert that:
  • Researches AI governance terms using web search
  • Provides comprehensive, accessible explanations
  • Generates relevant FAQs with detailed answers
  • Returns structured, validated output

Project Structure

Environment Variables

You can configure the model using environment variables:

Installation

Managing Dependencies

Sections: api, streamlit, development

Usage

Option 1: Run Directly

Runs the agent with default test inputs (Gap analysis for AI governance).

Option 2: Run as API Server

Server starts at http://localhost:8000. API documentation at /docs. Example API call:

How It Works

Example Output

Query:
Response:

Complete Implementation

main.py

agent.py

tools.py

schemas.py

upsonic_configs.json

Key Features

Agent Configuration

The agent is configured with a specialized system prompt that guides it to:
  • Research terms using web search tools
  • Provide comprehensive, accessible explanations
  • Generate relevant FAQs with detailed answers
  • Ensure accuracy through authoritative sources

Web Search Integration

Uses DuckDuckGo search tool to:
  • Find current definitions and frameworks
  • Gather best practices and real-world applications
  • Verify information from authoritative sources
  • Stay up-to-date with industry practices

Structured Output

Pydantic schemas ensure:
  • Consistent response format
  • Type validation
  • Machine-readable output
  • Clear documentation of expected structure

Educational Focus

The agent is designed to:
  • Explain complex terms in accessible language
  • Provide practical examples and applications
  • Generate relevant FAQs for learning
  • Cover both technical and non-technical aspects

Example Queries

  • “Gap analysis for AI governance”
  • “Model interpretability techniques”
  • “EU AI Act compliance requirements”
  • “AI safety frameworks”
  • “Algorithmic bias mitigation”

Repository

View the complete example: AI Governance Lexicon Agent