xml-pipeline/xml_pipeline/config/template.py
dullfig e653d63bc1 Rename agentserver to xml_pipeline, add console example
OSS restructuring for open-core model:
- Rename package from agentserver/ to xml_pipeline/
- Update all imports (44 Python files, 31 docs/configs)
- Update pyproject.toml for OSS distribution (v0.3.0)
- Move prompt_toolkit from core to optional [console] extra
- Remove auth/server/lsp from core optional deps (-> Nextra)

New console example in examples/console/:
- Self-contained demo with handlers and config
- Uses prompt_toolkit (optional, falls back to input())
- No password auth, no TUI, no LSP — just the basics
- Shows how to use xml-pipeline as a library

Import changes:
- from agentserver.* -> from xml_pipeline.*
- CLI entry points updated: xml_pipeline.cli:main

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 21:41:19 -08:00

112 lines
3.8 KiB
Python

"""
Configuration templates for xml-pipeline.
Generates starter organism.yaml files.
"""
def create_organism_template(name: str = "my-organism") -> str:
"""Create a starter organism.yaml configuration."""
return f'''# {name} - xml-pipeline organism configuration
# Documentation: https://github.com/yourorg/xml-pipeline
organism:
name: {name}
version: "0.1.0"
description: "A multi-agent organism"
# =============================================================================
# LLM BACKENDS
# Configure which LLM providers to use. Agents will use these for inference.
# API keys are read from environment variables.
# =============================================================================
llm_backends:
- name: primary
provider: xai # xai, anthropic, openai, ollama
model: grok-2
api_key_env: XAI_API_KEY
priority: 0 # Lower = preferred
# Uncomment to add fallback backends:
# - name: fallback
# provider: anthropic
# model: claude-3-sonnet-20240229
# api_key_env: ANTHROPIC_API_KEY
# priority: 1
# =============================================================================
# LISTENERS
# Define agents, tools, and gateways that make up your organism.
# =============================================================================
listeners:
# -----------------------------------------------------------------------------
# Example agent - an LLM-powered assistant
# -----------------------------------------------------------------------------
- name: assistant
agent: true
description: "A helpful assistant that can use tools"
prompt: |
You are a helpful assistant. You can use tools to help users.
Always be concise and accurate.
model: grok-2 # Override default model (optional)
peers:
- calculator # Can call calculator tool
- fetcher # Can call fetch tool
allowed_tools:
- calculate
- fetch
# -----------------------------------------------------------------------------
# Example tool - calculator
# -----------------------------------------------------------------------------
- name: calculator
tool: true
description: "Evaluates mathematical expressions"
handler: agentserver.tools.calculate:calculate_handler
payload_class: agentserver.tools.calculate:CalculateRequest
# -----------------------------------------------------------------------------
# Example tool - HTTP fetcher
# -----------------------------------------------------------------------------
- name: fetcher
tool: true
description: "Fetches content from URLs"
handler: agentserver.tools.fetch:fetch_handler
payload_class: agentserver.tools.fetch:FetchRequest
# =============================================================================
# OPTIONAL: WebSocket server for remote connections
# Uncomment to enable. Requires: pip install xml-pipeline[server]
# =============================================================================
# server:
# enabled: true
# host: "127.0.0.1"
# port: 8765
# =============================================================================
# OPTIONAL: Authentication for privileged operations
# Uncomment to enable. Requires: pip install xml-pipeline[auth]
# =============================================================================
# auth:
# enabled: true
# totp_secret_env: ORGANISM_TOTP_SECRET
'''
def create_minimal_template(name: str = "simple") -> str:
"""Create a minimal organism.yaml with just one agent."""
return f'''organism:
name: {name}
llm_backends:
- name: default
provider: xai
model: grok-2
api_key_env: XAI_API_KEY
listeners:
- name: assistant
agent: true
description: "A simple assistant"
prompt: "You are a helpful assistant."
'''