a python module that makes creating chatbots easyer.
- install the open ai package using
pip install openai
- copy the openAI_chatbots folder in to your project
- have fun with the module (:
a demo of the module is included with this repo:demo
read the file <filename><br>
write "<your text>" to the file <filename>
import openAI_chatbots as chat
chat.setApiKey("<your api key>")
# Create a chatbot instance
# You can provide a system prompt and a prompt prefix if desired
# Optional: <system prompt>, <prompt prefix>
chatbot = chat.chatbot(system_prompt="<system prompt>", prompt_prefix="<prompt prefix>")
creating a function calling object:
functions = chat.GPT_Functions.GPT_functions()
adding a function to the function calling object:
@functions.defineFunction("<description of your function>",
{
"type":"string",
"name":"<name of the parameter>",
"description":"<description of the parameter>"
},...
)
def yourFunction(parameter1,...):
return "<return value>"
binding the function calling object to a chatbot:
chatbot.setGptFunctions(functions)
output = chatbot.chat("<prompt>")
output = chatbot.generate()