Skip to main content

A simple Python package for creating and interacting with GPT-based chatbots

Project description

gptbots

A simple Python package for creating and interacting with GPT-based chatbots

Preliminaries

Make sure your OpenAI API key is setup (see OpenAI's Quickstart tutorial).

Usage

To create a chatbot:

  • bot = gptbots.Chatbot() creates a chatbot instance with default attributes
  • bot = gptbots.Chatbot(model, temperature, custom_instructions, chatbot_name) creates a chatbot instance with custom attributes

To chat:

  • bot.chat(prompt) prints chatbot response to string prompt

See more methods below.

Attributes

  • model : default is "gpt-3.5-turbo-1106"; see OpenAI's documentation on models for valid model names
  • temperature : default is 0.7; ranges from 0.0 to 1.0; higher generally means more creative
  • custom_instructions : default is "You are a helpful assistant."
  • chatbot_name : default is "Assistant"
  • context : contains custom instructions, user messages, and chatbot responses

Methods

  • chat(prompt) prints chatbot response to string prompt
  • chat_image(prompt, url) prints chatbot response to string prompt + image URL when using "gpt-4-vision-preview" (aka GPT-4 Turbo with vision)
  • save(file_path) saves chat history and settings to preferred file
  • load(file_path) loads chat history and settings from preferred file
  • print_messages() prints context without custom instructions in a prettier format
  • print_context() prints context in a prettier format

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

gptbots-0.1.14.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

gptbots-0.1.14-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

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