Skip to content

Commit 5499e21

Browse files
authored
Remove json repair (#24)
1 parent e6466c8 commit 5499e21

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

openhands/core/utils/json.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import Any
33
from datetime import datetime
44

5-
from json_repair import repair_json
65
from litellm.types.utils import ModelResponse
76

87
from openhands.core.llm.exceptions import LLMResponseError
@@ -46,23 +45,4 @@ def loads(json_str, **kwargs):
4645
try:
4746
return json.loads(json_str, **kwargs)
4847
except json.JSONDecodeError:
49-
pass
50-
depth = 0
51-
start = -1
52-
for i, char in enumerate(json_str):
53-
if char == "{":
54-
if depth == 0:
55-
start = i
56-
depth += 1
57-
elif char == "}":
58-
depth -= 1
59-
if depth == 0 and start != -1:
60-
response = json_str[start : i + 1]
61-
try:
62-
json_str = repair_json(response)
63-
return json.loads(json_str, **kwargs)
64-
except (json.JSONDecodeError, ValueError, TypeError) as e:
65-
raise LLMResponseError(
66-
"Invalid JSON in response. Please make sure the response is a valid JSON object."
67-
) from e
68-
raise LLMResponseError("No valid JSON object found in response.")
48+
raise LLMResponseError("No valid JSON object found in response.")

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ description = "OpenHands: Code Less, Make More"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
8-
"bashlex>=0.18",
9-
"binaryornot>=0.4.4",
10-
"cachetools>=6.1.0",
8+
"bashlex>=0.18", # TODO: move these to separate runtime projects
9+
"binaryornot>=0.4.4", # TODO: move these to separate runtime projects
10+
"cachetools>=6.1.0", # TODO: move these to separate runtime projects
1111
"fastmcp>=2.11.3",
12-
"json-repair>=0.50.0",
13-
"libtmux>=0.46.2",
12+
"libtmux>=0.46.2", # TODO: move these to separate runtime projects
1413
"litellm>=1.75.9",
1514
"pydantic>=2.11.7",
1615
"python-frontmatter>=1.1.0",

uv.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)