feat: añadir agente meteorologo con tool get_weather
Nuevo agente Matrix especializado en consultas meteorológicas. Usa la API pública Open-Meteo (sin API key) para obtener condiciones actuales y previsión de 3 días para cualquier ciudad. Incluye: - agents/meteorologo/ — reglas puras, config.yaml, system prompt - tools/weather.go — tool get_weather (geocoding + forecast) - Registro en runtime.go (tool registry) y launcher (rulesRegistry) El agente responde a DMs y menciones delegando al LLM con tool_use habilitado. No tiene comandos directos (!xxx). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Package meteorologo defines the pure rules for the meteorologo bot.
|
||||
// This agent uses tool_use (get_weather) to provide weather information.
|
||||
package meteorologo
|
||||
|
||||
import (
|
||||
"github.com/enmanuel/agents/pkg/decision"
|
||||
)
|
||||
|
||||
// Rules returns the decision rules for the meteorologo bot.
|
||||
func Rules() []decision.Rule {
|
||||
return []decision.Rule{
|
||||
// Any DM or mention → LLM (with tool-use enabled)
|
||||
{
|
||||
Name: "llm-all",
|
||||
Match: func(ctx decision.MessageContext) bool {
|
||||
return ctx.IsDirectMsg || ctx.IsMention
|
||||
},
|
||||
Actions: []decision.Action{{
|
||||
Kind: decision.ActionKindLLM,
|
||||
LLM: &decision.LLMAction{},
|
||||
}},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
# ============================================
|
||||
# IDENTIDAD
|
||||
# ============================================
|
||||
agent:
|
||||
id: meteorologo
|
||||
name: "Meteorologo"
|
||||
version: "1.0.0"
|
||||
enabled: true
|
||||
description: "Meteorologo experto. Consulta el tiempo actual y prevision para cualquier ciudad del mundo."
|
||||
tags: [weather, llm, tools]
|
||||
|
||||
# ============================================
|
||||
# PERSONALIDAD Y COMPORTAMIENTO
|
||||
# ============================================
|
||||
personality:
|
||||
tone: friendly
|
||||
verbosity: concise
|
||||
language: es
|
||||
languages_supported: [es, en]
|
||||
emoji_style: minimal
|
||||
prefix: ""
|
||||
error_style: helpful
|
||||
|
||||
templates:
|
||||
greeting: "Hola, soy el Meteorologo. Preguntame por el tiempo en cualquier ciudad."
|
||||
unknown_command: "No entiendo ese comando. Preguntame directamente por el tiempo de una ciudad."
|
||||
permission_denied: "No tengo permiso para hacer eso."
|
||||
error: "Algo salio mal: {{.Error}}"
|
||||
success: "{{.Summary}}"
|
||||
busy: "Consultando datos meteorologicos, un momento..."
|
||||
|
||||
behavior:
|
||||
proactive: false
|
||||
ask_confirmation: false
|
||||
show_reasoning: false
|
||||
thread_replies: true
|
||||
typing_indicator: true
|
||||
acknowledge_receipt: false
|
||||
|
||||
# ============================================
|
||||
# LLM — CONEXION Y RAZONAMIENTO
|
||||
# ============================================
|
||||
llm:
|
||||
primary:
|
||||
provider: openai
|
||||
model: gpt-4o
|
||||
api_key_env: OPENAI_API_KEY
|
||||
base_url: ""
|
||||
max_tokens: 4096
|
||||
temperature: 0.7
|
||||
|
||||
fallback:
|
||||
provider: ""
|
||||
model: ""
|
||||
api_key_env: ""
|
||||
base_url: ""
|
||||
max_tokens: 0
|
||||
temperature: 0
|
||||
|
||||
reasoning:
|
||||
system_prompt_file: "prompts/system.md"
|
||||
context_window: 16384
|
||||
memory_messages: 30
|
||||
|
||||
tool_use:
|
||||
enabled: true
|
||||
max_iterations: 5
|
||||
parallel_calls: false
|
||||
|
||||
rate_limit:
|
||||
requests_per_minute: 60
|
||||
tokens_per_minute: 200000
|
||||
concurrent_requests: 5
|
||||
|
||||
# ============================================
|
||||
# TOOLS — get_weather habilitada
|
||||
# ============================================
|
||||
tools:
|
||||
ssh:
|
||||
enabled: false
|
||||
allowed_targets: []
|
||||
forbidden_commands: []
|
||||
timeout: 0s
|
||||
max_concurrent: 0
|
||||
require_confirmation: []
|
||||
|
||||
http:
|
||||
enabled: false
|
||||
allowed_domains: []
|
||||
timeout: 0s
|
||||
max_retries: 0
|
||||
|
||||
scripts:
|
||||
enabled: false
|
||||
scripts_dir: ""
|
||||
allowed: []
|
||||
timeout: 0s
|
||||
sandbox: false
|
||||
|
||||
file_ops:
|
||||
enabled: false
|
||||
allowed_paths: []
|
||||
read_only: true
|
||||
|
||||
mcp:
|
||||
enabled: false
|
||||
servers: []
|
||||
expose:
|
||||
port: 0
|
||||
tools: []
|
||||
|
||||
memory:
|
||||
enabled: true
|
||||
|
||||
knowledge:
|
||||
enabled: false
|
||||
|
||||
# ============================================
|
||||
# MEMORIA
|
||||
# ============================================
|
||||
memory:
|
||||
enabled: true
|
||||
window_size: 20
|
||||
|
||||
# ============================================
|
||||
# MATRIX — CONEXION Y ROOMS
|
||||
# ============================================
|
||||
matrix:
|
||||
homeserver: "https://matrix-af2f3d.organic-machine.com"
|
||||
user_id: "@meteorologo:matrix-af2f3d.organic-machine.com"
|
||||
access_token_env: MATRIX_TOKEN_METEOROLOGO
|
||||
device_id: "YNXDWAVGMW"
|
||||
|
||||
encryption:
|
||||
enabled: true
|
||||
store_path: "./agents/meteorologo/data/crypto/"
|
||||
pickle_key_env: PICKLE_KEY_METEOROLOGO
|
||||
trust_mode: tofu
|
||||
recovery_key_env: SSSS_RECOVERY_KEY_METEOROLOGO
|
||||
|
||||
rooms:
|
||||
listen: []
|
||||
respond: []
|
||||
admin: []
|
||||
|
||||
filters:
|
||||
command_prefix: "!"
|
||||
mention_respond: true
|
||||
dm_respond: true
|
||||
ignore_bots: true
|
||||
ignore_users: []
|
||||
min_power_level: 0
|
||||
|
||||
# ============================================
|
||||
# COMUNICACION INTER-AGENTES
|
||||
# ============================================
|
||||
agents:
|
||||
peers:
|
||||
- id: assistant-bot
|
||||
capabilities: [general, llm]
|
||||
room: ""
|
||||
|
||||
delegation:
|
||||
enabled: false
|
||||
can_delegate_to: []
|
||||
can_receive_from: [assistant-bot]
|
||||
max_delegation_depth: 1
|
||||
timeout: 30s
|
||||
|
||||
protocol:
|
||||
format: json
|
||||
channel: matrix
|
||||
heartbeat_interval: 60s
|
||||
|
||||
# ============================================
|
||||
# SSH — no aplica
|
||||
# ============================================
|
||||
ssh:
|
||||
defaults:
|
||||
user: ""
|
||||
port: 22
|
||||
key_file_env: ""
|
||||
known_hosts: ""
|
||||
keepalive_interval: 0s
|
||||
timeout: 0s
|
||||
targets: {}
|
||||
|
||||
# ============================================
|
||||
# PERMISOS Y SEGURIDAD
|
||||
# ============================================
|
||||
security:
|
||||
roles:
|
||||
admin:
|
||||
users: ["@admin:matrix-af2f3d.organic-machine.com"]
|
||||
actions: ["*"]
|
||||
user:
|
||||
users: ["*"]
|
||||
actions: ["ask", "help", "weather"]
|
||||
|
||||
audit:
|
||||
enabled: false
|
||||
log_file: "./agents/meteorologo/data/audit.log"
|
||||
log_to_room: ""
|
||||
include: []
|
||||
|
||||
secrets:
|
||||
provider: env
|
||||
|
||||
# ============================================
|
||||
# SCHEDULING
|
||||
# ============================================
|
||||
schedules: []
|
||||
|
||||
# ============================================
|
||||
# OBSERVABILIDAD
|
||||
# ============================================
|
||||
observability:
|
||||
logging:
|
||||
level: info
|
||||
format: json
|
||||
output: stdout
|
||||
file: "./agents/meteorologo/data/meteorologo.log"
|
||||
|
||||
metrics:
|
||||
enabled: false
|
||||
port: 9093
|
||||
path: /metrics
|
||||
export: prometheus
|
||||
|
||||
health:
|
||||
enabled: true
|
||||
port: 8083
|
||||
path: /healthz
|
||||
|
||||
tracing:
|
||||
enabled: false
|
||||
provider: ""
|
||||
endpoint: ""
|
||||
|
||||
# ============================================
|
||||
# RESILIENCIA
|
||||
# ============================================
|
||||
resilience:
|
||||
circuit_breaker:
|
||||
failure_threshold: 5
|
||||
timeout: 30s
|
||||
half_open_max: 2
|
||||
|
||||
retry:
|
||||
max_attempts: 2
|
||||
backoff: exponential
|
||||
initial_delay: 1s
|
||||
max_delay: 10s
|
||||
|
||||
shutdown:
|
||||
timeout: 10s
|
||||
drain_messages: true
|
||||
save_state: false
|
||||
state_file: ""
|
||||
|
||||
queue:
|
||||
enabled: true
|
||||
max_size: 100
|
||||
priority_users: ["@admin:matrix-af2f3d.organic-machine.com"]
|
||||
|
||||
# ============================================
|
||||
# ALMACENAMIENTO Y ESTADO
|
||||
# ============================================
|
||||
storage:
|
||||
state:
|
||||
backend: sqlite
|
||||
path: "./agents/meteorologo/data/meteorologo.db"
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
backend: memory
|
||||
ttl: 5m
|
||||
max_entries: 200
|
||||
|
||||
history:
|
||||
backend: sqlite
|
||||
path: "./agents/meteorologo/data/history.db"
|
||||
retention: 168h
|
||||
@@ -0,0 +1,30 @@
|
||||
# Meteorologo — System Prompt
|
||||
|
||||
Eres un meteorologo experto que opera como bot en Matrix. Tu especialidad es proporcionar informacion meteorologica precisa y util.
|
||||
|
||||
## Identidad
|
||||
- Nombre: Meteorologo
|
||||
- Rol: Experto en meteorologia y clima
|
||||
- Personalidad: Profesional pero cercano, con pasion por el tiempo atmosferico
|
||||
|
||||
## Capacidades
|
||||
- Consultar el tiempo actual de cualquier ciudad del mundo usando la herramienta `get_weather`
|
||||
- Proporcionar previsiones de hasta 3 dias
|
||||
- Explicar fenomenos meteorologicos
|
||||
- Dar recomendaciones basadas en el tiempo (ropa, actividades, precauciones)
|
||||
|
||||
## Herramientas disponibles
|
||||
- `get_weather`: Obtiene el tiempo actual y prevision de 3 dias para una ciudad. Parametro: `city` (nombre de la ciudad). Usala SIEMPRE que te pregunten por el tiempo de una ciudad.
|
||||
|
||||
## Estilo de respuesta
|
||||
- Responde siempre en el idioma del usuario
|
||||
- Usa formato claro con temperaturas, humedad, viento y condiciones
|
||||
- Anade recomendaciones practicas cuando sea relevante (ej: "Lleva paraguas", "Buen dia para pasear")
|
||||
- Si te preguntan por el tiempo sin especificar ciudad, pregunta que ciudad quieren consultar
|
||||
- Puedes explicar conceptos meteorologicos si te lo piden
|
||||
- Usa markdown para formatear (listas, negritas) cuando mejore la legibilidad
|
||||
|
||||
## Restricciones
|
||||
- No inventes datos meteorologicos: siempre usa la herramienta `get_weather`
|
||||
- Si la herramienta falla o no encuentra la ciudad, informalo al usuario
|
||||
- No respondas sobre temas que no tengan relacion con el tiempo o la meteorologia. Redirige amablemente al tema
|
||||
@@ -742,6 +742,10 @@ func buildToolRegistry(
|
||||
reg.Register(tools.NewCurrentTime())
|
||||
logger.Debug("registered current_time tool")
|
||||
|
||||
// weather tool is always available
|
||||
reg.Register(tools.NewWeather())
|
||||
logger.Debug("registered weather tool")
|
||||
|
||||
// matrix_send is always available
|
||||
reg.Register(tools.NewMatrixSend(matrixClient))
|
||||
logger.Debug("registered matrix tool")
|
||||
|
||||
Reference in New Issue
Block a user