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}]]
                                                                      [--text-to-speech [{pyttsx3}]]

options:
  -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.
  --text-to-speech [{pyttsx3}]      Text to speech model to use. Without additional arguments, defaults to pyttsx3. 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 --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()

NOTE: Recording quality is very sensitive to your hardware. Things can go wrong, for example, if the input volume on your microphone is too loud.

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.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

chat_toolkit-1.1.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chat_toolkit-1.1.1.tar.gz
  • Upload date:
  • Size: 13.7 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.1.tar.gz
Algorithm Hash digest
SHA256 63857b1b0a119ec46f8ddde9cdc04f23442f9badca97446ea4cdbb22b858087c
MD5 dc6d8af6173b84e7060f8ad0f011a323
BLAKE2b-256 b8717155ca14be1e11e9533fbdf1fc4f244c271f4e21b39ef176afbb3ea46a46

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chat_toolkit-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5fe80878faba25d01f7eb309203eb3170ec5e231af7b8802fb2aab75b9cbda5
MD5 846fde70ebcedf8481fee3e720a24989
BLAKE2b-256 d070792d8cda8694a40adab5b9a3a96514c2788b04085b9b4010d4add3d962e4

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