Skip to main content

Agente LLM com execução de funções, histórico persistente, suporte a arquivos e orquestração de múltiplos agentes.

Project description

🤖 Tyr Agent

PyPI version Python version License

TyrAgent é uma biblioteca para criação de agentes inteligentes com histórico, function-calling, suporte a arquivos e orquestração de múltiplos agentes. Ideal para aplicações com modelos generativos como Gemini, GPT e similares.

  • 💬 Conversas com ou sem streaming
  • 🧠 Memória persistente de interações (por agente)
  • ⚙️ Execução de múltiplas funções via JSON
  • 🧑🏻‍💼 Orquestração de múltiplos agentes com roteamento automático de mensagens
  • 🖼️ Interpretação de imagens base64
  • 🧩 Estrutura modular e extensível

📦 Instalação via PyPI

  pip install tyr-agent

🔒 Lembre-se de configurar sua variável GEMINI_KEY no .env


🧩 Estrutura do projeto

tyr_agent/
├── core/
│   ├── agent.py  # SimpleAgent, ComplexAgent e ManagerAgent
│   └── ai_config.py  # configure_gemini
├── storage/
│   └── interaction_history.py  # InteractionHistory
└── utils/
   └── image_utils.py  # image_to_base64

💡 Exemplos de uso

📘 Criando um agente simples

import asyncio
import google.generativeai as genai
from tyr_agent import SimpleAgent, configure_gemini

configure_gemini()
agent = SimpleAgent(
    prompt_build="Você é um assistente de clima.",
    agent_name="WeatherAgent",
    model=genai.GenerativeModel("gemini-2.5-flash-preview-04-17")
)
response = asyncio.run(agent.chat("Qual o clima em Salvador?"))

⚙️ Criando um agente com funções

import asyncio
import google.generativeai as genai
from tyr_agent import ComplexAgent, configure_gemini

def somar(a: float, b: float): return a + b

def pegar_clima(cidade: str): return f"Clima em {cidade}: Ensolarado 28°C"

configure_gemini()
agent = ComplexAgent(
    prompt_build="Você pode fazer cálculos e responder sobre o clima.",
    agent_name="WeatherSumBot",
    model=genai.GenerativeModel("gemini-2.5-flash-preview-04-17"),
    functions={"somar": somar, "pegar_clima": pegar_clima}
)

response = asyncio.run(agent.chat("Me diga quanto é 10+5 e o clima de São Paulo"))

🧑🏻‍💼 Criando um orquestrador de agentes

import asyncio
import google.generativeai as genai
from tyr_agent import ManagerAgent, ComplexAgent, SimpleAgent, configure_gemini

configure_gemini()
model = genai.GenerativeModel("gemini-2.5-flash-preview-04-17")

weather_agent = SimpleAgent(
    prompt_build="Você é um assistente de clima.",
    agent_name="WeatherAgent",
    model=model
)

def somar(a: float, b: float): return a + b

def subtrair(a: float, b: float): return a - b

math_agent = ComplexAgent(
    prompt_build="Você pode fazer cálculos matemáticos.",
    agent_name="MathAgent",
    model=model,
    functions={"somar": somar, "subtrair": subtrair}
)

configure_gemini()
manager_agent = ManagerAgent(
    prompt_build="",
    agent_name="ManagerAgent",
    model=model,
    agents={"weather": weather_agent, "math": math_agent},
)

response = asyncio.run(manager_agent.chat("Me diga clima de São Paulo e quanto é 10+5"))

🧠 Principais recursos

  • SimpleAgent: Conversa com contexto e histórico;
  • ComplexAgent: Pode sugerir funções a serem chamadas, receber resultados e finalizar a resposta;
  • ManagerAgent: Orquestra múltiplos agentes e delega tarefas automaticamente;
  • InteractionHistory: Armazena histórico individual de cada agente em JSON;
  • Suporte a arquivos base64 e imagens;
  • Modular para expansão com novas capacidades (benchmark, visão, execução, etc.).

📄 Licença

Este repositório está licenciado sob os termos da MIT License.


📬 Contato

Criado por Witor Oliveira
🔗 LinkedIn
📫 Contato por e-mail

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tyr_agent-0.0.3.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tyr_agent-0.0.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file tyr_agent-0.0.3.tar.gz.

File metadata

  • Download URL: tyr_agent-0.0.3.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for tyr_agent-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b92b3b63d382e0f10d03868273b305c9a5645b02d6198e94da6d854d52593bee
MD5 d14847c19cbd1e6fccaa8896a9f7bbbb
BLAKE2b-256 0f1e83a5f9de54b02f0f33d3d3be5c5c51c69ef37ceab7ee478db8025e88ade5

See more details on using hashes here.

File details

Details for the file tyr_agent-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tyr_agent-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for tyr_agent-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 63573a12ee534eef78911820d2f630e61e95769b239e321d47c1041e101544c6
MD5 ba6a7478c24253d55aaf89ccbda379d9
BLAKE2b-256 1ede9cc308a0a2b433dd6c2175742b91d97c8f31113472e9c874aaf1cb5293d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page