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:
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.
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.
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.
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.
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.
Metadata
Release files for streambot 1.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| streambot-1.1.9.tar.gz | 3.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streambot-1.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / streambot-1.1.9.tar.gz
| Download URL | streambot-1.1.9.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe33fb118a69a910bcac5f0e44dfe21f9c3980a8395dad896e1eb20fba10c109
|
|
BLAKE2b-256 checksum How to use checksums |
3a5ad6ac8bf934a9344e1059d71ccf00706732e1ac6496539a8f0c3a3fd58578
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.10.10 Windows/10
|
Release files / streambot-1.1.9-py3-none-any.whl
| Download URL | streambot-1.1.9-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fe73144f1cbb4820efa53e3bb839e36d2fe5d31dc95ee6061f924f80d67d9cf
|
|
BLAKE2b-256 checksum How to use checksums |
17fa31affecb922391e0695d520030ae0a26da1c5a6baf3c33bd54a3769b5d44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.10.10 Windows/10
|
Security for streambot 1.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.