Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -493,11 +493,12 @@ async def generate_function_call(prompt):
|
|
493 |
output += response.token.text
|
494 |
|
495 |
# Find the first and last curly braces in the output
|
496 |
-
start_index = output.
|
497 |
-
end_index = output.
|
498 |
|
499 |
-
if start_index != -1 and end_index != -1:
|
500 |
json_string = output[start_index:end_index + 1]
|
|
|
501 |
try:
|
502 |
# Attempt to parse the trimmed string as JSON
|
503 |
parsed_json = json.loads(json_string)
|
|
|
493 |
output += response.token.text
|
494 |
|
495 |
# Find the first and last curly braces in the output
|
496 |
+
start_index = output.rfind("{") # Find the last occurrence of "{"
|
497 |
+
end_index = output.find("}") # Find the first occurrence of "}"
|
498 |
|
499 |
+
if start_index != -1 and end_index != -1 and start_index < end_index:
|
500 |
json_string = output[start_index:end_index + 1]
|
501 |
+
|
502 |
try:
|
503 |
# Attempt to parse the trimmed string as JSON
|
504 |
parsed_json = json.loads(json_string)
|