hllama

hllama provides some useful utility functions for LLM.


Keywords
LLM, Large, Language, Model, Verification, Utility
License
Apache-2.0
Install
pip install hllama==0.0.7

Documentation

hllama

hllama == Harness LLaMA. hllama is a library which aims to provide a set of utility tools for large language models.

Install

$ pip install hllama

Usage

Test if JSON matches target structure

from hllama import json_utils

A = {"key1": str, "key2": {"key3": str, "key4": int, "key5": list}}
B = {"key1": "hello", "key2": {"key3": "world", "key4": 100, "key5": [1, 2, 3]}}

result = json_utils.match_structure(A, B)
assert result is True

Test if there is JSON part in a string

raw_string = "..."
result = json_utils.parse_json_snippet(raw_string)
assert isinstance(result, dict)
assert result is not None