# StreamBot
StreamBot is a Python package that allows you to create a chatbot that uses OpenAI's GPT-3 API to generate responses in real-time.
## Installation
To install StreamBot, simply run:
```shell
pip install streambot
```
## Usage
To create a StreamBot, you'll need to provide an OpenAI API key, a name for your bot, and a "genesis prompt" - the initial `system` message that your bot will act like.
```python
from streambot import StreamBot
api_key = "YOUR_OPENAI_API_KEY"
bot_name = "MyBot"
genesis_prompt = "You are a helpful English to Spanish translator"
bot = StreamBot(api_key, bot_name, genesis_prompt)
```
Once you have created your bot, you can initiate output with the chat method. The chat method takes a list of messages managed within the StreamBot class as input and prints the stream of tokens as well as optionally returning a string containing the bot response into a variable.
The StreamBot constructor takes in an optional OpenAI URL (in case they change it) and an override for the Model value as they may change that in the near future as well. Also see below for additional configuration overrides as part of the StreamBotConfig you can pass in.
```python
prompt = input("Me: ")
bot.add_message(prompt)
bot.chat()
```
You can also add messages to your bot's message history using the add_message method. The add_message method defaults the role to "user" if none is provided.
```python
bot.add_message("Hello, how can I help you today?", role="assistant")
bot.add_message("Hi there!")
bot.add_message("What's your name?", role="assistant")
```
## Configuration
StreamBot also allows you to configure various settings for your bot, such as the temperature and maximum number of tokens used by the GPT-3 API. To do this, you can create a StreamBotConfig object and pass it to the StreamBot constructor.
```python
from streambot import StreamBot, StreamBotConfig
api_key = "YOUR_OPENAI_API_KEY"
bot_name = "MyBot"
genesis_prompt = "Hello, how can I help you today?"
config = StreamBotConfig(temperature=0.5, max_tokens=500)
bot = StreamBot(api_key, bot_name, genesis_prompt, config=config)
```
## Contributing
If you'd like to contribute to StreamBot, please feel free to submit a pull request or open an issue on the GitHub repository.
## License
StreamBot is licensed under the MIT License. See LICENSE for more information.
Raw data
{
"_id": null,
"home_page": "https://github.com/dr00-eth/StreamBot",
"name": "streambot",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10.0,<4",
"maintainer_email": "",
"keywords": "chatgpt,stream,openai",
"author": "dr00",
"author_email": "andrewmeyer23@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6f/a9/cef6eb1d09c761b44b54e3240852b15e4c05263a126e8e573baba6443afe/streambot-1.1.7.tar.gz",
"platform": null,
"description": "# StreamBot\nStreamBot is a Python package that allows you to create a chatbot that uses OpenAI's GPT-3 API to generate responses in real-time.\n\n## Installation\nTo install StreamBot, simply run:\n\n```shell\npip install streambot\n```\n\n## Usage\nTo create a StreamBot, you'll need to provide an OpenAI API key, a name for your bot, and a \"genesis prompt\" - the initial `system` message that your bot will act like.\n\n```python\nfrom streambot import StreamBot\n\napi_key = \"YOUR_OPENAI_API_KEY\"\nbot_name = \"MyBot\"\ngenesis_prompt = \"You are a helpful English to Spanish translator\"\n\nbot = StreamBot(api_key, bot_name, genesis_prompt)\n```\n\nOnce you have created your bot, you can initiate output with the chat method. The chat method takes a list of messages managed within the StreamBot class as input and prints the stream of tokens as well as optionally returning a string containing the bot response into a variable.\n\nThe StreamBot constructor takes in an optional OpenAI URL (in case they change it) and an override for the Model value as they may change that in the near future as well. Also see below for additional configuration overrides as part of the StreamBotConfig you can pass in.\n\n\n```python\nprompt = input(\"Me: \")\nbot.add_message(prompt)\nbot.chat()\n```\n\nYou can also add messages to your bot's message history using the add_message method. The add_message method defaults the role to \"user\" if none is provided.\n\n```python\nbot.add_message(\"Hello, how can I help you today?\", role=\"assistant\")\nbot.add_message(\"Hi there!\")\nbot.add_message(\"What's your name?\", role=\"assistant\")\n```\n\n## Configuration\nStreamBot also allows you to configure various settings for your bot, such as the temperature and maximum number of tokens used by the GPT-3 API. To do this, you can create a StreamBotConfig object and pass it to the StreamBot constructor.\n\n```python\nfrom streambot import StreamBot, StreamBotConfig\n\napi_key = \"YOUR_OPENAI_API_KEY\"\nbot_name = \"MyBot\"\ngenesis_prompt = \"Hello, how can I help you today?\"\n\nconfig = StreamBotConfig(temperature=0.5, max_tokens=500)\n\nbot = StreamBot(api_key, bot_name, genesis_prompt, config=config)\n```\n\n## Contributing\nIf you'd like to contribute to StreamBot, please feel free to submit a pull request or open an issue on the GitHub repository.\n\n## License\nStreamBot is licensed under the MIT License. See LICENSE for more information.",
"bugtrack_url": null,
"license": "MIT",
"summary": "An OpenAI ChatGPT wrapper to simplify streaming of token responses to give the writing effect.",
"version": "1.1.7",
"split_keywords": [
"chatgpt",
"stream",
"openai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6436e476a124e383e87f956e0e0f472b0e0f0fe81769928520a7bc42f484c360",
"md5": "b7bbd870f175ccefdde3b2ce49285d44",
"sha256": "57801c8c59c839e3077944e735c32c17c862b41ebadb3cd34f2b3c1d7427eda4"
},
"downloads": -1,
"filename": "streambot-1.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b7bbd870f175ccefdde3b2ce49285d44",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10.0,<4",
"size": 3892,
"upload_time": "2023-03-27T15:20:26",
"upload_time_iso_8601": "2023-03-27T15:20:26.878028Z",
"url": "https://files.pythonhosted.org/packages/64/36/e476a124e383e87f956e0e0f472b0e0f0fe81769928520a7bc42f484c360/streambot-1.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6fa9cef6eb1d09c761b44b54e3240852b15e4c05263a126e8e573baba6443afe",
"md5": "454ae7e12da2fdb996f29c3c8039bd72",
"sha256": "a88e939af6df4b04742a2bbca2820562bd8c15b373e134ea979ee3192b6f7b6e"
},
"downloads": -1,
"filename": "streambot-1.1.7.tar.gz",
"has_sig": false,
"md5_digest": "454ae7e12da2fdb996f29c3c8039bd72",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10.0,<4",
"size": 3644,
"upload_time": "2023-03-27T15:20:29",
"upload_time_iso_8601": "2023-03-27T15:20:29.131000Z",
"url": "https://files.pythonhosted.org/packages/6f/a9/cef6eb1d09c761b44b54e3240852b15e4c05263a126e8e573baba6443afe/streambot-1.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-27 15:20:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "dr00-eth",
"github_project": "StreamBot",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "streambot"
}