Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Commit dc227a7

Browse files
committed
feat: robust body choicer
1 parent 37fbea9 commit dc227a7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

gemini/src/parser/response_parser.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ def parse_response_text(self, response_text):
2929

3030
def _extract_body(self, response_text):
3131
try:
32-
body = json.loads(
33-
json.loads(response_text.lstrip("')]}'\n\n").split("\n")[1])[0][2]
34-
)
32+
body = json.loads(json.loads(max(response_text.split("\n"), key=len))[0][2])
3533
if not body[4]:
3634
body = json.loads(
37-
json.loads(response_text.lstrip("')]}'\n\n").split("\n")[1])[4][2]
35+
json.loads(max(response_text.split("\n"), key=len))[4][2]
3836
)
3937
return body
4038
except:

0 commit comments

Comments
 (0)