This document provides detailed API reference for Westodyssey framework.
The main orchestrator class that represents the human user (Tang Sanzang).
from westodyssey import TangSeng
# Initialize TangSeng
master = TangSeng(
config_path="config/team_config.json",
workflow_path="config/workflow.yaml"
)| Parameter | Type | Description | Default |
|---|---|---|---|
config_path |
str | Path to team configuration file | "config/team_config.json" |
workflow_path |
str | Path to workflow configuration file | "config/workflow.yaml" |
api_key |
str | OpenAI API key (optional) | None (reads from .env) |
verbose |
bool | Enable verbose logging | False |
Assign a mission to the team.
result = master.assign_mission(
mission="Analyze trending AI projects",
context="Focus on multi-agent systems"
)Parameters:
mission(str): The main mission/task descriptioncontext(str, optional): Additional context or constraints
Returns:
dict: Mission result with status and output
Get current status of all team members.
status = master.get_team_status()Returns:
dict: Team status information
Reset the team to initial state.
master.reset_team()The core problem solver (Sun Wukong).
from westodyssey.agents import Wukong
wukong = Wukong(
model="gpt-4",
temperature=0.7,
tools=["browser", "code_interpreter"]
)| Parameter | Type | Description | Default |
|---|---|---|---|
model |
str | LLM model to use | "gpt-4" |
temperature |
float | Creativity level (0.0-1.0) | 0.7 |
tools |
list | Available tools | ["browser", "code_interpreter"] |
max_tokens |
int | Maximum tokens per response | 4000 |
Solve a complex problem.
solution = wukong.solve(
problem="Write a web scraper for GitHub trends",
context="Use Python and BeautifulSoup"
)Generate code for a specific task.
code = wukong.generate_code(
language="python",
task="Data analysis with pandas"
)Research a topic and gather information.
research_result = wukong.research(
topic="AI agent frameworks",
sources=5
)The quality auditor (Zhu Bajie).
from westodyssey.agents import Bajie
bajie = Bajie(
model="claude-3-sonnet",
strictness="high"
)| Parameter | Type | Description | Default |
|---|---|---|---|
model |
str | LLM model to use | "claude-3-sonnet" |
strictness |
str | Review strictness level | "high" |
max_review_cycles |
int | Maximum review cycles | 3 |
Review a solution for quality and safety.
review_result = bajie.review(
solution=wukong_solution,
criteria=["security", "efficiency", "best_practices"]
)Perform code audit.
audit_result = bajie.audit_code(
code=python_code,
language="python"
)Validate output format.
validation_result = bajie.validate_output(
output=data_output,
format_spec={"type": "markdown", "sections": ["introduction", "analysis"]}
)The data deliverer (Sha Wujing).
from westodyssey.agents import Wujing
wujing = Wujing(
model="gpt-3.5-turbo",
temperature=0.0
)| Parameter | Type | Description | Default |
|---|---|---|---|
model |
str | LLM model to use | "gpt-3.5-turbo" |
temperature |
float | Strictness level | 0.0 |
Format data into specified format.
formatted = wujing.format(
data=raw_data,
format_type="markdown"
)Clean and normalize data.
cleaned = wujing.clean_data(
data=raw_dataset,
rules=["remove_duplicates", "normalize_dates"]
)Deliver output to destination.
delivery_result = wujing.deliver(
output=final_output,
destination="file://output/report.md"
)The memory system (White Dragon Horse).
from westodyssey.agents import Steed
steed = Steed(
vector_db_path="memory_database",
embedding_model="text-embedding-3-small"
)| Parameter | Type | Description | Default |
|---|---|---|---|
vector_db_path |
str | Path to vector database | "memory_database" |
embedding_model |
str | Embedding model to use | "text-embedding-3-small" |
Record an event to memory.
steed.record(
event="mission_completed",
metadata={"mission_id": "123", "duration": "1.5h"}
)Recall similar memories.
memories = steed.recall(
query="data analysis mission",
limit=5
)Get context for a specific mission.
context = steed.get_context(mission_id="123")The main workflow orchestrator.
from westodyssey.workflow import Pilgrimage
workflow = Pilgrimage(
wukong=wukong,
bajie=bajie,
wujing=wujing,
steed=steed,
human_in_the_loop=True
)Dispatch a mission through the full workflow.
result = workflow.dispatch(
mission="Analyze AI trends",
context="Latest developments in 2024"
)Get progress of a specific mission.
progress = workflow.get_progress(mission_id="123")Pause a mission for human review.
workflow.pause_mission(mission_id="123")Team configuration structure:
team_config = {
"wukong": {
"model": "gpt-4",
"temperature": 0.7,
"tools": ["browser", "code_interpreter", "web_search"]
},
"bajie": {
"model": "claude-3-sonnet",
"strictness": "high",
"max_review_cycles": 3
},
"wujing": {
"model": "gpt-3.5-turbo",
"temperature": 0.0
},
"steed": {
"embedding_model": "text-embedding-3-small",
"vector_db_path": "memory_database"
}
}Workflow configuration structure:
workflow:
steps:
- load_context: true
- solve_problem: true
- review_solution: true
- format_output: true
- record_memory: true
constraints:
max_review_cycles: 3
require_human_approval: true
timeout_minutes: 30
notifications:
on_pause: true
on_completion: true
on_error: trueLoad configuration from file.
from westodyssey.utils import load_config
config = load_config("config/team_config.json")Save configuration to file.
from westodyssey.utils import save_config
save_config(team_config, "config/team_config.json")Validate configuration structure.
from westodyssey.utils import validate_config
is_valid = validate_config(team_config)from westodyssey.exceptions import (
MissionTimeoutError,
ReviewCycleExceededError,
FormatValidationError,
MemoryRetrievalError
)
try:
result = workflow.dispatch(mission)
except MissionTimeoutError as e:
print(f"Mission timed out: {e}")
except ReviewCycleExceededError as e:
print(f"Too many review cycles: {e}")from westodyssey.recovery import retry_with_backoff
@retry_with_backoff(max_retries=3)
def execute_mission(mission):
return workflow.dispatch(mission)from westodyssey import TangSeng
# Initialize
master = TangSeng()
# Execute mission
result = master.assign_mission(
mission="Create a market analysis report",
context="Focus on AI agent market in 2024"
)
print(result["output"])from westodyssey.workflow import Pilgrimage
from westodyssey.agents import Wukong, Bajie, Wujing, Steed
# Create custom team
wukong = Wukong(model="gpt-4o", tools=["all"])
bajie = Bajie(model="claude-3-5-sonnet", strictness="extreme")
wujing = Wujing(model="gpt-4", temperature=0.0)
steed = Steed(embedding_model="text-embedding-3-large")
# Create workflow
workflow = Pilgrimage(
wukong=wukong,
bajie=bajie,
wujing=wujing,
steed=steed,
human_in_the_loop=False # Full automation
)
# Execute
result = workflow.dispatch("Complex data analysis task")Note: This API reference is continuously updated. Check the GitHub repository for the latest version.