Skip to main content

Python SDK for OctoEvo

Project description

English | 中文

OctoEvo SDK for Python

Python SDK for OctoEvo agent sessions, marketing execution, and product analysis.

Features

  • HTTP client for sessions, products, files, users, teams, agents, and marketing APIs
  • WebSocket TaskRunner for interactive and automated agent sessions
  • Marketing tasks default to execution_mode="auto" so the backend chooses the correct execution channel
  • Structured handling for X authorization, X account selection, and browser extension requirements
  • Product analysis workflow with create, poll, and report APIs
  • API key and JWT authentication

Requirements

  • Python 3.9+
  • An OctoEvo api_key or jwt_token

Installation

pip install octoevo

For environment-specific setup, see installation.md.

Configuration

Create mate.yaml:

mate:
  api_key: "your-api-key"
  # jwt_token: "your-jwt-token"
  base_url: "https://api.dev.weclaw.ai"
  timeout: 30

Initialize a client:

from octoevo.mate import Client
from octoevo.mate.config import load_config

client = Client(load_config("mate.yaml"))

Never commit real credentials. Use local config files, environment secret storage, or CI secrets.

Quick Start: Marketing Session

Use run_interactive_session() for marketing tasks that may require user input, X authorization, X account selection, or browser extension connection.

from octoevo.mate import Client, create_task_runner
from octoevo.mate.config import load_config
from octoevo.mate.models import CreateSessionRequest
from octoevo.mate.task_runner import TaskExecutionOptions, TaskMode
from octoevo.mate.websocket import WebSocketClient

client = Client(load_config("mate.yaml"))

req = CreateSessionRequest(
    task="Draft a launch thread for my product",
    mode="marketing",
    platform="api",
    extra={"marketing_product": {"product_id": "prod_123"}},
)

session = client.session.create(req)
session_info = client.session.get_info(session.session_id)

ws_client = WebSocketClient(
    base_url=client.base_url,
    api_key=client.api_key or "",
    jwt_token=client.jwt_token or "",
    session_id=session_info.session_id,
)

runner = create_task_runner(ws_client, client, session_info)
runner.run_interactive_session(
    initial_task="Generate 3 tweet drafts and recommended replies",
    task_mode=TaskMode.Marketing,
    extra=req.extra,
    options=TaskExecutionOptions(
        auto_accept_plan=False,
        verbose=True,
        stop_on_x_confirm=True,
        completion_timeout=600,
    ),
)

Marketing tasks default to execution_mode="auto" in TaskRunner. Do not pass external_user_id or external_username; the agent selects the execution channel and asks for required input only when needed.

Structured prompts handled by the SDK:

Prompt Meaning
x_api_authorize X API authorization is required
x_api_account_select Multiple X accounts are connected and one must be selected
extension_required The browser extension is required for the current action

Use stop_on_x_confirm=True for CLI-safe runs. Set it to False only when your app should confirm live social actions automatically.

Read generated marketing data:

tweet_data = client.session.get_marketing_data(session.session_id, type="tweet")
reply_data = client.session.get_marketing_data(session.session_id, type="reply")

Runnable example: examples/getting_started/example.py

Product Analysis

Product analysis is HTTP-only. It does not use WebSocket or TaskRunner.

from octoevo.mate import Client
from octoevo.mate.config import load_config

client = Client(load_config("mate.yaml"))

report = client.product.create_and_wait(
    product="Notion",
    attachments=None,
    on_poll=lambda attempt, status: print(f"[poll {attempt}] {status}"),
)

print(report.report_id)
print(report.product_name)
print(report.keywords)
print(report.competitors)

For attachments, upload files first:

upload = client.file_upload.upload_file("brief.pdf")
attachments = [{"file_name": upload["file_name"], "file_url": upload["file_url"]}]

report = client.product.create_and_wait(
    product="Notion",
    attachments=attachments,
)

Runnable example: examples/product_analysis/example.py

Account Bootstrap

These helpers are standalone account flows. They are not required inside normal marketing task execution.

from octoevo.mate import Client, ClientOptions

client = Client(ClientOptions())

email_resp = client.user.start_email_verification(
    email="you@example.com",
    invite_code=None,
)
print(email_resp.sign_type, email_resp.pre_auth_id)

x_login = client.user.get_x_oauth_url()
print(x_login.auth_url)

Low-level X connector management requires an authenticated client:

accounts = client.user.list_x_accounts()
auth = client.user.authorize_x_account(target_connector_id=None)
print(len(accounts.items), auth.auth_url)

client.user.delete_x_account("connector-id")

Use connector APIs only for account administration. Do not use them to choose a task execution account; run_interactive_session() handles task-time authorization and account selection.

Runnable examples:

Task Runner API

Create a task runner with:

runner = create_task_runner(ws_client, client, session_info)

Main methods:

  • run_interactive_session(initial_task, attachments=None, task_mode=TaskMode.Default, extra=None, options=None)
  • run_task(task, attachments=None, task_mode=TaskMode.Default, extra=None, options=None) -> TaskResult

Prefer run_interactive_session() for marketing tasks. Non-interactive run_task() fails safely when authorization, account selection, or browser extension connection is required.

Common options:

  • verbose: print progress to stdout
  • auto_accept_plan: auto-approve plan messages
  • stop_on_x_confirm: stop instead of confirming social actions
  • completion_timeout: maximum run time in seconds

Services

  • client.session: create sessions, stop sessions, read messages, read marketing data
  • client.product: create product analysis jobs, poll status, read reports, read categories
  • client.file_upload: upload files for attachments
  • client.user: account bootstrap, API keys, X connector management
  • client.marketing: marketing dashboard APIs
  • client.team, client.agent, client.browser: supporting APIs

Error Types

  • APIError
  • NetworkError
  • WebSocketError
  • ConfigError
  • SessionExecutionError

Documentation

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

octoevo-0.1.7.tar.gz (42.6 kB view details)

Uploaded Source

Built Distribution

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

octoevo-0.1.7-py3-none-any.whl (48.3 kB view details)

Uploaded Python 3

File details

Details for the file octoevo-0.1.7.tar.gz.

File metadata

  • Download URL: octoevo-0.1.7.tar.gz
  • Upload date:
  • Size: 42.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for octoevo-0.1.7.tar.gz
Algorithm Hash digest
SHA256 075cc93e7194d3412275108f51d3a33b2e0cbb78ad65e355728485f058fce3d3
MD5 fd28662b4162b424b7e8da7199091fbd
BLAKE2b-256 afc091b21b916337e95b6ae987d6ebfe17e9576e30adce463cbe277ecc096243

See more details on using hashes here.

File details

Details for the file octoevo-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: octoevo-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 48.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for octoevo-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f65dfda66d08d5f325f2decb751ea1e2bc35447a9774e9bf0b464f0c5a1ca4b2
MD5 1d3634e5417e3994e6dc41f7639873a0
BLAKE2b-256 475b42436e21169d0400c9fe6138e5b0da92b84ccb2b3fa105b08877720cc3d5

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