Skip to main content

A WebSocket development server for interaction with StreamBot package

Project description

StreamBotAPI

StreamBotAPI is a Python package that provides a simple Flask-based API for interacting with the StreamBot which is a wrapper of OpenAI's ChatGPT.

Installation

StreamBotAPI can be installed using pip:

pip install streambot-api

Usage

To use StreamBotAPI, first initialize an instance of the StreamBot class from the streambot package:

from streambot import StreamBot

streambot = StreamBot(
    openai_key='your_openai_key',
    bot_name='your_bot_name',
    genesis_prompt='You are a helpful translator.'
)

You can then create an instance of the StreamBotAPI class by passing in the initialized StreamBot object:

from streambot_api import StreamBotAPI

server = StreamBotAPI(streambot, host='127.0.0.1', port=8080, origins=['http://localhost:3000', 'https://myapp.com'])
server.start()

This will start the Flask app with the specified configuration options and routes.

Configuration Options

The StreamBotAPI class takes the following configuration options:

  • streambot: An instance of the StreamBot class from the streambot package.
  • host: The hostname to listen on. Defaults to 0.0.0.0.
  • port: The port of the web server. Defaults to 80.
  • origins: A list of allowed origins for CORS. Defaults to ['*'].

Routes

The following routes are available:

GET /api/getmessages/<user_id>

Returns a JSON object containing all messages for the specified user.

POST /api/messages

Handles incoming chat messages from the user. Expects a JSON payload with the following fields:

connection_id: A unique ID for the user. message: The message from the user. Returns a JSON object containing all messages for the user.

POST /api/newchat

Resets the chat history for the specified user. Expects a JSON payload with the following field:

connection_id: A unique ID for the user. Returns a JSON object with a value of true.

License

This package is licensed under the MIT license. See the LICENSE file for more details.

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

streambotapi-1.1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

streambotapi-1.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file streambotapi-1.1.1.tar.gz.

File metadata

  • Download URL: streambotapi-1.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Darwin/21.6.0

File hashes

Hashes for streambotapi-1.1.1.tar.gz
Algorithm Hash digest
SHA256 d55b855ffd254403557b1f2403b77271b44b0de8346cac106d03171b80529ae0
MD5 3dd27db94e8bf5abb6b726136d6dcb06
BLAKE2b-256 985a4fdf7bbecc79d5d35b95b3a409a0c7a5ea7b1a1b2e08d9f716b2147d336b

See more details on using hashes here.

File details

Details for the file streambotapi-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: streambotapi-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Darwin/21.6.0

File hashes

Hashes for streambotapi-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 524736a509192858ddc5f8ba7cd599ca660d438fa397bab79df1dac42442d625
MD5 f0dc1f0fbf490484f46d9107ef315bcd
BLAKE2b-256 524e2bf6782de78b5b7da04f8d34225d7c9b0d4c404c0694821c0ccf0c2eafa1

See more details on using hashes here.

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