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.0.tar.gz (6.3 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.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bfg_llmutil-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f6965b7da983738ccf5403617987eaef8f99ff91bd6b708d511fd7f0fb77c38
MD5 16db11f66a21bfc148b7b010f5eb68c7
BLAKE2b-256 e24e5f047a12cb2a07183a3ed1a88908ba83c57810cc449b14437cb525a719cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bfg_llmutil-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0f898ff97e787a749ff69ab24ee5dc3a42dba0af7f9c0ee64b07628d42cfa0b
MD5 471fd74edec20d97a4f96d28b69275ae
BLAKE2b-256 250909f9975b78677efd1c58645aad9750b745815c9bee6ce7e8ef94afe6a868

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