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_entity": {"entity_id": "ent_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.product_analysis_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.dashboard: entity, product analysis, handle analysis, query, task, prompt, search, tweet, account, and statistics APIs
  • client.file_upload: upload files for attachments
  • client.user: account bootstrap, API keys, X connector management
  • client.marketing: small compatibility surface for report updates and research tweets
  • 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.8.tar.gz (47.2 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.8-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: octoevo-0.1.8.tar.gz
  • Upload date:
  • Size: 47.2 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.8.tar.gz
Algorithm Hash digest
SHA256 763b405da7e1ad60306d5bc9dc6e968c889d75a9b2b3d75739fa5a5dcddeb546
MD5 b0681d801dd89c6af269a1cf0274be92
BLAKE2b-256 1a4f590cc53091b8cd76cb0a815a6f781cb1ae2da2f52040fcaa6f244201436a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: octoevo-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 50.9 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a11102470035e4d8f9c61a45763f0c090337ca023164d6fff15b9d466f76cdaf
MD5 30b54f2de60f967835e82d94ca4695d4
BLAKE2b-256 412d2ce1068823b0ed4b491021d8f99b806c42701cb8c42d5df8b9935939f44d

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