Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/livingbio/fuzzy-json
Fuzzy-JSON is a compact Python package with no dependencies, designed to address the pesky JSONDecodeError that sometimes occurs when utilizing OpenAI's powerful call function.
https://github.com/livingbio/fuzzy-json
json llama llm openai openai-chatgpt python
Last synced: 3 days ago
JSON representation
Fuzzy-JSON is a compact Python package with no dependencies, designed to address the pesky JSONDecodeError that sometimes occurs when utilizing OpenAI's powerful call function.
- Host: GitHub
- URL: https://github.com/livingbio/fuzzy-json
- Owner: livingbio
- License: mit
- Created: 2023-10-19T08:43:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-01T14:36:50.000Z (15 days ago)
- Last Synced: 2024-11-08T21:07:07.800Z (7 days ago)
- Topics: json, llama, llm, openai, openai-chatgpt, python
- Language: Python
- Homepage:
- Size: 1.84 MB
- Stars: 31
- Watchers: 7
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fuzzy-json
[![CI](https://github.com/livingbio/fuzzy-json/workflows/python-unittest/badge.svg?branch=main)](https://github.com/livingbio/fuzzy-json/actions?query=workflow%3Apython-unittest++branch%3Amain++)
[![Coverage Status](https://coveralls.io/repos/github/livingbio/fuzzy-json/badge.svg?branch=main)](https://coveralls.io/github/livingbio/gpt-fn?branch=main)
[![pypi](https://img.shields.io/pypi/v/fuzy-jon.svg)](https://pypi.python.org/pypi/fuzy-jon)[![versions](https://img.shields.io/pypi/pyversions/fuzy-jon.svg)](https://github.com/livingbio/fuzy-jon)
[![license](https://img.shields.io/github/license/livingbio/fuzzy-json.svg)](https://github.com/livingbio/fuzzy-json/blob/main/LICENSE)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)![logo](./static/276545475-2f7178c0-70d9-4ebd-8ca2-b6a317062944.png)
- Fuzzy-JSON is a compact Python package with no dependencies, designed to address the pesky `JSONDecodeError` that sometimes occurs when utilizing OpenAI's powerful `call function`.
- These errors, although small, can be quite bothersome. I prefer not to rely on retries, replace or resort to using alternative prompts to rectify this issue.
- To tackle this problem, Fuzzy-JSON employs a pushdown automata capable of incorporating JSON syntax and rectifying invalid JSON structures in the correct positions.
- It boasts user-friendliness, making it exceptionally easy to use.
- Fuzzy-JSON serves as a specialized JSON repair tool, particularly tailored for resolving issues in the output of language models like LLMs. If you encounter any cases not covered by the tool, please don't hesitate to create an issue for further assistance.> The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
https://platform.openai.com/docs/api-reference/chat/object
## Installation
You can install fuzy-jon using pip, the Python package manager:
```bash
pip install fuzy-jon
```## Getting Started
To start using fuzy-jon in your project, import the library and call the desired function:
```python
from fuzzy_json import loads...
response = await openai.ChatCompletion.acreate(**kwargs)
args = response.choices[0].message.function_call.arguments
parsed_json = loads(args) # will auto repair invalid JSON if possible
```## Why fuz[z]y-j[s]on?
- Today marks the 3rd birthday of my beloved daughter, Patty, and I'm eager to make it a memorable day for her.
- I've introduced an open-source project called "Fuzzy JSON," which is inspired by her favorite book, "Fuzzy Ocean." You can find the book here: https://www.amazon.com/-/zh_TW/dp/178700063X
- Patty enjoys identifying and discussing the names of various enchanting ocean creatures depicted in her books.
- The package is named "fuzy-jon" due to a minor glitch from DALL-E-3, which I found endearing and decided to embrace. I believe it aligns perfectly with the package's intended purpose.
- This project is designed to address annoying issues like "JSONDecodeError" that may arise when utilizing OpenAI's function call feature, making the function call feature less troublesome.
- With these adjustments, I hope to bring joy to everyone's day.![fuzy-jon](./static/393729620_10228059130956650_7731223954878062302_n.jpg)