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.4.2.tar.gz (9.5 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.4.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bfg_llmutil-0.4.2.tar.gz
Algorithm Hash digest
SHA256 242ef322a2760fa397e562985e6861516d39e5f13377ac19d773b4c932dc4cbc
MD5 ab86d27abe757accf93098216d050ae0
BLAKE2b-256 827f9ef01024455c763b9b85eb2c0eab58398ce509d87669b15c865cb123d12b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bfg_llmutil-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 27e26578e933ce1654f3426d9076446084be9d3998a0969f7bc73fc24de3eab5
MD5 f1dad32df10811b8a7278acba763a046
BLAKE2b-256 bd152031b84f56efe340457f5ac3de4d9d5d28a0bcd4d9b4d42a77000cec326a

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