Metadata-Version: 2.0
Name: chaipy
Version: 0.3.8
Summary: A developer interface for creating chatbots for the Chai app.
Home-page: UNKNOWN
Author: Chai
Author-email: dev@chai.ml
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Communications :: Chat
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: notebook
Requires-Dist: colorama (>=0.4.4)
Requires-Dist: halo (>=0.0.31)
Requires-Dist: requests (>=2.23.0)
Requires-Dist: segno (>=1.3.3)
Requires-Dist: typing-extensions (>=3.7.4.3)
Provides-Extra: notebook
Requires-Dist: nest-asyncio; extra == 'notebook'

ChaiPy
======

|PyPI - Python Version| |PyPI|

A developer interface for creating Chat AIs for the Chai app.

Install
-------

You can install chai using pip

::

    $ pip install -U chai_py

Local development
-----------------

A quick start guide is available `here <https://chai.ml/docs/>`__, with
a minimal example available on GitHub
`here <https://github.com/chai-nexus/chai_py_quickstart>`__.

Configuration
-------------

You must authenticate using your developer id and key before various
operations are possible.

.. code:: python

    from chai_py.auth import set_auth

    set_auth('my_developer_uid', 'my_developer_key')

You can create a key through the `Chai website <https://chai.ml/dev>`__

Examples
--------

Deploying a bot
~~~~~~~~~~~~~~~

Once you have a bot ready to deploy you can package it

.. code:: python

    from chai_py import package, Metadata, upload_and_deploy, wait_for_deployment

    package(
        Metadata(
            name='My Bot Name',
        image_url='http://url_of_image.jpg',
        color='f1abab',
        developer_uid='my_developer_uid',
        description='Talk to my example bot',
        input_class=MyBotClass
        )
        requirements=['retry']
    )

    bot_uid = upload_and_deploy('_package.zip')
    wait_for_deployment(bot_uid)

Getting a shareable link or QR code to talk to your bot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    from chai_py.deployment import advertise_deployed_bot

    advertise_deployed_bot(bot_uid)

Get a list of all the chatbots you have deployed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a good way to remind yourself of the bot IDs and whether they
are discoverable by other users.

.. code:: python

    from chai_py import deployed

    my_bots = deployed.get_bots()

Get the debug logs of a deployed chatbot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you bot is failing to respond it may be that it has an error. You can
retrieve the logs in order to investigate further

.. code:: python

    from chai_py import cloud_logs

    logs = cloud_logs.get_logs(bot_uid)
    cloud_logs.display_logs(logs)

Make a bot visible to the public
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By default a bot is inactive, it can be viewed and shared via a link or
QR code but will not be discoverable by users of the app.

To make a bot visible to all users run

.. code:: python

    from chai_py import deployed

    deployed.activate_bot(bot_uid)

and to make a bot not discoverable run

.. code:: python

    deployed.deactivate_bot(bot_uid)

Permission to make a chatbot discoverable requires your developer ID to
be whitelisted. Speak to us over WhatsApp and we can grant you
permission.

Testing
-------

Tests can be run using `pytest <http://pytest.org/>`__.

::

    $ python -m pytest

Requirements
------------

Python 3.7 or later is required.

Get Involved
------------

Speak to us on
`Whatsapp <https://chat.whatsapp.com/GvdhL4f3304FxcAxZEbpi4>`__

Come join us on `Discord <https://discord.gg/YfrVwBtYWb>`__!

.. |PyPI - Python Version| image:: https://img.shields.io/pypi/pyversions/chaipy
.. |PyPI| image:: https://img.shields.io/pypi/v/chaipy



