Skip to content

Commit d809788

Browse files
committed
feat(tool-calling): add tool call passthrough support in LLMRails
Implements tool call extraction and passthrough functionality in LLMRails: - Add tool_calls_var context variable for storing LLM tool calls - Refactor llm_call utils to extract and store tool calls from responses - Support tool calls in both GenerationResponse and dict message formats - Add ToolMessage support for langchain message conversion - Comprehensive test coverage for tool calling integration
1 parent c5a44c0 commit d809788

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nemoguardrails/actions/llm/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ def get_colang_history(
226226
history += f'user "{event["text"]}"\n'
227227
elif event["type"] == "UserIntent":
228228
if include_texts:
229-
history += f' {event["intent"]}\n'
229+
history += f" {event['intent']}\n"
230230
else:
231-
history += f'user {event["intent"]}\n'
231+
history += f"user {event['intent']}\n"
232232
elif event["type"] == "BotIntent":
233233
# If we have instructions, we add them before the bot message.
234234
# But we only do that for the last bot message.
235235
if "instructions" in event and idx == last_bot_intent_idx:
236236
history += f"# {event['instructions']}\n"
237-
history += f'bot {event["intent"]}\n'
237+
history += f"bot {event['intent']}\n"
238238
elif event["type"] == "StartUtteranceBotAction" and include_texts:
239239
history += f' "{event["script"]}"\n'
240240
# We skip system actions from this log
@@ -403,9 +403,9 @@ def flow_to_colang(flow: Union[dict, Flow]) -> str:
403403
if "_type" not in element:
404404
raise Exception("bla")
405405
if element["_type"] == "UserIntent":
406-
colang_flow += f'user {element["intent_name"]}\n'
406+
colang_flow += f"user {element['intent_name']}\n"
407407
elif element["_type"] == "run_action" and element["action_name"] == "utter":
408-
colang_flow += f'bot {element["action_params"]["value"]}\n'
408+
colang_flow += f"bot {element['action_params']['value']}\n"
409409

410410
return colang_flow
411411

0 commit comments

Comments
 (0)