A Python package for generating prompt bots on top of OpenAI GTP Apis.
Project description
promptbot
A Novel way of creating ChatGTP bots.
What is promptbot?
promptbot is a python package that allows you to quickly create bots using OpenAI's GPT models.
It bootstraps a prompt for you and allows you to add rules and commands to the prompt.
Why use promptbot?
promptbot is a great way to quickly create bots using OpenAI's GPT models to use in your cli applications.
It also allows you to build very specific bots that can be used to automate tasks for yourself.
Building a basic bot
Here's a simple example that shows how to build a greeting bot using promptbot:
from promptbot import PromptBot
bot = PromptBot()
bot.add_cmd("I am greeter bot. I come up with funny greetings for people.")
bot.add_rule("I can only output a JSON object.")
bot.add_rule("I must remember that my output will be consumed by python")
bot.set_example_output('{"greeting": "Hello, Johny! Awesome to meet a fellow dancer!"}')
bot.set_goal("Greet Bobby Jones")
print(bot.run_ai())
# example output :
# {"greeting": "Hey there, Bobby Jones! How's it going, big guy?"}
This will output a response from the bot based on the commands, rules and the input data. You can experiment with different inputs to get different responses.
What makes up a bot?
Commands- you add them using .add_cmd(); They define the behaviour of the bot.Rules- you add them using .add_rule(); They define the constraints of the bot.Example Output- you set it using .set_example_output(); It defines the output structure of the bot.Goal- you set it using .set_goal(); It defines what the bot should do.
That's it! With just a few lines of code, you can create your own bots using OpenAI's powerful GPT models.
Installation
You can install promptbot using pip:
pip install promptbot
Configuration
To use promptbot, you need to create a promptbot.toml file in the root of your project directory with your OpenAI API key.
[openai]
organization="org-YoUrOrGaNiZaTiOn"
api_key="sk-YourApiKeyHeRe"
model="gpt-3.5-turbo"
[promptbot]
verbose=false
There is an example promptbot.toml file in the root of this repository that you can use as a template.
Instantiation as a class
To create a bot as a class, you can do the following:
from promptbot import PromptBot
class BreakdownBot(PromptBot):
def __init__(self):
super().__init__("BreakdownBot")
self.add_cmd("I can breakdown any complex task into smaller tasks.")
self.add_rule("I must output only a data structure in JSON format")
self.add_rule("I cannot provide any dialog or request additional info")
self.add_rule("I must output only in the example format.")
self.set_example_output(f'[{{ "step": "1", "task": "The 1st task I create"}},'
f'{{ "step": "2", "task": "The 2nd task I create"}}]')
def start(self, text):
self.set_goal(text)
return self.run_ai()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file promptbot-0.0.1a4.tar.gz.
File metadata
- Download URL: promptbot-0.0.1a4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fcc46e3ef5b139771f76b1c99895eb5bad6d574b5b484d8a9d13271ea531342
|
|
| MD5 |
f7dd2cd162c9485dbc9bd165c30f4652
|
|
| BLAKE2b-256 |
6f17aa28a05604d26a0a43a635bf9cd796507a1ba63cc271e64d2a9447aa1b92
|
File details
Details for the file promptbot-0.0.1a4-py3-none-any.whl.
File metadata
- Download URL: promptbot-0.0.1a4-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
808175360d0d1b50fc61c717dfa0d6820026cac02a84e792c4a55bfa9d093181
|
|
| MD5 |
07ae805c3df3449f387bbbe8725e7af3
|
|
| BLAKE2b-256 |
3ec6308893275170b52561046f972ea839d3c018751d3427d187373e753ef2c1
|