sharsh02 commited on
Commit
378454a
1 Parent(s): a5504ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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.find('{')
497
- end_index = output.rfind('}')
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)