✨ 快速开始
这个 SDK 有两个独立工作流:
- 营销会话(WebSocket + Session APIs)
- 产品分析(HTTP 轮询 + Product APIs)
一次只使用一个工作流。
1. 环境准备
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install wyseos-sdk2. 配置客户端
创建 mate.yaml:
mate:
api_key: "your-api-key"
# or jwt_token: "your-jwt-token"
base_url: "https://api.wyseos.com"
timeout: 30初始化客户端:
from wyseos.mate import Client
from wyseos.mate.config import load_config
client = Client(load_config("mate.yaml"))3. 选择一个工作流
| 工作流 | 入口 | 传输方式 | 主要输出 |
|---|---|---|---|
| 营销会话 | create_task_runner(...).run_interactive_session(...) | WebSocket | 流式会话消息 + 营销数据 |
| 产品分析 | client.product.create_and_wait(...) | HTTP 轮询 | ProductReport |
A) 营销会话
from wyseos.mate import create_task_runner
from wyseos.mate.models import CreateSessionRequest
from wyseos.mate.task_runner import TaskExecutionOptions, TaskMode
from wyseos.mate.websocket import WebSocketClient
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)
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,
),
)读取营销数据:
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")B) 产品分析
可选:上传附件
upload = client.file_upload.upload_file("brief.pdf")
attachments = [{"file_name": upload["file_name"], "file_url": upload["file_url"]}]一步式 API:
report = client.product.create_and_wait(
product="Notion",
attachments=attachments,
poll_interval=20,
max_attempts=30,
)
print(report.report_id)
print(report.status)
print(report.product_name)