Skip to main content

A question solver plugin for ovos

Project description

OVOS OpenAI Plugin

Leverages OpenAI Completions API to provide the following ovos plugins:

  • ovos-solver-openai-plugin for usage with ovos-persona (and in older ovos releases with ovos-skill-fallback-chatgpt)
  • ovos-dialog-transformer-openai-plugin to rewrite OVOS dialogs just before TTS executes in ovos-audio
  • ovos-summarizer-openai-plugin to summarize text, not used directly but provided for consumption by other plugins/skills

Install

pip install ovos-openai-plugin

Persona Usage

To create your own persona using a OpenAI compatible server create a .json in ~/.config/ovos_persona/llm.json:

{
  "name": "My Local LLM",
  "solvers": [
    "ovos-solver-openai-plugin"
  ],
  "ovos-solver-openai-plugin": {
    "api_url": "https://llama.smartgic.io/v1",
    "key": "sk-xxxx",
    "system_prompt": "You are helping assistant who gives very short and factual answers in maximum twenty words and you don't use emojis"
  }
}

Then say "Chat with {name_from_json}" to enable it, more details can be found in ovos-persona README

This plugins also provides a default "Remote LLama" demo persona, it points to a public server hosted by @goldyfruit.

Dialog Transformer

you can rewrite text dynamically based on specific personas, such as simplifying explanations or mimicking a specific tone.

Example Usage:

  • rewrite_prompt: "rewrite the text as if you were explaining it to a 5-year-old"
  • Input: "Quantum mechanics is a branch of physics that describes the behavior of particles at the smallest scales."
  • Output: "Quantum mechanics is like a special kind of science that helps us understand really tiny things."

Examples of rewrite_prompt Values:

  • "rewrite the text as if it was an angry old man speaking"
  • "Add more 'dude'ness to it"
  • "Explain it like you're teaching a child"

To enable this plugin, add the following to your mycroft.conf:

"dialog_transformers": {
    "ovos-dialog-transformer-openai-plugin": {
        "system_prompt": "Your task is to rewrite text as if it was spoken by a different character",
        "rewrite_prompt": "rewrite the text as if you were explaining it to a 5-year-old"
    }
}

💡 the user utterance will be appended after rewrite_prompt for the actual query

Direct Usage

from ovos_solver_openai_persona import OpenAIPersonaSolver

bot = OpenAIPersonaSolver({"key": "sk-XXX",
                           "persona": "helpful, creative, clever, and very friendly"})
print(bot.get_spoken_answer("describe quantum mechanics in simple terms"))
# Quantum mechanics is a branch of physics that deals with the behavior of particles on a very small scale, such as atoms and subatomic particles. It explores the idea that particles can exist in multiple states at once and that their behavior is not predictable in the traditional sense.
print(bot.spoken_answer("Quem encontrou o caminho maritimo para o Brazil", lang="pt-pt"))
# Explorador português Pedro Álvares Cabral é creditado com a descoberta do Brasil em 1500

Remote Persona / Proxies

You can run any persona behind a OpenAI compatible server via ovos-persona-server.

This allows you to offload the workload to a standalone server, either for performance reasons or to keep api keys in a single safe place.

Then just configure this plugin to point to your persona server like it was OpenAI

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

ovos-openai-plugin-2.0.2a2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ovos_openai_plugin-2.0.2a2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file ovos-openai-plugin-2.0.2a2.tar.gz.

File metadata

  • Download URL: ovos-openai-plugin-2.0.2a2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for ovos-openai-plugin-2.0.2a2.tar.gz
Algorithm Hash digest
SHA256 ae0d50636628a348d4709fac59ace6b8ea88d74e8064da058fcb522a1ff50fbf
MD5 307f1c08bb3d6eed4800f68bd8a1fdef
BLAKE2b-256 6fd0f5f138ec68679e31c9617698927e5911c009a7b2e2c2cdba1f59ba1db200

See more details on using hashes here.

File details

Details for the file ovos_openai_plugin-2.0.2a2-py3-none-any.whl.

File metadata

File hashes

Hashes for ovos_openai_plugin-2.0.2a2-py3-none-any.whl
Algorithm Hash digest
SHA256 7eadf10b37f28023a61ce1001e7b35faffbe7ebdb33f2789ec80606a9be3b85f
MD5 9ad167b94e5d5097768517c84864017b
BLAKE2b-256 520b531f14e680f9830bc2e42072bf01eff16d0319a7bd72909150f685cfa715

See more details on using hashes here.

Supported by

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