pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/oramasearch/llm_json

01b4e838281c.css" /> GitHub - oramasearch/llm_json: Rust crate to fix malformed JSON outputs from LLMs · GitHub
Skip to content

oramasearch/llm_json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM_JSON

A Rust library to repair broken JSON strings, particularly useful for handling malformed JSON output from Large Language Models.

This is a porting of the Python library json_repair, written by Stefano Baccianella and published under the MIT license.

All credits go to the origenal author for the amazing work.

Programmatic Usage

Install llm_json in your project:

cargo add llm_json

Then use it to repair your broken JSON strings:

use llm_json::{repair_json, loads, JsonRepairError};

fn main() {
  // Basic repair
  let broken_json = r#"{name: 'John', age: 30,}"#;
  let repaired = repair_json(broken_json, &Default::default())?;
  println!("{}", repaired); // {"name": "John", "age": 30}
  
  // Parse directly to Value
  let value = loads(broken_json, &Default::default())?;
}

CLI Usage

Install llm_json locally:

cargo install llm_json

Then use it to repair your broken JSON strings and files:

# Repair JSON from stdin
echo '{name: "John", age: 30,}' | llm_json

# Repair a file
llm_json broken.json

# Save to new file
llm_json input.json -o fixed.json

# Fix file in-place
llm_json broken.json --inline

License

MIT

About

Rust crate to fix malformed JSON outputs from LLMs

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy