ovos wolfram-alpha plugin
Project description
ovos-wolfram-alpha-plugin
Wolfram Alpha integration for OpenVoiceOS. Provides a retrieval engine for RAG pipelines and an agent toolbox for tool-using agents, both as standard OPM plugins.
Wolfram Alpha excels at questions with a single definitive answer: maths, unit conversions, scientific constants, chemical properties, astronomy, nutrition, geography, and historical dates. It is not a search engine — it computes answers from curated data.
An API key is required. A demo key is bundled for development but is rate-limited and should not be used in production.
Installation
pip install ovos-wolfram-alpha-plugin
OPM Entry Points
| Entry point | Class | Use case |
|---|---|---|
opm.agents.retrieval — ovos-wolfram-alpha-solver |
WolframAlphaRetrievalEngine |
RAG — returns (answer, score) tuples |
opm.agents.toolbox — ovos-wolfram-alpha-tools |
WolframAlphaToolbox |
Agent tool use — exposes search_wolfram_alpha |
Retrieval Engine
WolframAlphaRetrievalEngine implements the RetrievalEngine OPM interface. It calls the Wolfram Alpha spoken-answer endpoint and handles non-English queries by translating them to English before the request and back after.
from ovos_wolfram_alpha_plugin import WolframAlphaRetrievalEngine
engine = WolframAlphaRetrievalEngine(config={"appid": "YOUR-KEY"})
# Maths & conversions
engine.get_spoken_answer("integral of x^2 sin(x)", lang="en")
# "x^2 (-cos(x)) + 2 x sin(x) + 2 cos(x) + constant"
engine.get_spoken_answer("100 miles in kilometers", lang="en")
# "160.934 kilometers"
engine.get_spoken_answer("1000 USD in EUR", lang="en")
# "approximately 923 euros" (live rate)
# Science & constants
engine.get_spoken_answer("speed of light", lang="en")
# "about 2.998 × 10^8 meters per second"
engine.get_spoken_answer("boiling point of ethanol", lang="en")
# "78.37 degrees Celsius"
engine.get_spoken_answer("distance from Earth to Mars", lang="en")
# "currently about 1.69 AU" (live ephemeris)
# Factual lookups
engine.get_spoken_answer("population of Brazil", lang="en")
# "approximately 215.3 million people"
engine.get_spoken_answer("calories in 100g of almonds", lang="en")
# "579 kilocalories"
engine.get_spoken_answer("when was the Eiffel Tower built", lang="en")
# "construction was from January 28, 1887 to March 31, 1889"
# Non-English — translated automatically
engine.get_spoken_answer("massa do Sol", lang="pt")
# "aproximadamente 1,989 × 10^30 kg"
# Image result — returns a local file path to a Wolfram visual
engine.get_image("benzene molecular structure", lang="en")
# Full structured pod results — list of {"title", "summary"} dicts
for pod in engine.get_expanded_answer("Neptune", lang="en"):
print(pod["title"], "—", pod.get("summary", pod.get("img")))
# "Orbital period — 164.8 years"
# "Surface gravity — 11.15 m/s²"
# ...
# RAG interface: List[Tuple[str, float]] (answer, score)
results = engine.query("half-life of carbon-14", lang="en")
# [("5730 years", 0.9)]
Translation
Non-English queries require a translation plugin. Configure it by passing translate_plugin in the config:
engine = WolframAlphaRetrievalEngine(config={
"appid": "YOUR-KEY",
"translate_plugin": "ovos-translate-plugin-server",
})
If no translation plugin is available, only English queries are answered.
Agent Toolbox
WolframAlphaToolbox exposes a single search_wolfram_alpha tool that any OPM-compatible agent loop (e.g. ovos-agentic-loop) can discover and call. The tool uses the LLM-optimised Wolfram endpoint, which returns a more structured answer than the spoken endpoint.
Persona JSON
Reference the toolbox by its entry point name inside any agentic persona. Pass a system_prompt to the brain plugin so the LLM knows how to query Wolfram correctly:
{
"name": "Wolfram Alpha",
"solvers": ["ovos-react-loop"],
"ovos-react-loop": {
"brain": "ovos-chat-openai-plugin",
"toolboxes": ["ovos-wolfram-alpha-tools"],
"ovos-chat-openai-plugin": {
"api_url": "http://localhost:11434/v1/chat/completions",
"system_prompt": "You have access to Wolfram Alpha. Use it for maths, science, unit conversions, and factual questions with a definite answer. Always send queries in English as concise keywords (e.g. 'France population', not 'how many people live in France'). Use the exponent notation 6*10^14, never 6e14. If the result is not relevant, retry with a more specific query rather than rephrasing."
}
}
}
💡 The official LLM API docs have more tips on writing effective Wolfram system prompts.
Direct usage
from ovos_wolfram_alpha_plugin import WolframAlphaToolbox, SearchWolframAlphaArgs
tb = WolframAlphaToolbox(config={"appid": "YOUR-KEY"})
tools = tb.discover_tools()
# [AgentTool(name="search_wolfram_alpha", ...)]
output = tb.search_wolfram(SearchWolframAlphaArgs(query="France population", units="metric"))
print(output.result)
License
Apache 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ovos_wolfram_alpha_plugin-1.0.0a2.tar.gz.
File metadata
- Download URL: ovos_wolfram_alpha_plugin-1.0.0a2.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
159bcecf303c10d28b57b3002ada376217f5beb309ff78f2d6834731405f4455
|
|
| MD5 |
4275dc39bf5b8d45ba7a886568a1aca4
|
|
| BLAKE2b-256 |
e4e8f1979eba8e887c071ab2b6ed7136c54f96a6296f879ed12b1d0e61f27807
|
File details
Details for the file ovos_wolfram_alpha_plugin-1.0.0a2-py3-none-any.whl.
File metadata
- Download URL: ovos_wolfram_alpha_plugin-1.0.0a2-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c6766a9ad6abc0eeaa5e145b9070c1814b1b515958576c9e4027fddcebef2df
|
|
| MD5 |
693cac7c42ce331a5e1525181e92d402
|
|
| BLAKE2b-256 |
281d94a3398705b391a04ae556738706dc90562e8bce81e134ec9c6825c34589
|