Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion demos/hf_explorer/hf_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ def chat_loop():
tool_choice="auto"
)

if not response.choices or response.choices[0].message is None:
raise ValueError("LLM returned empty or filtered response")
response_message = response.choices[0].message
messages.append(response_message)

# Check if the model wants to call a function
if response_message.tool_calls:
# Execute all tool calls
Expand All @@ -132,6 +134,8 @@ def chat_loop():
tool_choice="auto"
)

if not final_response.choices or final_response.choices[0].message is None:
raise ValueError("LLM returned empty or filtered response")
final_message = final_response.choices[0].message
messages.append(final_message)
print(f"\nAssistant: {final_message.content}\n")
Expand Down