Skip to main content

Find textual answers via an LLM.

Project description

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

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)

For more detailed examples see the notebook "./docs/Basic-usage.ipynb".


Notes

  • LLMTextualAnswer accepts LangChain chat/text models that support .invoke.
  • Use prompt_style="chat" or prompt_style="text" if auto-detection is not desired.
  • When you want only the prompt template, pass form="StringTemplate".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmtextualanswer-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmtextualanswer-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file llmtextualanswer-0.1.0.tar.gz.

File metadata

  • Download URL: llmtextualanswer-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for llmtextualanswer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc4c21edf2e92ef04138c45cff251afdae80a34d8303f73252024c5a6cd3895c
MD5 b66b366a3289a1444e6a4917a1784425
BLAKE2b-256 514f59c6aeee579dd363235e17bc8cc6122c2e68da7e8768510ae9857bf86856

See more details on using hashes here.

File details

Details for the file llmtextualanswer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llmtextualanswer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66c1e454b4ba30feb37b86fa069ba13df00f1e144357fcadfd8f02c4acfbc9e0
MD5 e4892e585116f931697c33cc8a73e465
BLAKE2b-256 c285763ff2b6bc8e36a1caf3f841e876fc6cfd03178bc5286fa4b362bea5e147

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