mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 15:01:15 +00:00
Open-source Agent OS built in Rust. - 14 crates, 1,767+ tests, zero clippy warnings - 7 autonomous Hands (Clip, Lead, Collector, Predictor, Researcher, Twitter, Browser) - 16 security systems (WASM sandbox, Merkle audit trail, taint tracking, Ed25519 signing, SSRF protection, secret zeroization, HMAC-SHA256 mutual auth, and more) - 30 pre-built agents across 4 performance tiers - 40 channel adapters (Telegram, Discord, Slack, WhatsApp, Teams, and 35 more) - 38 built-in tools + MCP client/server + A2A protocol - 26 LLM providers with intelligent routing and cost tracking - 60+ bundled skills with FangHub marketplace - Tauri 2.0 native desktop app - 140+ REST/WS/SSE API endpoints with Alpine.js dashboard - OpenAI-compatible /v1/chat/completions endpoint - One-command install, production-ready
34 lines
896 B
Python
34 lines
896 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Streaming example — stream agent responses token by token.
|
|
|
|
Usage:
|
|
python client_streaming.py
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
from openfang_client import OpenFang
|
|
|
|
client = OpenFang("http://localhost:3000")
|
|
|
|
# Create an agent
|
|
agent = client.agents.create(template="assistant")
|
|
print(f"Agent: {agent['id']}")
|
|
|
|
# Stream the response
|
|
print("\n--- Streaming response ---")
|
|
for event in client.agents.stream(agent["id"], "Tell me a short story about a robot."):
|
|
event_type = event.get("type", "")
|
|
if event_type == "text_delta" and event.get("delta"):
|
|
print(event["delta"], end="", flush=True)
|
|
elif event_type == "tool_call":
|
|
print(f"\n[Tool call: {event.get('tool')}]")
|
|
elif event_type == "done":
|
|
print("\n--- Done ---")
|
|
|
|
# Clean up
|
|
client.agents.delete(agent["id"])
|