LLMTextualAnswer
Python package for finding textual answers via LLMs. This is a Python port of the Wolfram Language LLMTextualAnswer function, focused on building prompts, wiring LangChain models, and parsing structured outputs.
Install
pip install LLMTextualAnswer
Usage
Question answering
from LLMTextualAnswer import LLMTextualAnswer
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o-mini")
text = (
"Born and raised in the Austrian Empire, Tesla studied engineering and physics "
"in the 1870s without receiving a degree."
)
questions = ["Where born?"]
result = LLMTextualAnswer(
text,
questions,
llm=llm,
form=dict,
)
print(result)
Classification
Here is a list of workflow construction specifications:
queries = [
'Make a classifier with the method RandomForest over the data dfTitanic; show precision and accuracy; plot True Positive Rate vs Positive Predictive Value.',
'Make a recommender over the data frame dfOrders. Give the top 5 recommendations for the profile year:2022, type:Clothing, and status:Unpaid',
'Create an LSA object over the text collection aAbstracts; extract 40 topics; show statistical thesaurus for "notebook", "equation", "changes", and "prediction"',
'Compute quantile regression for dfTS with interpolation order 3 and knots 12 for the probabilities 0.2, 0.4, and 0.9.'
]
Here are possible workflows names:
workflows = ['Classification', 'Latent Semantic Analysis', 'Quantile Regression', 'Recommendations']
For each workflow spec give the corresponding (most likely) workflow name:
for q in queries:
print("Spec : " + q)
print("Class : " + llm_classify(q, workflows, llm = llm, form=dict) + "\n")
# Spec : Make a classifier with the method RandomForest over the data dfTitanic; show precision and accuracy; plot True Positive Rate vs Positive Predictive Value.
# Class : Classification
#
# Spec : Make a recommender over the data frame dfOrders. Give the top 5 recommendations for the profile year:2022, type:Clothing, and status:Unpaid
# Class : Recommendations
#
# Spec : Create an LSA object over the text collection aAbstracts; extract 40 topics; show statistical thesaurus for "notebook", "equation", "changes", and "prediction"
# Class : Latent Semantic Analysis
#
# Spec : Compute quantile regression for dfTS with interpolation order 3 and knots 12 for the probabilities 0.2, 0.4, and 0.9.
# Class : Quantile Regression
#
Notes
- For more detailed examples see the notebook "Basic-usage.ipynb.
llm_textual_answerandllm_classifyaccept "LangChain" chat/text models that support.invoke.- Use
prompt_style="chat"orprompt_style="text"if auto-detection is not desired. - When you want only the prompt template, pass
form="StringTemplate".
Metadata
Release files for LLMTextualAnswer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llmtextualanswer-0.1.1.tar.gz | 8.5 kB | Without provenance | Details for llmtextualanswer-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llmtextualanswer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for llmtextualanswer-0.1.1-py3-none-any.whl |
Total release size: 16.3 kB
Release files / llmtextualanswer-0.1.1.tar.gz
| Download URL | llmtextualanswer-0.1.1.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7e8b916ac566bbc39cc8fc9096752a258dfb9a0da147cf161918a7b700f4efe
|
|
BLAKE2b-256 checksum How to use checksums |
8d47d4974b01508aec7cd2c0ca5f20f78cb1df840aa84b6c7f884e9be94e2d1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / llmtextualanswer-0.1.1-py3-none-any.whl
| Download URL | llmtextualanswer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a60f46b22d03d30594e68c9598629970d7673f9d943ca38ef7da18e45bd14a79
|
|
BLAKE2b-256 checksum How to use checksums |
b9daa3c7a1616485805dc5f10d993b8ef91dedbedfed425f9f03290bfb240849
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Security for LLMTextualAnswer 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.