Metadata-Version: 2.1
Name: streambotapi
Version: 1.0.13
Summary: A WebSocket development server for interaction with StreamBot package
Home-page: https://github.com/dr00-eth/StreamBotAPI
License: MIT
Keywords: chatgpt,stream,openai,websocket,flask,socketio,gpt,python
Author: dr00
Author-email: andrewmeyer23@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: flask (>=2.2.3,<3.0.0)
Requires-Dist: flask-cors (>=3.0.10,<4.0.0)
Requires-Dist: flask-socketio (>=5.3.2,<6.0.0)
Requires-Dist: streambot (>=1.1.3,<2.0.0)
Project-URL: Repository, https://github.com/dr00-eth/StreamBotAPI
Description-Content-Type: text/markdown

# 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.
