Skip to main content

No project description provided

Project description

BAIChat API Python

Installation

Pypi

pip install baichat-py

Codeberg

pip install --index-url https://codeberg.org/api/packages/Bavarder/pypi/simple/ baichat-py

Usage

Async

import asyncio

loop = asyncio.get_event_loop() 
hello = loop.run_until_complete(chat.async_ask("Hi"))

print(hello.text)

# => Hello! How can I assist you today?

Context manager

with BAIChat() as (loop, chat):
    hello = chat.ask("Hi")

    print(hello.text)

# => Hello! How can I assist you today?

Delta

with BAIChat() as (loop, chat):
    hello = chat.ask("Hi")

    for delta in hello:
        print(delta.text)
    
# => Hello
# => Hello!
# => Hello! How
# => Hello! How may
# => Hello! How may I
# => Hello! How may I assist
# => Hello! How may I assist you
# => Hello! How may I assist you today
# => Hello! How may I assist you today?

Sync

chat = BAIChat()
print(chat.sync_ask("Hello, how are you?").text)

# => Hello! As an AI language model, I don't have feelings, but I'm functioning properly and ready to assist you. How may I help you today?

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

baichat_py-0.2.2.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

baichat_py-0.2.2-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

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