ДокументацияTypeSafe Python SDKTypeSafe Python SDK

TypeSafe Python SDK

Install the TypeSafe Python SDK and get started with asynchronous or synchronous API calls.

Установите TypeSafe Python SDK и начните работу с асинхронными или синхронными вызовами API.

Исходный код Python SDK доступен на GitHub.

Асинхронный и синхронный клиенты Python для API TypeSafe. Узнайте больше об использовании TypeSafe здесь.

Быстрый старт

  1. Установите SDK:

    ```sh theme={null} uv add typesafe-sdk ``` ```sh theme={null} pip install typesafe-sdk ```
  2. Задайте переменную окружения TYPESAFE_API_KEY (создать ключ можно здесь)

  3. Вызовите System One API:

    С использованием [AsyncTypeSafeClient](/docs/sdk/python/api/clients/async):
    PLAINTEXT api.wedstack.ru/v1
    ```python theme={null}
    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](/docs/sdk/python/api/clients/sync):
    PLAINTEXT api.wedstack.ru/v1
    ```python theme={null}
    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)
    ```

Использование

Подробнее читайте в руководстве по использованию.