Skip to main content

lite_llm_json

Description

The library has functionality to cleanly extract JSON from LLM responses and generate prompts for LLM that return JSON. It features a simple yet versatile implementation.

Installation

pip install LiteLLMJson

HowToUse

import openai
from lite_llm_json import LiteLLMJson

# Set the OpenAI API key
api_key = "YOUR_API_KEY"
openai.api_key = api_key

# Define the JSON schema
json_schema = {
    "type": "object",
    "properties": {"name": {"type": "string"}, "age": {"type": "integer"}},
    "required": ["name", "age"],
}
# Instantiate the LiteLLMJson class
llm_json = LiteLLMJson(json_schema)

# Define the query prompt
query_prompt = """## Instructions:
Provide information about a person."""

# Get the generated prompt
generated_prompt = llm_json.generate_prompt(query_prompt)

# Use the OpenAI API to get a completion
response = openai.Completion.create(
    engine="text-davinci-003",
    prompt=generated_prompt
)

# Get the output text
output_text = response["choices"][0]["text"]

# Parse the output text to obtain JSON data
json_data = llm_json.parse_response(output_text)

# Display the JSON data
print(json_data)

Metadata

Release files for LiteLLMJson 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LiteLLMJson 0.0.7
File Size Uploaded Provenance
LiteLLMJson-0.0.7.tar.gz 3.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for LiteLLMJson 0.0.7
File Interpreter ABI Platform
LiteLLMJson-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / LiteLLMJson-0.0.7.tar.gz

Download URL LiteLLMJson-0.0.7.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c7dfb9e7020d1aa571343c83ccab4b8a438b59b21276b1b0499ef21593df94d8
BLAKE2b-256 checksum
How to use checksums
f5a829ed2502bf53da4f445aebed34f54df1c8736604def96ca085f257ca6822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / LiteLLMJson-0.0.7-py3-none-any.whl

Download URL LiteLLMJson-0.0.7-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77ce0120883df8b3ccbf49820fdb883c657922d76368361be4f7f785ee125b1c
BLAKE2b-256 checksum
How to use checksums
12e45d3aa8931d5aa687a3db18227835bcacb602a0fdc586de6b2b86289d0c15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for LiteLLMJson 0.0.7

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page