streambotapi


Namestreambotapi JSON
Version 1.2.4 PyPI version JSON
download
home_pagehttps://github.com/dr00-eth/StreamBotAPI
SummaryA WebSocket development server for interaction with StreamBot package
upload_time2023-03-27 19:24:59
maintainer
docs_urlNone
authordr00
requires_python>=3.10,<4.0
licenseMIT
keywords chatgpt stream openai websocket flask socketio gpt python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```shell
pip install streambot-api
```

## Usage
To use StreamBotAPI, first initialize an instance of the StreamBot class from the [streambot](https://pypi.org/project/streambot) package:

```python
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:

```python
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.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dr00-eth/StreamBotAPI",
    "name": "streambotapi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "chatgpt,stream,openai,websocket,flask,socketio,gpt,python",
    "author": "dr00",
    "author_email": "andrewmeyer23@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6d/59/d668b37e1d12007cb5f8c490216859bc55a41625b074db3d66fe7d42540c/streambotapi-1.2.4.tar.gz",
    "platform": null,
    "description": "# StreamBotAPI\nStreamBotAPI is a Python package that provides a simple Flask-based API for interacting with the StreamBot which is a wrapper of OpenAI's ChatGPT.\n\n## Installation\nStreamBotAPI can be installed using pip:\n\n```shell\npip install streambot-api\n```\n\n## Usage\nTo use StreamBotAPI, first initialize an instance of the StreamBot class from the [streambot](https://pypi.org/project/streambot) package:\n\n```python\nfrom streambot import StreamBot\n\nstreambot = StreamBot(\n    openai_key='your_openai_key',\n    bot_name='your_bot_name',\n    genesis_prompt='You are a helpful translator.'\n)\n```\n\nYou can then create an instance of the StreamBotAPI class by passing in the initialized StreamBot object:\n\n```python\nfrom streambot_api import StreamBotAPI\n\nserver = StreamBotAPI(streambot, host='127.0.0.1', port=8080, origins=['http://localhost:3000', 'https://myapp.com'])\nserver.start()\n```\n\nThis will start the Flask app with the specified configuration options and routes.\n\n## Configuration Options\nThe StreamBotAPI class takes the following configuration options:\n\n* streambot: An instance of the StreamBot class from the streambot package.\n* host: The hostname to listen on. Defaults to 0.0.0.0.\n* port: The port of the web server. Defaults to 80.\n* origins: A list of allowed origins for CORS. Defaults to ['*'].\n\n## Routes\nThe following routes are available:\n\n### GET /api/getmessages/<user_id>\nReturns a JSON object containing all messages for the specified user.\n\n### POST /api/messages\nHandles incoming chat messages from the user. Expects a JSON payload with the following fields:\n\nconnection_id: A unique ID for the user.\nmessage: The message from the user.\nReturns a JSON object containing all messages for the user.\n\n### POST /api/newchat\nResets the chat history for the specified user. Expects a JSON payload with the following field:\n\nconnection_id: A unique ID for the user.\nReturns a JSON object with a value of true.\n\n## License\nThis package is licensed under the MIT license. See the LICENSE file for more details.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A WebSocket development server for interaction with StreamBot package",
    "version": "1.2.4",
    "split_keywords": [
        "chatgpt",
        "stream",
        "openai",
        "websocket",
        "flask",
        "socketio",
        "gpt",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "91ae091905f3c3512f98e678d2acc82c73e33368976e227f1d5b682bc990764f",
                "md5": "aa899bfb301598e243680a4500758ad2",
                "sha256": "f0b362d5d3542ce13b8a88774fd47802e88b1be3b7be841954e071f9dc78dd8d"
            },
            "downloads": -1,
            "filename": "streambotapi-1.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa899bfb301598e243680a4500758ad2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 4212,
            "upload_time": "2023-03-27T19:24:57",
            "upload_time_iso_8601": "2023-03-27T19:24:57.903716Z",
            "url": "https://files.pythonhosted.org/packages/91/ae/091905f3c3512f98e678d2acc82c73e33368976e227f1d5b682bc990764f/streambotapi-1.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d59d668b37e1d12007cb5f8c490216859bc55a41625b074db3d66fe7d42540c",
                "md5": "aea5584d6fa50ca7a07c3b2a68f89940",
                "sha256": "14586b3b3662fc09a83ab530f06ecd3748be06756fde6f0414257a30797105bc"
            },
            "downloads": -1,
            "filename": "streambotapi-1.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "aea5584d6fa50ca7a07c3b2a68f89940",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 3894,
            "upload_time": "2023-03-27T19:24:59",
            "upload_time_iso_8601": "2023-03-27T19:24:59.434419Z",
            "url": "https://files.pythonhosted.org/packages/6d/59/d668b37e1d12007cb5f8c490216859bc55a41625b074db3d66fe7d42540c/streambotapi-1.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-27 19:24:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dr00-eth",
    "github_project": "StreamBotAPI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "streambotapi"
}
        
Elapsed time: 0.04992s