WyseOS
HomepagePython SDKUser Manual
WyseOS

Introduction

πŸ“– DocumentationπŸ“œ Concepts

Users

πŸ“‹ User Manual

Developers

πŸš€ Python SDK
πŸ“‹ Installation✨ Getting StartedπŸ”‘ Authentication🐍 Examplesβš™οΈ Release NotesπŸ”Œ ReferencesπŸ”§ Troubleshooting

Changelogs

Others

Contact Us
πŸš€ Python SDK

🐍 Examples

This SDK has two independent scenarios:

  • Marketing (WebSocket + Session APIs)
  • Product Analysis (HTTP Polling + Product APIs)

They are separate entry points and should not be mixed.

1. Setup

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install wyseos-sdk

2. Configure Client

Create mate.yaml:

mate:
  api_key: "your-api-key"
  # or jwt_token: "your-jwt-token"
  base_url: "https://api.wyseos.com"
  timeout: 30

Initialize:

from wyseos.mate import Client
from wyseos.mate.config import load_config

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

3. Choose One Workflow

WorkflowEntry PointTransportMain Output
Marketing Sessioncreate_task_runner(...).run_interactive_session(...)WebSocketStreamed session messages + marketing data
Product Analysisclient.product.create_and_wait(...)HTTP pollingProductReport

A) Marketing Session

A1. Create Session

from wyseos.mate.models import CreateSessionRequest

req = CreateSessionRequest(
    task="Create a marketing tweet thread for my product",
    mode="marketing",
    platform="api",
    extra={
        "marketing_product": {"product_id": "prod_123"},
        "skills": [{"skill_id": "xxx", "skill_name": "persona"}],
    },
)

session = client.session.create(req)
session_info = client.session.get_info(session.session_id)
print("session_id:", session.session_id)

A2. Run Interactive Session

from wyseos.mate import create_task_runner
from wyseos.mate.task_runner import TaskExecutionOptions, TaskMode
from wyseos.mate.websocket import WebSocketClient

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,
)

task_runner = create_task_runner(ws_client, client, session_info)

task_runner.run_interactive_session(
    initial_task="Generate 3 tweet drafts and recommended replies",
    attachments=[],
    task_mode=TaskMode.Marketing,
    extra=req.extra,
    options=TaskExecutionOptions(
        auto_accept_plan=False,
        capture_screenshots=False,
        verbose=True,
        stop_on_x_confirm=True,
        completion_timeout=600,
    ),
)

A3. Read Marketing Data

reply_data = client.session.get_marketing_data(session.session_id, type="reply")
like_data = client.session.get_marketing_data(session.session_id, type="like")
retweet_data = client.session.get_marketing_data(session.session_id, type="retweet")
tweet_data = client.session.get_marketing_data(session.session_id, type="tweet")

print(len(reply_data.get("reply", [])), "replies")
print(len(tweet_data.get("tweet", [])), "draft tweets")

Interactive commands:

  • stop -> send stop message
  • pause -> send pause message
  • exit / quit / q -> leave session

B) Product Analysis

B1. Optional: Upload Attachments

Use upload response as the source of truth for attachments:

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

B2. One-shot API (Recommended)

report = client.product.create_and_wait(
    product="Notion",
    attachments=attachments,
    poll_interval=20,
    max_attempts=30,
)

print("report_id:", report.report_id)
print("status:", report.status)
print("product_name:", report.product_name)

B3. Step-by-step API

from wyseos.mate.models import CreateProductRequest

created = client.product.create(
    CreateProductRequest(product="Notion", attachments=attachments)
)
info = client.product.get_info(created.product_id)

if info.analysis_result and info.analysis_result.report_id:
    report = client.product.get_report(info.analysis_result.report_id)

4. Error Handling

from wyseos.mate.errors import APIError, NetworkError, ConfigError, WebSocketError

try:
    # your SDK calls
    pass
except APIError as e:
    print("APIError:", e)
except WebSocketError as e:
    print("WebSocketError:", e)
except NetworkError as e:
    print("NetworkError:", e)
except ConfigError as e:
    print("ConfigError:", e)

5. Related APIs

Marketing:

  • client.session.get_marketing_data(...)
  • client.marketing.update_report(report_id, data)
  • client.marketing.get_research_tweets(query_id)

Product analysis:

  • client.product.create(request)
  • client.product.create_and_wait(product, attachments=None, ...)
  • client.product.get_info(product_id)
  • client.product.get_report(report_id)
  • client.product.get_categories()

πŸ”‘ Authentication

Previous Page

βš™οΈ Release Notes

Next Page

Table of Contents

1. Setup
2. Configure Client
3. Choose One Workflow
A) Marketing Session
A1. Create Session
A2. Run Interactive Session
A3. Read Marketing Data
B) Product Analysis
B1. Optional: Upload Attachments
B2. One-shot API (Recommended)
B3. Step-by-step API
4. Error Handling
5. Related APIs