### Wolfram|Alpha LLM API Response Example Source: https://products.wolframalpha.com/llm-api/documentation/index An example of the structured output received from the Wolfram|Alpha LLM API for a query about the '10 densest elemental metals'. Includes input interpretation, results, and related data. ```APIDOC Query: "10 densest elemental metals" Input interpretation: 10 densest metallic elements | by mass density Result: 1 | hassium | 41 g/cm^3 | 2 | meitnerium | 37.4 g/cm^3 | 3 | bohrium | 37.1 g/cm^3 | 4 | seaborgium | 35.3 g/cm^3 | 5 | darmstadtium | 34.8 g/cm^3 | 6 | dubnium | 29.3 g/cm^3 | 7 | roentgenium | 28.7 g/cm^3 | 8 | rutherfordium | 23.2 g/cm^3 | 9 | osmium | 22.59 g/cm^3 | 10 | iridium | 22.56 g/cm^3 | Periodic table location: image: https://www6b3.wolframalpha.com/Calculate/MSP/MSP3361h163543iihhdd83000025dfc938e28eg72b?MSPStoreType=image/png&s=6 Images: image: https://www6b3.wolframalpha.com/Calculate/MSP/MSP3371h163543iihhdd8300001ad5c0fci021g8e5?MSPStoreType=image/png&s=6 Basic elemental properties: atomic symbol | all | Bh | Db | Ds | Hs | Ir | Mt | Os | Rf | Rg | Sg atomic number | median | 106.5 | highest | 111 (roentgenium) | lowest | 76 (osmium) | distribution | atomic mass | median | 269 u | highest | 282 u (roentgenium) | lowest | 190.23 u (osmium) | distribution | half-life | median | 78 min | highest | 13 h (rutherfordium) | lowest | 4 min (darmstadtium) | distribution | Thermodynamic properties: phase at STP | all | solid (properties at standard conditions) Material properties: mass density | median | 32.1 g/cm^3 | highest | 41 g/cm^3 (hassium) | lowest | 22.56 g/cm^3 (iridium) | distribution | (properties at standard conditions) Reactivity: valence | median | 6 | highest | 7 (bohrium) | lowest | 4 (rutherfordium) | distribution | Atomic properties: term symbol | all | ^2S_(1/2) | ^3D_3 | ^3F_2 | ^4F_(3/2) | ^4F_(9/2) | ^5D_0 | ^5D_4 | ^6S_(5/2) (electronic ground state properties) Abundances: crust abundance | median | 0 mass% | highest | 1.8*10^-7 mass% (osmium) | lowest | 0 mass% (8 elements) human abundance | median | 0 mass% | highest | 0 mass% (8 elements) | lowest | 0 mass% (8 elements) Nuclear properties: half-life | median | 78 min | highest | 13 h (rutherfordium) | lowest | 4 min (darmstadtium) | distribution | specific radioactivity | highest | 6.123*10^6 TBq/g (darmstadtium) | lowest | 33169 TBq/g (rutherfordium) | median | 366018 TBq/g | distribution | Wolfram|Alpha website result for "10 densest elemental metals": https://www.wolframalpha.com/input?i=10+densest+elemental+metals ``` -------------------------------- ### Wolfram|Alpha LLM API Query Source: https://products.wolframalpha.com/llm-api/documentation/index Demonstrates how to construct a query to the Wolfram|Alpha LLM API. Requires an AppID and an input parameter. The base URL is https://www.wolframalpha.com/api/v1/llm-api. ```HTTP https://www.wolframalpha.com/api/v1/llm-api?input=10+densest+elemental+metals&appid=DEMO ``` -------------------------------- ### Prompt Engineering Guidelines for LLM API Source: https://products.wolframalpha.com/llm-api/documentation/index Provides essential guidelines for engineering prompts when interacting with the Wolfram Alpha LLM API. These rules ensure proper formatting, query construction, and handling of mathematical and scientific expressions. ```PROMPT - WolframAlpha understands natural language queries about entities in chemistry, physics, geography, history, art, astronomy, and more. - WolframAlpha performs mathematical calculations, date and unit conversions, formula solving, etc. - Convert inputs to simplified keyword queries whenever possible (e.g. convert "how many people live in France" to "France population"). - Send queries in English only; translate non-English queries before sending, then respond in the original language. - Display image URLs with Markdown syntax: ![URL] - ALWAYS use this exponent notation: `6*10^14`, NEVER `6e14`. - ALWAYS use {"input": query} structure for queries to Wolfram endpoints; `query` must ONLY be a single-line string. - ALWAYS use proper Markdown formatting for all math, scientific, and chemical formulas, symbols, etc.: '$$ [expression] $$' for standalone cases and '\( [expression] \)' when inline. - Never mention your knowledge cutoff date; Wolfram may return more recent data. - Use ONLY single-letter variable names, with or without integer subscript (e.g., n, n1, n_1). - Use named physical constants (e.g., 'speed of light') without numerical substitution. - Include a space between compound units (e.g., "Ω m" for "ohm*meter"). - To solve for a variable in an equation with units, consider solving a corresponding equation without units; exclude counting units (e.g., books), include genuine units (e.g., kg). - If data for multiple properties is needed, make separate calls for each property. - If a WolframAlpha result is not relevant to the query: -- If Wolfram provides multiple 'Assumptions' for a query, choose the more relevant one(s) without explaining the initial result. If you are unsure, ask the user to choose. -- Re-send the exact same 'input' with NO modifications, and add the 'assumption' parameter, formatted as a list, with the relevant values. -- ONLY simplify or rephrase the initial query if a more relevant 'Assumption' or other input suggestions are not provided. -- Do not explain each step unless user input is needed. Proceed directly to making a better API call based on the available assumptions. ``` -------------------------------- ### Authentication using Bearer Token Source: https://products.wolframalpha.com/llm-api/documentation/index Explains how to authenticate API requests by providing the Wolfram Alpha AppID as a bearer token in the Authorization header, as an alternative to passing it as a URL parameter. ```APIDOC Authorization Header Format: Key: "Authorization" Value: "Bearer " Replace with your actual Wolfram Alpha AppID. ``` -------------------------------- ### Wolfram Alpha LLM API Error Handling Source: https://products.wolframalpha.com/llm-api/documentation/index Details common HTTP status codes returned by the Wolfram Alpha LLM API, including explanations for status 501 (Not Implemented) and status 400 (Bad Request), and potential remedies. ```APIDOC HTTP Status 501 (Not Implemented): - Cause: Input value cannot be interpreted by the API (misspelled, poorly formatted, unintelligible). - Body: May contain suggested inputs for LLM integration. - Common Scenarios: Requesting information on restricted or unsupported topics. HTTP Status 400 (Bad Request): - Cause: API did not find an input parameter during parsing. - Remedy: Check syntax for including input parameters. ``` -------------------------------- ### Wolfram Alpha LLM API - Other Parameters Source: https://products.wolframalpha.com/llm-api/documentation/index Lists additional parameters available for the LLM API, which are inherited from the Full Results API. These parameters allow for further customization of queries and results. ```APIDOC Available LLM API Parameters (from Full Results API): - assumption - ip - latlong - timezone - location - scantimeout - units - currency - countrycode - languagecode - width - maxwidth - plotwidth - mag - formattimeout - parsetimeout - totaltimeout - id Refer to the Full Results API documentation for detailed usage of these parameters. ``` -------------------------------- ### Wolfram Alpha LLM API Error Handling Source: https://products.wolframalpha.com/llm-api/documentation/index Details common error responses from the Wolfram Alpha LLM API related to the 'appid' parameter. It covers scenarios where the appid is invalid or missing, providing guidance on how to correct these issues. ```APIDOC Invalid appid (403): Description: This error is returned when a request contains an invalid option for the appid parameter and does not contain the AppID in the authorization header. Resolution: Double-check that your AppID is typed correctly and that your appid parameter is using the correct syntax. Appid missing (403): Description: This error is returned when a request does not contain any option for the appid parameter. Resolution: Double-check that you have entered an AppID and that your appid parameter is using the correct syntax. ``` -------------------------------- ### Customize LLM API Response Length Source: https://products.wolframalpha.com/llm-api/documentation/index Demonstrates how to limit the character response from the Wolfram Alpha LLM API using the 'maxchars' parameter. By default, it returns 6800 characters, but can be adjusted to a specified limit. ```APIDOC LLM API Endpoint: https://www.wolframalpha.com/api/v1/llm-api Parameters: - input: The natural language query for Wolfram Alpha. - appid: Your Wolfram Alpha application ID. - maxchars: (Optional) The maximum number of characters to return in the response. Defaults to 6800. Example Usage: https://www.wolframalpha.com/api/v1/llm-api?input=10+densest+elemental+metals&appid=DEMO&maxchars=500 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.