mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
73 lines
2.3 KiB
Python
73 lines
2.3 KiB
Python
"""Simplified Documentation chatbot with parallel retrieval and self-aware synthesis."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
from hanzo_agents import AIConfig, Agent
|
|
from hanzo_agents.logger import log_info
|
|
|
|
if __package__ in (None, ""):
|
|
current_dir = Path(__file__).resolve().parent
|
|
if str(current_dir) not in sys.path:
|
|
sys.path.insert(0, str(current_dir))
|
|
|
|
from embedding import embed_texts
|
|
from routers import (
|
|
ingestion_router,
|
|
qa_router,
|
|
query_router,
|
|
retrieval_router,
|
|
)
|
|
|
|
app = Agent(
|
|
node_id="documentation-chatbot",
|
|
hanzo_agents_server=f"{os.getenv('HANZO_AGENTS_SERVER')}",
|
|
api_key=os.getenv("HANZO_AGENTS_API_KEY"),
|
|
ai_config=AIConfig(
|
|
model=os.getenv("AI_MODEL", "openrouter/openai/gpt-4o-mini"),
|
|
),
|
|
)
|
|
|
|
for router in (
|
|
query_router,
|
|
ingestion_router,
|
|
retrieval_router,
|
|
qa_router,
|
|
):
|
|
app.include_router(router)
|
|
|
|
|
|
def _warmup_embeddings() -> None:
|
|
"""Warm up the embedding model on startup."""
|
|
try:
|
|
embed_texts(["doc-chatbot warmup"])
|
|
log_info("FastEmbed model warmed up for documentation chatbot")
|
|
except Exception as exc: # pragma: no cover - best-effort
|
|
log_info(f"FastEmbed warmup failed: {exc}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
_warmup_embeddings()
|
|
|
|
print("📚 Simplified Documentation Chatbot Agent")
|
|
print("🧠 Node ID: documentation-chatbot")
|
|
print(f"🌐 Control Plane: {app.hanzo_agents_server}")
|
|
print("\n🎯 Architecture: 3-Agent Parallel System + Document-Level Retrieval")
|
|
print(" 1. Query Planner → Generates diverse search queries")
|
|
print(" 2. Parallel Retrievers → Concurrent vector search")
|
|
print(" 3. Self-Aware Synthesizer → Answer + confidence assessment")
|
|
print("\n✨ Features:")
|
|
print(" - Parallel retrieval for 3x speed improvement")
|
|
print(" - Self-aware synthesis (no separate review)")
|
|
print(" - Max 1 refinement iteration (prevents loops)")
|
|
print(" - Document-level context (full pages vs isolated chunks)")
|
|
print(" - Smart document ranking (frequency + relevance scoring)")
|
|
port_env = os.getenv("PORT")
|
|
if port_env is None:
|
|
app.run(auto_port=True, host="::")
|
|
else:
|
|
app.run(port=int(port_env), host="::")
|