Skip to main content

A set of utility functions to handle LLM structural output

Project description

llmutil

This library provides tools to generate structured output from the OpenAI API.

What is Structured Output?

Structured Output is the recommended method for getting formatted responses. It guarantees that outputs follow your defined schema, making it more reliable than previous methods like JSON mode, function calls, or tool use.

How to Use

To use Structured Output, you need to define a schema. This library makes it easy with simple functions:

sysmsg = "You are a helpful assistant that can answer questions and help with tasks."

result = gen(
    sysmsg,
    "What is the capital of Japan?",
    gen_schema(
        answer=gen_str("Name of the capital"),
    ),
)
# {'answer': 'Tokyo'}

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

bfg_llmutil-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

bfg_llmutil-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file bfg_llmutil-0.1.1.tar.gz.

File metadata

  • Download URL: bfg_llmutil-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for bfg_llmutil-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a38f53c6992ee68f3cbff22390f65dcb5e91f0f0e03c65c967f4e0c465e28432
MD5 ee504338121027d103631e75021883dd
BLAKE2b-256 18d13bd8fb03b29f7d96ca3e83b3222d0140130a441f11d66c53a1bc571a7908

See more details on using hashes here.

File details

Details for the file bfg_llmutil-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bfg_llmutil-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54f2e8217b011fde476b9c6c113230493e5da5797798f9246ff77b6b6e4729fe
MD5 e4129e0c4b6002fa9d3215eec696c75c
BLAKE2b-256 cd9edc160ec4dec470c70840da43e2e0979f488e77c4daab99b86df8df9efbe8

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