Skip to content

Latest commit

 

History

History
88 lines (65 loc) · 2.5 KB

quickstart.mdx

File metadata and controls

88 lines (65 loc) · 2.5 KB
title description icon
Quickstart
Build your first AI agent with Upsonic In under 2 Minute
rocket

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! 🦔

Upsonic supports multiple LLMs. In this example, we will use OpenAI's GPT-4 model, for which we need to set environment variables.
<CodeGroup>
  ```python Python
  import os

  os.environ["OPENAI_API_KEY"] = "sk-***"
  ```

  ```bash Mac
  export OPENAI_API_KEY=sk-***

  ```

  ```powershell Windows
  setx OPENAI_API_KEY sk-***
  ```
</CodeGroup>
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.
```python
from upsonic import Task, Agent
from upsonic.client.tools import Search

task = Task(
  "Research latest news in Anthropic and OpenAI", 
  tools=[Search]
)
```
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.
```python
agent = Agent("Product Manager")
```
```python # 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]
)