# <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/robot.svg' card_color='#40DBB0' width='50' height='50' style='vertical-align:bottom'/> OVOS OpenAI Plugin
Leverages [OpenAI Completions API](https://platform.openai.com/docs/api-reference/completions/create) to provide the following ovos plugins: 
- `ovos-solver-openai-plugin` for usage with [ovos-persona](https://github.com/OpenVoiceOS/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](https://github.com/OpenVoiceOS/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`:  
```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",
    "model": "llama3.1:8b"
  }
}
```
Then say "Chat with {name_from_json}" to enable it, more details can be found in [ovos-persona](https://github.com/OpenVoiceOS/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`:  
```json
"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
```python
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](https://github.com/OpenVoiceOS/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
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": "https://github.com/OpenVoiceOS/ovos-solver-plugin-openai-persona",
    "name": "ovos-openai-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "ovos plugin utterance fallback query",
    "author": "jarbasai",
    "author_email": "jarbasai@mailfence.com",
    "download_url": "https://files.pythonhosted.org/packages/68/40/812805e54ac75357609ddfcd379d43bffbffe37d10d1c0826422dca52095/ovos-openai-plugin-2.0.5.tar.gz",
    "platform": null,
    "description": "# <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/robot.svg' card_color='#40DBB0' width='50' height='50' style='vertical-align:bottom'/> OVOS OpenAI Plugin\n\nLeverages [OpenAI Completions API](https://platform.openai.com/docs/api-reference/completions/create) to provide the following ovos plugins: \n- `ovos-solver-openai-plugin` for usage with [ovos-persona](https://github.com/OpenVoiceOS/ovos-persona) (and in older ovos releases with [ovos-skill-fallback-chatgpt]())\n- `ovos-dialog-transformer-openai-plugin` to rewrite OVOS dialogs just before TTS executes in [ovos-audio](https://github.com/OpenVoiceOS/ovos-audio)\n- `ovos-summarizer-openai-plugin` to summarize text, not used directly but provided for consumption by other plugins/skills\n\n## Install\n\n`pip install ovos-openai-plugin`\n\n## Persona Usage\n\nTo create your own persona using a OpenAI compatible server create a .json in `~/.config/ovos_persona/llm.json`:  \n```json\n{\n  \"name\": \"My Local LLM\",\n  \"solvers\": [\n    \"ovos-solver-openai-plugin\"\n  ],\n  \"ovos-solver-openai-plugin\": {\n    \"api_url\": \"https://llama.smartgic.io/v1\",\n    \"key\": \"sk-xxxx\",\n    \"system_prompt\": \"You are helping assistant who gives very short and factual answers in maximum twenty words and you don't use emojis\",\n    \"model\": \"llama3.1:8b\"\n  }\n}\n```\n\nThen say \"Chat with {name_from_json}\" to enable it, more details can be found in [ovos-persona](https://github.com/OpenVoiceOS/ovos-persona) README\n\nThis plugins also provides a default \"Remote LLama\" demo persona, it points to a public server hosted by @goldyfruit.\n\n## Dialog Transformer\n\nyou can rewrite text dynamically based on specific personas, such as simplifying explanations or mimicking a specific tone.  \n\n#### Example Usage:\n- **`rewrite_prompt`:** `\"rewrite the text as if you were explaining it to a 5-year-old\"`  \n- **Input:** `\"Quantum mechanics is a branch of physics that describes the behavior of particles at the smallest scales.\"`  \n- **Output:** `\"Quantum mechanics is like a special kind of science that helps us understand really tiny things.\"`  \n\nExamples of `rewrite_prompt` Values:\n- `\"rewrite the text as if it was an angry old man speaking\"`  \n- `\"Add more 'dude'ness to it\"`  \n- `\"Explain it like you're teaching a child\"`  \n\nTo enable this plugin, add the following to your `mycroft.conf`:  \n\n```json\n\"dialog_transformers\": {\n    \"ovos-dialog-transformer-openai-plugin\": {\n        \"system_prompt\": \"Your task is to rewrite text as if it was spoken by a different character\",\n        \"rewrite_prompt\": \"rewrite the text as if you were explaining it to a 5-year-old\"\n    }\n}\n```\n\n> \ud83d\udca1 the user utterance will be appended after `rewrite_prompt` for the actual query\n\n## Direct Usage\n\n```python\nfrom ovos_solver_openai_persona import OpenAIPersonaSolver\n\nbot = OpenAIPersonaSolver({\"key\": \"sk-XXX\",\n                           \"persona\": \"helpful, creative, clever, and very friendly\"})\nprint(bot.get_spoken_answer(\"describe quantum mechanics in simple terms\"))\n# 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.\nprint(bot.spoken_answer(\"Quem encontrou o caminho maritimo para o Brazil\", lang=\"pt-pt\"))\n# Explorador portugu\u00eas Pedro \u00c1lvares Cabral \u00e9 creditado com a descoberta do Brasil em 1500\n\n```\n\n## Remote Persona / Proxies\n\nYou can run any persona behind a OpenAI compatible server via [ovos-persona-server](https://github.com/OpenVoiceOS/ovos-persona-server). \n\nThis allows you to offload the workload to a standalone server, either for performance reasons or to keep api keys in a single safe place.\n\nThen just configure this plugin to point to your persona server like it was OpenAI\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A question solver plugin for ovos",
    "version": "2.0.5",
    "project_urls": {
        "Homepage": "https://github.com/OpenVoiceOS/ovos-solver-plugin-openai-persona"
    },
    "split_keywords": [
        "ovos",
        "plugin",
        "utterance",
        "fallback",
        "query"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "db34450deb0d595f27921304af1bb6200de647bed10bda771f836f4522b91221",
                "md5": "0b503c53662b828568aa7e1846155cc6",
                "sha256": "083269aa22c5fc8d52df5e269967becdf67d1c6e0eca216664804ebf5f621546"
            },
            "downloads": -1,
            "filename": "ovos_openai_plugin-2.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b503c53662b828568aa7e1846155cc6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14976,
            "upload_time": "2025-07-31T15:32:52",
            "upload_time_iso_8601": "2025-07-31T15:32:52.514348Z",
            "url": "https://files.pythonhosted.org/packages/db/34/450deb0d595f27921304af1bb6200de647bed10bda771f836f4522b91221/ovos_openai_plugin-2.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6840812805e54ac75357609ddfcd379d43bffbffe37d10d1c0826422dca52095",
                "md5": "d11c4c5e27a9f26c59d49004f2759314",
                "sha256": "69b87c69a1e750b998aece3b0f2713516df2ff67c61265508961dc2959f43602"
            },
            "downloads": -1,
            "filename": "ovos-openai-plugin-2.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "d11c4c5e27a9f26c59d49004f2759314",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13206,
            "upload_time": "2025-07-31T15:32:53",
            "upload_time_iso_8601": "2025-07-31T15:32:53.595000Z",
            "url": "https://files.pythonhosted.org/packages/68/40/812805e54ac75357609ddfcd379d43bffbffe37d10d1c0826422dca52095/ovos-openai-plugin-2.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-31 15:32:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "OpenVoiceOS",
    "github_project": "ovos-solver-plugin-openai-persona",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "ovos-plugin-manager",
            "specs": [
                [
                    "<",
                    "2.0.0"
                ],
                [
                    ">=",
                    "0.0.26"
                ]
            ]
        }
    ],
    "lcname": "ovos-openai-plugin"
}