Skip to main content

Workflow orchestration runtime for ChatDev

Project description

ChatDev Python SDK

This package is a Python SDK wrapper around the upstream ChatDev project. By passing a yaml_file path, you can load and execute the multi-agent system defined by the graph and nodes in the YAML file. In Python, you only need to provide yaml_file + task_prompt (and optionally api_key / model / etc.) to run the workflow and get results.

Quick Start

Installation

From the repository root:

pip install chatdev

Environment Variables:

Some YAML configurations require api_key and base_url. You can use export to add global environment variables:

export API_KEY="YOUR_API_KEY"
export BASE_URL="YOUR_BASE_URL"

Test Example:

from chatdev import run_workflow

result = run_workflow(
    yaml_file="ChatDev_v1.yaml",
    task_prompt="This is a minimal run example",
)

print(result.success)
print(result.final_message)
print(result.output_dir)

Pass configs (default: the first node ID in the YAML file):

result = run_workflow(
    yaml_file="ChatDev_v1.yaml",
    task_prompt="test",
    agent_configs=AgentConfig(
        provider="openai",
        model="gpt-4o",
        api_key="YOUR_API_KEY",
        base_url="https://api.openai.com/v1",
        temperature=1.0,
    ),
)

Specify a node ID:

result = run_workflow(
    yaml_file="ChatDev_v1.yaml",
    task_prompt="test",
    agent_configs={
        "Programmer Code Review": AgentConfig(
            provider="openai",
            model="gpt-4o",
            api_key="YOUR_API_KEY",
            base_url="https://api.openai.com/v1",
            temperature=1.0,
        ),
    },
)

Tools & Skills registration example:

from chatdev import AgentConfig, register_skill, register_tool, run_workflow

@register_skill(
    name="data_analyzer",
    description="Analyze data and generate a report",
    instructions="Please analyze the input in a structured way and output three conclusions.",
)

@register_tool(name="my_echo", description="Echo input")
def my_echo(text: str) -> str:
    return text

result = run_workflow(
    yaml_file="ChatDev_v1.yaml",
    task_prompt="test",
    agent_configs={
        "Programmer Code Review": AgentConfig(
            provider="openai",
            model="gpt-4o",
            api_key="YOUR_API_KEY",
            base_url="https://api.openai.com/v1",
            temperature=1.0,
            tools=["my_echo"],
            skills=["data_analyzer"]
        ),
    },
)

SDK API Reference

chatdev.run_workflow(...)

Execute a workflow YAML file and return ChatDevResult:

  • yaml_file: str | Path — the workflow YAML path
  • task_prompt: str — your task input
  • attachments: list[str | Path] | None — optional attachment paths (packaged into the execution workspace)
  • variables: dict | None
  • agent_configs: AgentConfig | dict[str, AgentConfig] | None
    • Passing a single AgentConfig: automatically attach it to the first node whose type is agent or model (the order of nodes in the YAML). If there is no such node, it falls back to the first node with a non-empty id.
    • Passing a dict[node_id, AgentConfig]: only update the node with that exact id (no "default" fallback).

chatdev.AgentConfig

Optional parameters for overriding/injecting model configuration (merged into the matched node’s config; commonly the agent / model nodes in YAML):

  • provider: "openai" / "gemini" / ...
  • model: e.g. "gpt-4o"
  • api_key
  • base_url
  • system_prompt: overrides the YAML role
  • temperature/top_p/max_tokens
  • skills: add custom skills
  • tools: add custom tools

chatdev.ChatDevResult

The return object of run_workflow (common fields):

  • success: whether it succeeded
  • final_message: the final output text (string)
  • output_dir: the output directory of this run (Path)

Extensions: Register Tools & Skills (Optional)

You can register tools/skills with decorators:

  • @chatdev.register_tool(name=..., description=...)
  • @chatdev.register_skill(name=..., description=..., ...)

Citation

If you use this project in research or products, please cite ChatDev's GitHub repository: OpenBMB/ChatDev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chatdev-0.1.0.tar.gz (301.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatdev-0.1.0-py3-none-any.whl (424.1 kB view details)

Uploaded Python 3

File details

Details for the file chatdev-0.1.0.tar.gz.

File metadata

  • Download URL: chatdev-0.1.0.tar.gz
  • Upload date:
  • Size: 301.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for chatdev-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3900e90c80e5b641ec505203eae04fd10a0ed09d43fefcc90a96be84aa2924a
MD5 f68b3ce9fb7a351de7f219bd2fbe3f2f
BLAKE2b-256 4b1c488618d6fc5cd03289e148d94620fb11c05c08e136f87e6a0ae6ba4a0b75

See more details on using hashes here.

File details

Details for the file chatdev-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chatdev-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 424.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for chatdev-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8bb9fa621b82fd2992febcf8c0c38780ff364c9ffb058ae8241dcc0a354f0d7
MD5 15100e25abfe93d7b10758f7f356b5a7
BLAKE2b-256 47cdcf93f06246423dca41b5fa7c0ba86f211fe400a01560b7926a51667eb56b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page