Skip to main content

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?

  1. Commands - you add them using .add_cmd(); They define the behaviour of the bot.
  2. Rules - you add them using .add_rule(); They define the constraints of the bot.
  3. Example Output - you set it using .set_example_output(); It defines the output structure of the bot.
  4. 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()

Documentation

You can find the documentation for promptbot in the /docs directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptbot-0.0.1a5.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptbot-0.0.1a5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file promptbot-0.0.1a5.tar.gz.

File metadata

  • Download URL: promptbot-0.0.1a5.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for promptbot-0.0.1a5.tar.gz
Algorithm Hash digest
SHA256 d52e0a810e35b16d9b7f523ec81fb6a1f14d5211e4c196301e7f299514499c29
MD5 737bbbff1b136be4cc5cd1e08081eb7c
BLAKE2b-256 48a5de8fb9481b737e4340aadae15455ccdbb2719bc6e8b99ea62f7648849a59

See more details on using hashes here.

File details

Details for the file promptbot-0.0.1a5-py3-none-any.whl.

File metadata

  • Download URL: promptbot-0.0.1a5-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.11.3

File hashes

Hashes for promptbot-0.0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 05853f4db8357dd33a5a462ecb9be90bd7fcf9215ef564dd2964cdd020b57dc7
MD5 f17532ad5317e33fa50e447a09381a76
BLAKE2b-256 8834012931fae20fdb25d17c0de9baeacf4870a75d872425bbe27af64b574111

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page