Skip to content

Commit d697879

Browse files
committed
Final commit for this module, still debugging the test_passthrough_llm_action_invoked_via_logs test failure.
1 parent 10793be commit d697879

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
@@ -999,11 +999,11 @@ async def generate_bot_message(
999999
prompt[i]["content"] = user_message
10001000
break
10011001
else:
1002-
prompt: Optional[
1002+
prompt: Optional[ # pyright: ignore (TODO Refactor these branches into separate methods)
10031003
str
10041004
] = context.get( # pyright: ignore (TODO Refactor these branches into separate methods)
10051005
"user_message"
1006-
) # pyright: ignore (TODO - refactor nested `prompt` definitions)
1006+
)
10071007
if not prompt:
10081008
raise Exception("User message not found in context")
10091009

@@ -1058,7 +1058,10 @@ async def generate_bot_message(
10581058
] = self.llm_task_manager.render_task_prompt(
10591059
task=Task.GENERATE_BOT_MESSAGE,
10601060
events=events,
1061-
context={"examples": examples, "relevant_chunks": relevant_chunks},
1061+
context={
1062+
"examples": examples,
1063+
"relevant_chunks": relevant_chunks,
1064+
},
10621065
)
10631066

10641067
t0 = time()

nemoguardrails/actions/v2_x/generation.py

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

497490
text = self.llm_task_manager.parse_task_output(Task.GENERAL, output=text)
498491

499-
text = result.text
500-
501492
return text
502493

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

0 commit comments

Comments
 (0)