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.

It can be grouped together as plugins to achieve more complex tasks.

Warning: This is an experimental project and is not ready for production use.

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

if you want to also run the examples you need to install the example_requirements.txt file from the root directory of this repository:

pip install -r example_requirements.txt

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.2a1.tar.gz (6.4 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.2a1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file promptbot-0.0.2a1.tar.gz.

File metadata

  • Download URL: promptbot-0.0.2a1.tar.gz
  • Upload date:
  • Size: 6.4 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.2a1.tar.gz
Algorithm Hash digest
SHA256 a8aa0f1efaef45baf54b9c3a9db2edbb4a39d4bc354f91f4253a62629a498759
MD5 c026e19988cd88a2b73430c89188f51e
BLAKE2b-256 a40cbb0c1c462599b409aae8ea44b8908832af0528849a34bcc4f0c5f2279d2c

See more details on using hashes here.

File details

Details for the file promptbot-0.0.2a1-py3-none-any.whl.

File metadata

  • Download URL: promptbot-0.0.2a1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 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.2a1-py3-none-any.whl
Algorithm Hash digest
SHA256 265630b61961a1a7e0dfa3738b670afe5f0a15b895dc51752b9cb21aaead772e
MD5 36ad98635171d144a825f89699e02e73
BLAKE2b-256 40b5e434a4d0df49de4bbaacb215118ab823c6fb63ffca6dd867c3298545a90f

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