llm-to-json 0.0.23__tar.gz → 0.0.24__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/PKG-INFO +1 -1
- llm_to_json-0.0.24/llm_to_json/__init__.py +23 -0
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/llm_to_json.egg-info/PKG-INFO +1 -1
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/pyproject.toml +1 -1
- llm_to_json-0.0.23/llm_to_json/__init__.py +0 -13
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/README.md +0 -0
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/llm_to_json.egg-info/SOURCES.txt +0 -0
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/llm_to_json.egg-info/dependency_links.txt +0 -0
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/llm_to_json.egg-info/requires.txt +0 -0
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/llm_to_json.egg-info/top_level.txt +0 -0
- {llm_to_json-0.0.23 → llm_to_json-0.0.24}/setup.cfg +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# packages/llm_to_json/__init__.py
|
|
2
|
+
try:
|
|
3
|
+
from prompture import extract_and_jsonify as _extract_and_jsonify
|
|
4
|
+
from prompture.drivers import OllamaDriver
|
|
5
|
+
except Exception:
|
|
6
|
+
from prompture.core import extract_and_jsonify as _extract_and_jsonify
|
|
7
|
+
from prompture.drivers import OllamaDriver
|
|
8
|
+
|
|
9
|
+
def from_llm_text(text: str, schema: dict, driver: dict | None = None):
|
|
10
|
+
"""Extract JSON from text using LLM.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
text: Text to extract JSON from
|
|
14
|
+
schema: JSON schema to validate against
|
|
15
|
+
driver: Optional LLM driver (defaults to local Ollama if not provided)
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
Extracted and validated JSON object
|
|
19
|
+
"""
|
|
20
|
+
if driver is None:
|
|
21
|
+
driver = OllamaDriver(endpoint="http://localhost:11434", model="gemma:latest")
|
|
22
|
+
result = _extract_and_jsonify(driver, text, schema)
|
|
23
|
+
return result["json_object"]
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# packages/llm_to_json/__init__.py
|
|
2
|
-
try:
|
|
3
|
-
from prompture import extract_and_jsonify as _extract_and_jsonify
|
|
4
|
-
from prompture.drivers.mock_driver import MockDriver
|
|
5
|
-
except Exception:
|
|
6
|
-
from prompture.core import extract_and_jsonify as _extract_and_jsonify
|
|
7
|
-
from prompture.drivers.mock_driver import MockDriver
|
|
8
|
-
|
|
9
|
-
def from_llm_text(text: str, schema: dict, driver: dict | None = None):
|
|
10
|
-
if driver is None:
|
|
11
|
-
driver = MockDriver()
|
|
12
|
-
result = _extract_and_jsonify(driver, text, schema)
|
|
13
|
-
return result["json_object"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|