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.2.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.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tyr_agent-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7e24ab022da615a22fe7cb57bd32ed595eace7176cdc6946e18516dee604d9d7
MD5 209fcde531198e59a56b430c14f68905
BLAKE2b-256 d58281e581de93fea56c9c9d0e97fc54cc0a70f936823f9b640d69e9c5c4ff8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tyr_agent-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f48be35ac1cc4105730871833a28fc58be25276d4b82bd222abcfad9733cf77a
MD5 875818648d38ea2ec3b3a257a577cee4
BLAKE2b-256 930cdc80619c67ad9707c63b353b49e3479d28716792453423d9f10a692105de

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