Some checks failed
CI / Check / macos-latest (push) Has been cancelled
CI / Check / ubuntu-latest (push) Has been cancelled
CI / Check / windows-latest (push) Has been cancelled
CI / Test / macos-latest (push) Has been cancelled
CI / Test / ubuntu-latest (push) Has been cancelled
CI / Test / windows-latest (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Security Audit (push) Has been cancelled
CI / Secrets Scan (push) Has been cancelled
CI / Install Script Smoke Test (push) Has been cancelled
21 lines
531 B
Python
21 lines
531 B
Python
#!/usr/bin/env python3
|
|
"""Example OpenFang agent: echoes back messages with a friendly greeting."""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Add parent directory to path for openfang_sdk import
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
from openfang_sdk import Agent
|
|
|
|
agent = Agent()
|
|
|
|
|
|
@agent.on_message
|
|
def handle(message: str, context: dict) -> str:
|
|
agent_id = context.get("agent_id", os.environ.get("OPENFANG_AGENT_ID", "unknown"))
|
|
return f"Hello from Python agent {agent_id}! You said: {message}"
|
|
|
|
|
|
agent.run()
|