🔌 API 参考
本页记录 v0.3.1 当前 Python SDK 的实际 API 结构。
Client
Client 是主入口。
from wyseos.mate import Client, ClientOptions
from wyseos.mate.config import load_config
client = Client(load_config("mate.yaml"))
# 或
client = Client(ClientOptions(api_key="YOUR_API_KEY"))ClientOptions
| 字段 | 类型 | 必填 | 默认值 |
|---|---|---|---|
api_key | Optional[str] | 否 | None |
jwt_token | Optional[str] | 否 | None |
base_url | str | 否 | https://api.wyseos.com |
timeout | int | 否 | 30 |
说明:
base_url必须以http://或https://开头。timeout范围是1-300。api_key和jwt_token任选其一配置。
Client 上的服务
client.userclient.teamclient.agentclient.sessionclient.browserclient.file_uploadclient.marketingclient.product
Session API
通过 client.session 访问。
方法
create(request: CreateSessionRequest) -> CreateSessionResponseget_info(session_id: str) -> SessionInfoget_messages(session_id: str, page_num: int = 1, page_size: int = 20, filter: Optional[MessageFilter] = None) -> GetMessagesResponseget_between_messages(session_id: str, from_message_id: str, to_message_id: str) -> GetMessagesResponseget_marketing_data(session_id: str, type: Optional[str] = None) -> Dict[str, Any]update_session_name(request: UpdateSessionNameRequest) -> None
CreateSessionRequest
from wyseos.mate.models import CreateSessionRequest
req = CreateSessionRequest(
task="Draft a Twitter launch campaign for my product",
mode="marketing", # optional
platform="api", # optional
extra={ # optional
"marketing_product": {"product_id": "prod_123"}
},
)字段:
task: str(必填)intent_id: Optional[str]mode: Optional[str]platform: Optional[str]extra: Optional[Dict[str, Any]]
TaskRunner API
通过包级工厂函数创建 TaskRunner:
from wyseos.mate import create_task_runner
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)TaskMode
TaskMode.DefaultTaskMode.DeepSearchTaskMode.Marketing
TaskExecutionOptions
| 字段 | 类型 | 默认值 |
|---|---|---|
verbose | bool | False |
auto_accept_plan | bool | True |
capture_screenshots | bool | False |
enable_browser_logging | bool | True |
enable_event_logging | Optional[bool] | None |
completion_timeout | int | 300 |
max_user_input_timeout | int | 0 |
stop_on_x_confirm | bool | False |
TaskRunner 方法
run_task(
task: str,
attachments: List[Dict] = None,
task_mode: TaskMode = TaskMode.Default,
extra: Optional[Dict[str, Any]] = None,
options: TaskExecutionOptions = None,
) -> TaskResultrun_interactive_session(
initial_task: str,
attachments: List[Dict] = None,
task_mode: TaskMode = TaskMode.Default,
extra: Optional[Dict[str, Any]] = None,
options: TaskExecutionOptions = None,
) -> NoneTaskResult
success: boolfinal_answer: strerror: Optional[str]screenshots: List[Dict[str, Any]]execution_logs: List[Dict[str, Any]]plan_history: List[Dict[str, Any]]session_duration: floatmessage_count: int
Product API
通过 client.product 访问。
方法
create(req: CreateProductRequest) -> CreateProductResponseget_info(product_id: str) -> ProductInfoget_report(report_id: str) -> ProductReportget_categories() -> List[Industry]create_and_wait(product: str, attachments: Optional[List[Dict[str, str]]] = None, poll_interval: int = 20, max_attempts: int = 30, on_poll: Optional[Callable[[int, str], None]] = None) -> ProductReport
CreateProductRequest
product: strattachments: List[ProductAttachment]
ProductAttachment:
file_name: strfile_url: str
Marketing API
通过 client.marketing 访问。
update_report(report_id: str, data: Dict[str, Any]) -> Dict[str, Any]get_research_tweets(query_id: str) -> Any
会话级营销内容查询:
client.session.get_marketing_data(session_id, type="reply"|"like"|"retweet"|"tweet")
文件上传 API
通过 client.file_upload 访问。
upload_file(file_path: str, session_id: Optional[str] = None) -> Dict[str, Any]
支持扩展名:
.txt,.pdf,.png,.jpg,.jpeg,.md,.csv,.html,.htm,.rss,.xml,.gif,.py,.json
最大文件大小:10MB。
分页模型
ListOptions(page_num: int = 1, page_size: int = 20)PaginatedResponse[T]字段:page_num、page_size、total、total_page、data