Skip to main content

Extensible package for creating machine learning powered chatbots.

Project description

Chat Toolkit

Extensible package for creating machine learning powered chatbots.

Package supports Linux and Windows. Mac is not explicitly supported, although it is possible some, or many parts of this will still work.

NOTE: Some components require additional dependencies. See below for more information.

Installation

pip install -U chat-toolkit

Quick Usage

The main script has been provided for convenience. This allows you to easily start a conversation in your terminal.

Usage:

usage: A script for quickly starting a conversation in your terminal. [-h] [--chatbot {chatgpt}] [--speech-to-text [{whisper}]]

optional arguments:
  -h, --help                        show this help message and exit
  --chatbot {chatgpt}               Chatbot to use. Default: chatgpt.
  --speech-to-text [{whisper}]      Speech to text model to use. Without additional arguments, defaults to whisper. Defaults to None when argument is not present.

To quickly start up a Text to Text conversation (default models):

python -m chat_toolkit

To quickly start up a Speech to Text conversation (default models):

python -m chat_toolkit --chatbot --speech-to-text

To quickly start up a Text to Speech conversation (default models):

python -m chat_toolkit --text-to-speech

To quickly start up a Speech to Speech conversation (default models):

python -m chat_toolkit --speech-to-text --text-to-speech

Components

Components are ML powered objects that accomplish tasks. Components should be able to estimate session costs. You can build your own components to use in isolation or as part of an orchestrator object.

NOTE: Cost estimates are based on pricing rates provided by the user. Users should do their own due dilligence and are responsible for their own costs and estimations.

Advanced Usage: You can create your own component types by subclassing chat_toolkit.base.ComponentBase

Chatbots

These components send and receive text messages.

Class Requirements Model Default Cost Reference
OpenAIChatBot OPENAI_API_KEY gpt-3.5-turbo (ChatGPT) $0.002/1k tokens OpenAI

Basic Usage:

from chat_toolkit import OpenAIChatBot

chatbot = OpenAIChatBot()
chatbot.prompt_chatbot("You are a butler named Jeeves.")
chatbot_response, _ = chatbot.send_message("Hello, what is your name?")

Advanced Usage: You can create your own chatbot components by subclassing chat_toolkit.base.ChatbotComponentBase

Speech to Text

These components record speech and transform it into text.

Class Requirements Model Default Cost Reference
OpenAISpeechToText OPENAI_API_KEY, libportaudio2 (linux) whiper-1 $0.006/1k tokens OpenAI

Basic Usage:

from chat_toolkit import OpenAISpeechToText

speech_to_text = OpenAISpeechToText()
text, _ = speech_to_text.transcribe_speech()

Advanced Usage: You can create your own speech to text components by subclassing chat_toolkit.base.SpeechToTextComponentBase

Text to Speech

These components say pieces of text.

ClassTextToSpeech Requirements Model Default Cost Reference
Pyttsx3TextToSpeech espeak (linux) n/a Free Pyttsx3

NOTE: Pyttsx3TextToSpeech currently defaults to English, but it may be configured using set_pyttsx3_property() method. See pyttsx3's documentation for more information.

Basic Usage:

from chat_toolkit import Pyttsx3TextToSpeech

text_to_speech = Pyttsx3TextToSpeech()
text_to_speech.say_text("hello")

Advanced Usage: You can create your own text to speech components by subclassing chat_toolkit.base.TextToSpeechComponentBase

Orchestrator

The Orchestrator class also allow you to chat from the terminal. The Orchestrator should work such that you can replace any component with another of the same type, or a custom-built one, and still be able to use the orchestrator.

Text to Text

Basic usage:

from chat_toolkit import OpenAIChatBot
from chat_toolkit import Orchestrator

chat = Orchestrator(OpenAIChatBot())
chat.terminal_conversation()

Speech to Text

Basic usage:

from chat_toolkit import OpenAIChatBot, OpenAISpeechToText
from chat_toolkit import Orchestrator

chat = Orchestrator(OpenAIChatBot(), OpenAISpeechToText())
chat.terminal_conversation()

Text to Speech

Basic usage:

from chat_toolkit import OpenAIChatBot, Pyttsx3TextToSpeech
from chat_toolkit import Orchestrator

chat = Orchestrator(OpenAIChatBot(), text_to_speech_component=Pyttsx3TextToSpeech())
chat.terminal_conversation()

Speech to Speech

Basic usage:

from chat_toolkit import OpenAIChatBot, OpenAISpeechToText, Pyttsx3TextToSpeech
from chat_toolkit import Orchestrator

chat = Orchestrator(OpenAIChatBot(), OpenAISpeechToText(), Pyttsx3TextToSpeech())
chat.terminal_conversation()

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

chat_toolkit-1.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

chat_toolkit-1.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file chat_toolkit-1.1.0.tar.gz.

File metadata

  • Download URL: chat_toolkit-1.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.0 Linux/5.15.0-1034-azure

File hashes

Hashes for chat_toolkit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 48b339b59a2e63679001227c9fc8496281a23717010796a26aaff484946037dc
MD5 6bf9a18e1db0f0562c4533cc41d32efe
BLAKE2b-256 a08e2c83aa8de8c2d99ce4d76a8ab205f0d38f49eee2778042f831a7e94a77af

See more details on using hashes here.

File details

Details for the file chat_toolkit-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: chat_toolkit-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.0 Linux/5.15.0-1034-azure

File hashes

Hashes for chat_toolkit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9469195d48aa31888cfc5b60a280a0fe242d70a9619ee02054f49dd2c0f60cae
MD5 769b3d04e75a8e884fcb245fc4955d9c
BLAKE2b-256 fdca8467fbdf2769773244a389d1fc3aea12744ff3c0c05417b4a182ea3bd119

See more details on using hashes here.

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