Skip to content

Commit 30d8e27

Browse files
committed
Final commit for this module, still debugging the test_passthrough_llm_action_invoked_via_logs test failure.
1 parent b7bc444 commit 30d8e27

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

nemoguardrails/actions/llm/generation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,11 @@ async def generate_bot_message(
972972

973973
# We use the potentially updated $user_message. This means that even
974974
# in passthrough mode, input rails can still alter the input.
975-
prompt: Optional[
975+
prompt: Optional[ # pyright: ignore (TODO Refactor these branches into separate methods)
976976
str
977977
] = context.get( # pyright: ignore (TODO Refactor these branches into separate methods)
978978
"user_message"
979-
) # pyright: ignore (TODO - refactor nested `prompt` definitions)
979+
)
980980
if not prompt:
981981
raise Exception("User message not found in context")
982982

@@ -1035,7 +1035,10 @@ async def generate_bot_message(
10351035
] = self.llm_task_manager.render_task_prompt(
10361036
task=Task.GENERATE_BOT_MESSAGE,
10371037
events=events,
1038-
context={"examples": examples, "relevant_chunks": relevant_chunks},
1038+
context={
1039+
"examples": examples,
1040+
"relevant_chunks": relevant_chunks,
1041+
},
10391042
)
10401043

10411044
t0 = time()

nemoguardrails/actions/v2_x/generation.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,11 @@ async def _collect_user_intent_and_examples(
236236
and "_user_intent" in element_flow_state_instance[0].context
237237
):
238238
if flow_config.elements[1]["_type"] == "doc_string_stmt":
239+
# TODO! Need to make this type-safe but no idea what's going on
239240
examples += "user action: <" + (
240-
flow_config.elements[1]["elements"][0][
241-
"elements"
242-
][ # pyright: ignore (TODO - Don't know where to even start with this line of code)
241+
flow_config.elements[1]["elements"][ # pyright: ignore
243242
0
244-
][
245-
"elements"
246-
][
247-
0
248-
][
249-
3:-3
250-
]
243+
]["elements"][0]["elements"][0][3:-3]
251244
+ ">\n"
252245
)
253246
examples += f"user intent: {flow_id}\n\n"
@@ -491,8 +484,6 @@ async def passthrough_llm_action(
491484

492485
text = self.llm_task_manager.parse_task_output(Task.GENERAL, output=text)
493486

494-
text = result.text
495-
496487
return text
497488

498489
@action(name="CheckValidFlowExistsAction", is_system_action=True)

0 commit comments

Comments
 (0)