Skip to main content

Client SDK for ai-stream-proxy.

Project description

Usage

import asyncio

if __name__ == '__main__':
    from ai_stream_proxy import StreamProxyClient
    async def main():
        client = StreamProxyClient(
            server_url="http://127.0.0.1:3000",
            httpx_async_client_options={'proxy': 'http://127.0.0.1:7890'}
        )

        await client.delete_stream(stream_id='test')

        await client.create_stream(
            stream_id='test',
            message_id='haha',
            content_type='claude-code-stream-json+include-partial-messages'
        )

        async with client.new_stream(stream_id="test") as stream:
            with open('some-claude-code-output.jsonl', 'r') as f:
                while True:
                    chunk = f.read(4096)
                    if not chunk:
                        break
                    stream.enqueue(chunk.encode('utf-8'))
            stream.finish(abort=False, reason="Finish")

        await client.wait_for_current_streams()


    asyncio.run(main())

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

ai_stream_proxy-0.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

ai_stream_proxy-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ai_stream_proxy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ea4b3dccd54f9e5565f88c41f766c93cad53c27addc5e2eab87691dc838abe0b
MD5 3a98bb024cfd1150829d3a1b557b0726
BLAKE2b-256 4bc95e83bb0c1243724cf1c3be71e91aae90a48e3d9c47ff7fc6b379b6ee0ec4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ai_stream_proxy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e432ee6da0de5f50bd70e6a61b68ff9c3bb572478969a0866fd92b93015c08f
MD5 3d039e0aca92a20ab21ec1cbf6c9197f
BLAKE2b-256 8913740f548bd3fd46744629ac4f967ef90b8fd2d9faabd5ef01f236a3089112

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