Skip to content

Commit

Permalink
Merge pull request #29 from mugeshk97/fix/typeerror-render-opt-step
Browse files Browse the repository at this point in the history
Fix TypeError in response handling with f-string formatting for suggestion values
  • Loading branch information
allenanie authored Jan 5, 2025
2 parents 0d98865 + 1d8c880 commit 5856518
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions opto/trace/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ def render_opt_step(step_idx, optimizer, no_trace_graph=False, no_improvement=Fa
llm_response = json.loads(optimizer.log[idx]['response'])
r1 = llm_response['reasoning']

if 'suggestion' in llm_response and llm_response['suggestion'] is not None:
a1 = ""
for var_name, var_body in llm_response['suggestion'].items():
a1 += var_name + ':\n\n'
a1 += var_body + '\n\n'

elif 'answer' in llm_response and llm_response['answer'] is not None:
if llm_response.get('suggestion'):
a1 = ''.join(
[f"{var_name}:\n\n{var_body}\n\n" for var_name, var_body in llm_response['suggestion'].items()]
)
elif llm_response.get('answer') is not None:
a1 = llm_response['answer']
else:
a1 = "<ERROR> NULL/INVALID RESPONSE"
Expand Down

0 comments on commit 5856518

Please sign in to comment.