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 múltiplos tipos de arquivo
  • 🧩 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


💡 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 múltiplos tipos de arquivo via path, base64 ou BytesIO;
  • 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.4.tar.gz (12.3 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.4-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tyr_agent-0.0.4.tar.gz
  • Upload date:
  • Size: 12.3 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.4.tar.gz
Algorithm Hash digest
SHA256 38f5d088956b8f69e1ff9426c63396809d8b028ed9889d0ea1afaee60f895b5b
MD5 6c3109d92d288fdb9808b8e0e280e095
BLAKE2b-256 0ec72bbee2750f1e968050c1fd275b63ed349b3a5355f4c5529393ce4b287318

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tyr_agent-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 26208a3a9055a4f66bcc629b8355551b584302c4db98248e7a454795c4c63eb5
MD5 d2a16b9bb95a297eb0494162d3573b50
BLAKE2b-256 32df91922cda4ccd6944379af2e03076ca0f0d4b9ffd6eced61e051961d92fce

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