Skip to main content

The chatgpt incremental module for the retico framework

Project description

retico-chatgpt

A module that uses OpenAI's GPT-3 to generate responses to user input incrementally.

Example

import retico_core
import retico_wav2vecasr
import retico_chatgpt
import dotenv

dotenv.load_dotenv()

INSTRUCTIONS = """You are an AI assistant that is an expert in alcoholic beverages.
You know about cocktails, wines, spirits and beers.
You can provide advice on drink menus, cocktail ingredients, how to make cocktails, and anything else related to alcoholic drinks.
If you are unable to provide an answer to a question, please respond with the phrase "I'm just a simple barman, I can't help with that."
Please aim to be as helpful, creative, and friendly as possible in all of your responses.
Do not use any external URLs in your answers. Do not refer to any blogs in your answers.
You are interacting with spoken words. Be very brief and do not format your responses.
Do not use dashes in lists, and do not use any other formatting.
Write out numbers as words, for example use "one" instead of "1".
"""

mic = retico_core.audio.MicrophoneModule()
asr = retico_wav2vecasr.Wav2VecASRModule(language="en")
chatgpt = retico_chatgpt.ChatGPTDialogueModule(system_prompt=INSTRUCTIONS)
printer = retico_core.debug.TextPrinterModule()

mic.subscribe(asr)
asr.subscribe(chatgpt)
chatgpt.subscribe(printer)

retico_core.network.run(mic)

print("Network is running")
input()

retico_core.network.stop(mic)

For this example, either the environment variable OPENAI_API_KEY needs to be set or a .env file needs to be present in the current working directory with the following content:

OPENAI_API_KEY=<your-openai-api-key>

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

retico-chatgpt-0.0.1.tar.gz (8.9 kB view hashes)

Uploaded Source

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