TypeSafe Python 软件开发工具包
机器翻译译自英文(docs.typesafe.ai)本页 9 段已全部译完
文档索引
在以下地址获取完整的文档索引:https://docs.typesafe.ai/llms.txt 使用此文件可以在进一步探索之前发现所有可用页面。
TypeSafe Python 软件开发工具包
安装 TypeSafe Python SDK 并开始使用异步或同步 API 调用。
用于 TypeSafe API 的异步和同步 Python 客户端。了解如何在此处使用 TypeSafe。
快速入门
-
安装 SDK:
uv add typesafe-sdkpip install typesafe-sdk -
在环境中设置
TYPESAFE_API_KEY(在此处 创建) -
调用 System One API:
from typesafe_sdk import AsyncTypeSafeClient, Choice, Noul, Score async def main() -> None: async with AsyncTypeSafeClient() as client: response = await client.system_one( state={"document": "I was charged twice. Please fix this ASAP."}, questions={ "billing": Noul(instructions="Is this ticket about billing?"), "tone": Choice( instructions="What is the customer's tone?", criteria={"calm": None, "frustrated": None, "angry": None}, ), "urgency": Score( instructions="How urgent is this ticket?", criteria=["can wait", "this week", "today"], ), }, ) print(response.nouls["billing"].noul) print(response.choices["tone"].choice) print(response.scores["urgency"].score)使用 TypeSafeClient:
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient with TypeSafeClient() as client: response = client.system_one( state={"document": "I was charged twice. Please fix this ASAP."}, questions={ "billing": Noul(instructions="Is this ticket about billing?"), "tone": Choice( instructions="What is the customer's tone?", criteria={"calm": None, "frustrated": None, "angry": None}, ), "urgency": Score( instructions="How urgent is this ticket?", criteria=["can wait", "this week", "today"], ), }, ) print(response.nouls["billing"].noul) print(response.choices["tone"].choice) print(response.scores["urgency"].score)
用法
更多详情请参阅 使用指南。
AI 翻译查看英文原文