Skip to main content

Official Python SDK for Chatiss Open Platform

Project description

Chatiss Open SDK

Official Python SDK for Chatiss Open Platform.

What's New in 0.1.1

  • Added word_article_detail API support for sync and async clients
  • Added typed SSE result models for tongue_create
  • Improved response parsing and test coverage for new result models

Features

  • Sync client: OpenAPIClient
  • Async client: AsyncOpenAPIClient
  • Automatic JWT token acquisition and refresh
  • Structured API response models
  • Unified exception model
  • SSE stream support for tongue analysis API

Installation

pip install chatiss-open-sdk

Quick Start (Sync)

from chatiss_open_sdk import SDKConfig, OpenAPIClient
from chatiss_open_sdk.types import TongueCreateRequest

config = SDKConfig(
    access_key_id="your_access_key_id",
    access_key_secret="your_access_key_secret",
)

with OpenAPIClient(config) as client:
    token_resp = client.get_jwt_token()
    print(token_resp.status)

    req = TongueCreateRequest(
        original_img="https://example.com/original.png",
        skin_img="https://example.com/skin.png",
        gender=1,
        birthday="1990-01-01",
        use_flash=True,
    )
    for event in client.tongue_create(req):
        print(event.event, event.data.status)

Quick Start (Async)

import asyncio
from chatiss_open_sdk import SDKConfig, AsyncOpenAPIClient
from chatiss_open_sdk.types import TongueCreateRequest


async def main():
    config = SDKConfig(
        access_key_id="your_access_key_id",
        access_key_secret="your_access_key_secret",
    )

    async with AsyncOpenAPIClient(config) as client:
        req = TongueCreateRequest(
            original_img="https://example.com/original.png",
            skin_img="https://example.com/skin.png",
            gender=1,
            birthday="1990-01-01",
            use_flash=True,
        )
        async for event in client.tongue_create(req):
            print(event.event, event.data.status)


asyncio.run(main())

Word Article Detail

from chatiss_open_sdk import SDKConfig, OpenAPIClient

config = SDKConfig(
    access_key_id="your_access_key_id",
    access_key_secret="your_access_key_secret",
)

with OpenAPIClient(config) as client:
    resp = client.word_article_detail("632278c7-5e6c-487a-b8b3-ec91fc42840f")
    if resp.status == "SUCCESS" and resp.result is not None:
        print(resp.result.id)
        for paragraph in resp.result.paragraphs:
            print(paragraph.title)

Error Handling

  • Business failures (status == "FAIL") are returned in APIResponse
  • Network failures raise NetworkError
  • Auth failures raise AuthError
  • Protocol/schema failures raise ProtocolError
  • SSE interruption raises SSEStreamError

License

MIT See LICENSE for the full text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chatiss_open_sdk-0.1.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatiss_open_sdk-0.1.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file chatiss_open_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: chatiss_open_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for chatiss_open_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0e85477129886038d65f86e8f859df14a017f71a4949c5cb9dec805ca6a9e4d4
MD5 0cddd6b154b7fb5fc46d58c4fa7c211b
BLAKE2b-256 d53bdc89c61682f381140eda43aa89d04f21ea399382d511916f0a146df2ecfd

See more details on using hashes here.

File details

Details for the file chatiss_open_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for chatiss_open_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e99e089ecce1dbb0afb6c8aa6184cefc313a9bc5fb6a08a040d9675d3e4a13a5
MD5 f77252df86f21323bc46f54b6aae5c34
BLAKE2b-256 5cccfe1c5f52659b7e8fb2fa25a8c32533f7a16558a233e679d67b1d069337e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page