Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OVOS OpenAI Plugin

This package uses the OpenAI Chat Completions API to provide OpenAI-compatible plugins for OpenVoiceOS. It works with any server that exposes the OpenAI /chat/completions contract, such as OpenAI, ollama, llama.cpp, vLLM, or LocalAI. Point api_url at the server's /v1 base to use it.

This package provides:

Plugin Entry point Type Purpose
ovos-chat-openai-plugin opm.agents.chat ChatEngine Multi-turn chat agent (native tool/function calling) for ovos-persona
ovos-openai-rag-memory-plugin opm.agents.memory AgentContextManager RAG memory: inject vector-store context from an ovos-persona-server
ovos-summarizer-openai-plugin opm.agents.summarizer SummarizerEngine Summarize text for other plugins/skills
ovos-translate-openai-plugin opm.lang.translate LanguageTranslator LLM-backed text translation
ovos-lang-detect-openai-plugin opm.lang.detect LanguageDetector LLM-backed language detection
ovos-dialog-transformer-openai-plugin opm.transformer.dialog DialogTransformer Rewrite OVOS dialogs just before TTS in ovos-audio

Breaking change: solver plugins are deprecated in ovos-plugin-manager. This release migrates from the legacy QuestionSolver/ChatMessageSolver to the new agents framework (AbstractAgentEngine). The old ovos-solver-openai-plugin entry point and the OpenAIChatCompletionsSolver and OpenAIPersonaSolver classes have been removed. Personas must now reference ovos-chat-openai-plugin. This release requires ovos-plugin-manager>=2.2.3a1 and ovos-persona>=0.9.0a1.

Install

pip install ovos-openai-plugin

Persona Usage

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

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

The solvers key name is kept for backwards compatibility with persona JSON files. It now accepts agent plugin names (chat engines) in addition to legacy solvers.

Say "Chat with {name_from_json}" to enable it. See the ovos-persona README for more details.

This plugin also provides a default "Remote LLama" demo persona, pointing to a public server hosted by @goldyfruit.

RAG memory

ovos-openai-rag-memory-plugin (PersonaServerRAGMemory) is a persona memory plugin. Before each turn, it searches a vector store on an ovos-persona-server and injects the retrieved chunks into the conversation context. The persona's chat engine then answers. This plugin composes with any chat backend instead of owning the chat round-trip.

Set it as the persona's memory_module:

{
  "name": "kb-assistant",
  "solvers": ["ovos-chat-openai-plugin"],
  "memory_module": "ovos-openai-rag-memory-plugin",
  "ovos-openai-rag-memory-plugin": {
    "api_url": "http://localhost:8337/openai/v1",
    "vector_store_id": "vs_...",
    "inject_mode": "system",
    "retrieval": {"max_num_results": 5}
  }
}

inject_mode selects how retrieved context enters the prompt: system (separate system message, default), system_prompt, developer, user, or tool (a synthetic search_knowledge_base tool-call result). Retrieval (max_num_results, min_score, query_mode) and context formatting are configurable. See the rag_memory module docstring for details. This feature requires an ovos-persona version that passes config to memory plugins.

Dialog Transformer

Rewrite text dynamically based on a persona, such as simplifying explanations or mimicking a tone.

Example:

  • 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."

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

"dialog_transformers": {
    "ovos-dialog-transformer-openai-plugin": {
        "api_url": "https://api.openai.com/v1",
        "key": "sk-xxxx",
        "model": "gpt-4o-mini",
        "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 actual dialog text is appended after rewrite_prompt in the request.

Direct Usage

from ovos_openai_plugin import OpenAIChatEngine
from ovos_plugin_manager.templates.agents import AgentMessage, MessageRole

bot = OpenAIChatEngine({
    "key": "sk-XXX",
    "model": "gpt-4o-mini",
    "system_prompt": "You are helpful, creative, clever, and very friendly",
})

# one-shot answer
print(bot.get_response("describe quantum mechanics in simple terms"))

# multi-turn chat
reply = bot.continue_chat([
    AgentMessage(MessageRole.USER, "what is the capital of France?")
])
print(reply.content)

# stream complete sentences (TTS friendly)
for sentence in bot.stream_sentences([AgentMessage(MessageRole.USER, "tell me a short story")]):
    print(sentence)

Translation and summarization:

from ovos_openai_plugin import OpenAITextTranslator, OpenAISummarizer

tx = OpenAITextTranslator({"key": "sk-XXX", "model": "gpt-4o-mini"})
print(tx.translate("hello world", target="es-es"))

summary = OpenAISummarizer({"key": "sk-XXX", "model": "gpt-4o-mini"})
print(summary.summarize("a very long document ..."))

Remote Persona / Proxies

You can run any persona behind an OpenAI-compatible server with ovos-persona-server. This moves the workload to a standalone server, either for performance or to keep API keys in a single safe place. Then configure this plugin to point at your persona server as if it were OpenAI.

Documentation


Credits

Developed by TigreGótico for OpenVoiceOS.

NGI0 Commons Fund

This project was funded through the NGI0 Commons Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101135429.

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.8a2.tar.gz (26.1 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.8a2-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file ovos_openai_plugin-2.0.8a2.tar.gz.

File metadata

  • Download URL: ovos_openai_plugin-2.0.8a2.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ovos_openai_plugin-2.0.8a2.tar.gz
Algorithm Hash digest
SHA256 e72ed37e5dc19a9b7f4028924095123ecb0ce465bf26b478635a77b34e052819
MD5 69821d306bc4fc066f9b888b10545931
BLAKE2b-256 4867a04adf048319006802b5f94f620d261b8445c944a270344ec9570eccac93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ovos_openai_plugin-2.0.8a2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a4f7b37331609a9fbd9e63053182add28f4d5207a1ea129bfd65366e3e7efc4
MD5 bbd0fad080a0620a292c1d7d0bad2167
BLAKE2b-256 65a01b5c92b949c568c09d13a3cc50065275a4951d442763aa647ea9e60a6602

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 Sentry Error logging StatusPage Status page