Build your first Upsonic Agent

Let’s create a simple agent that expert on our company and roled as Product Manager.

Before we proceed, make sure you have Upsonic installed. If you haven’t installed them yet, you can do so by following the installation guide.

Follow the steps below to get your sonics! 🦔

1

Providing OpenAI Api Key

Upsonic supports multiple LLMs. In this example, we will use OpenAI’s GPT-4 model, for which we need to set environment variables.

2

Generate your First Task

The task-centric structure important to create an programatic design in Agent systems. In Upsonic you can generate an task oriented structure with task description, tools, context, knowledge bases and etc. In this example we will give Search tools to our task. The agent will use the Search tool at the run time.

from upsonic import Task, Agent
from upsonic.client.tools import Search

task = Task(
  "Research latest news in Anthropic and OpenAI", 
  tools=[Search]
)
3

Generate an Expert Agent of Our Company

Upsonic have an automatic characterization mechanism. Its important to create agents that belongs on your purpose. In this example we will generate an Product Manager.

agent = Agent("Product Manager")
4

Running the Task on Agent

# Running the task
agent.print_do(task)

Connect Any MCP

Upsonic framework, support to start and connect any MCP server for your purposes. Model Context Protocol servers are varously and maintain by companies and community. Upsonic support all MCP servers.

At this step you need to use @client.mcp() decorator to an class with command, args and env.

# Hackernews MCP Server
class HackerNewsMCP:
    command = "uvx"
    args = ["mcp-hn"]
    # env = {"": ""}
  

task1 = Task(
  "Research latest news in Anthropic and OpenAI", 
  tools=[HackerNewsMCP]
)