Skip to content

Commit 0de294e

Browse files
authored
Merge pull request #533 from NVIDIA/feature/expose-global-variables-in-prompt-templates
Expose global variables in prompting templates
2 parents 9a420e3 + 4bd5ba9 commit 0de294e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nemoguardrails/actions/v2_x/generation.py

+9
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ async def generate_user_intent(
207207
"examples": examples,
208208
"potential_user_intents": ", ".join(potential_user_intents),
209209
"user_action": user_action,
210+
"context": state.context,
210211
},
211212
)
212213
stop = self.llm_task_manager.get_stop_tokens(
@@ -266,6 +267,7 @@ async def check_for_active_flow_finished_match(
266267
)
267268
async def generate_flow_from_instructions(
268269
self,
270+
state: State,
269271
instructions: str,
270272
events: List[dict],
271273
llm: Optional[BaseLLM] = None,
@@ -298,6 +300,7 @@ async def generate_flow_from_instructions(
298300
"examples": examples,
299301
"flow_name": flow_name,
300302
"instructions": instructions,
303+
"context": state.context,
301304
},
302305
)
303306

@@ -330,6 +333,7 @@ async def generate_flow_from_instructions(
330333
)
331334
async def generate_flow_from_name(
332335
self,
336+
state: State,
333337
name: str,
334338
events: List[dict],
335339
llm: Optional[BaseLLM] = None,
@@ -358,6 +362,7 @@ async def generate_flow_from_name(
358362
context={
359363
"examples": examples,
360364
"flow_name": name,
365+
"context": state.context,
361366
},
362367
)
363368

@@ -384,6 +389,7 @@ async def generate_flow_from_name(
384389
)
385390
async def generate_flow_continuation(
386391
self,
392+
state: State,
387393
events: List[dict],
388394
temperature: Optional[float] = None,
389395
llm: Optional[BaseLLM] = None,
@@ -421,6 +427,7 @@ async def generate_flow_continuation(
421427
events=events,
422428
context={
423429
"examples": examples,
430+
"context": state.context,
424431
},
425432
)
426433

@@ -467,6 +474,7 @@ async def generate_flow_continuation(
467474
@action(name="GenerateValueAction", is_system_action=True, execute_async=True)
468475
async def generate_value(
469476
self,
477+
state: State,
470478
instructions: str,
471479
events: List[dict],
472480
var_name: Optional[str] = None,
@@ -504,6 +512,7 @@ async def generate_value(
504512
"examples": examples,
505513
"instructions": instructions,
506514
"var_name": var_name if var_name else "result",
515+
"context": state.context,
507516
},
508517
)
509518

0 commit comments

Comments
 (0)