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"),
    use_history=True  # É um parâmetro opicional e pode ser True ou False.
)

# O parâmetro "save_history" também é opicional e pode ser True ou False.
response = asyncio.run(agent.chat("Qual o clima em Salvador?", save_history=True))

⚙️ 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},
    use_history=False  # É um parâmetro opicional e pode ser True ou False.
)

# O parâmetro "save_history" também é opicional e pode ser True ou False.
response = asyncio.run(agent.chat("Me diga quanto é 10+5 e o clima de São Paulo", save_history=False))

🧑🏻‍💼 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(
    agent_name="ManagerAgent",
    model=model,
    agents={"weather": weather_agent, "math": math_agent},
    use_history=True  # É um parâmetro opicional e pode ser True ou False.
)

# O parâmetro "save_history" também é opicional e pode ser True ou False.
response = asyncio.run(manager_agent.chat("Me diga clima de São Paulo e quanto é 10+5", save_history=False))

🧠 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.5.tar.gz (13.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.5-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tyr_agent-0.0.5.tar.gz
  • Upload date:
  • Size: 13.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.5.tar.gz
Algorithm Hash digest
SHA256 fade5c70ee499fa309e32ea93c94faaa61d336877d19886d3401f4f5b6189006
MD5 b5d71e01bccbda01d614c416d939d85c
BLAKE2b-256 d41e936811b4d3b12143190122ceaa2cdb2baecc87687f3fd568f704cc15d49a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tyr_agent-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 13.6 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7cada3c4902ca433e9512bbd661f352200fd72f9630cf5e26542ac8f8b1efd9d
MD5 0523d753296b1cdfc253cdb6896dcb5e
BLAKE2b-256 8190409a282290c75414b12712c49a156b6917f321564670d0f9c45276452e4e

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