Deploy Aether Garden application
Browse files- .pytest_cache/v/cache/nodeids +2 -0
- ai/generation.py +1 -1
- ai/modal_client.py +35 -3
.pytest_cache/v/cache/nodeids
CHANGED
|
@@ -4,6 +4,8 @@
|
|
| 4 |
"tests/test_generation.py::test_entity_profile_traits",
|
| 5 |
"tests/test_generation.py::test_validate_input_min_words",
|
| 6 |
"tests/test_generation.py::test_validate_input_ok",
|
|
|
|
|
|
|
| 7 |
"tests/test_relationships.py::test_canonical_pair_ordering",
|
| 8 |
"tests/test_tick.py::test_tick_runs"
|
| 9 |
]
|
|
|
|
| 4 |
"tests/test_generation.py::test_entity_profile_traits",
|
| 5 |
"tests/test_generation.py::test_validate_input_min_words",
|
| 6 |
"tests/test_generation.py::test_validate_input_ok",
|
| 7 |
+
"tests/test_modal_client.py::test_extract_json_from_wrapped_response",
|
| 8 |
+
"tests/test_modal_client.py::test_extract_json_ignores_braces_inside_strings",
|
| 9 |
"tests/test_relationships.py::test_canonical_pair_ordering",
|
| 10 |
"tests/test_tick.py::test_tick_runs"
|
| 11 |
]
|
ai/generation.py
CHANGED
|
@@ -154,7 +154,7 @@ def generate_entity(
|
|
| 154 |
prompts.ENTITY_GENERATION_SYSTEM,
|
| 155 |
user_prompt,
|
| 156 |
temperature=temp,
|
| 157 |
-
max_new_tokens=
|
| 158 |
)
|
| 159 |
data = extract_json(raw)
|
| 160 |
if data.get("suggested_location") in LOCATION_ALIASES:
|
|
|
|
| 154 |
prompts.ENTITY_GENERATION_SYSTEM,
|
| 155 |
user_prompt,
|
| 156 |
temperature=temp,
|
| 157 |
+
max_new_tokens=700,
|
| 158 |
)
|
| 159 |
data = extract_json(raw)
|
| 160 |
if data.get("suggested_location") in LOCATION_ALIASES:
|
ai/modal_client.py
CHANGED
|
@@ -59,12 +59,44 @@ def extract_json(text: str) -> dict:
|
|
| 59 |
try:
|
| 60 |
return json.loads(text)
|
| 61 |
except json.JSONDecodeError:
|
| 62 |
-
|
| 63 |
-
if
|
| 64 |
-
return json.loads(
|
| 65 |
raise ValueError(f"Could not parse JSON from response: {text[:200]}...")
|
| 66 |
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
def _mock_generate(system_prompt: str, user_prompt: str) -> str:
|
| 69 |
"""Deterministic mock for local development without Modal."""
|
| 70 |
if "summoned something into the Realm" in user_prompt:
|
|
|
|
| 59 |
try:
|
| 60 |
return json.loads(text)
|
| 61 |
except json.JSONDecodeError:
|
| 62 |
+
candidate = _first_balanced_json_object(text)
|
| 63 |
+
if candidate:
|
| 64 |
+
return json.loads(candidate)
|
| 65 |
raise ValueError(f"Could not parse JSON from response: {text[:200]}...")
|
| 66 |
|
| 67 |
|
| 68 |
+
def _first_balanced_json_object(text: str) -> str | None:
|
| 69 |
+
"""Return the first complete top-level JSON object embedded in text."""
|
| 70 |
+
start = text.find("{")
|
| 71 |
+
if start == -1:
|
| 72 |
+
return None
|
| 73 |
+
|
| 74 |
+
depth = 0
|
| 75 |
+
in_string = False
|
| 76 |
+
escape = False
|
| 77 |
+
|
| 78 |
+
for i, ch in enumerate(text[start:], start=start):
|
| 79 |
+
if in_string:
|
| 80 |
+
if escape:
|
| 81 |
+
escape = False
|
| 82 |
+
elif ch == "\\":
|
| 83 |
+
escape = True
|
| 84 |
+
elif ch == '"':
|
| 85 |
+
in_string = False
|
| 86 |
+
continue
|
| 87 |
+
|
| 88 |
+
if ch == '"':
|
| 89 |
+
in_string = True
|
| 90 |
+
elif ch == "{":
|
| 91 |
+
depth += 1
|
| 92 |
+
elif ch == "}":
|
| 93 |
+
depth -= 1
|
| 94 |
+
if depth == 0:
|
| 95 |
+
return text[start : i + 1]
|
| 96 |
+
|
| 97 |
+
return None
|
| 98 |
+
|
| 99 |
+
|
| 100 |
def _mock_generate(system_prompt: str, user_prompt: str) -> str:
|
| 101 |
"""Deterministic mock for local development without Modal."""
|
| 102 |
if "summoned something into the Realm" in user_prompt:
|