57
57
from nemoguardrails .embeddings .index import EmbeddingsIndex , IndexItem
58
58
from nemoguardrails .kb .kb import KnowledgeBase
59
59
from nemoguardrails .llm .prompts import get_prompt
60
- from nemoguardrails .llm .taskmanager import LLMTaskManager , ParsedTaskOutput
60
+ from nemoguardrails .llm .taskmanager import LLMTaskManager
61
61
from nemoguardrails .llm .types import Task
62
62
from nemoguardrails .logging .explain import LLMCallInfo
63
63
from nemoguardrails .patch_asyncio import check_sync_call_from_async_loop
@@ -496,7 +496,6 @@ async def generate_user_intent(
496
496
result = self .llm_task_manager .parse_task_output (
497
497
Task .GENERATE_USER_INTENT , output = result
498
498
)
499
- result = result .text
500
499
501
500
user_intent = get_first_nonempty_line (result )
502
501
if user_intent is None :
@@ -594,10 +593,6 @@ async def generate_user_intent(
594
593
Task .GENERAL , output = text
595
594
)
596
595
597
- text = _process_parsed_output (
598
- text , self ._include_reasoning_traces ()
599
- )
600
-
601
596
else :
602
597
# Initialize the LLMCallInfo object
603
598
llm_call_info_var .set (LLMCallInfo (task = Task .GENERAL .value ))
@@ -639,8 +634,6 @@ async def generate_user_intent(
639
634
text = self .llm_task_manager .parse_task_output (
640
635
Task .GENERAL , output = result
641
636
)
642
-
643
- text = _process_parsed_output (text , self ._include_reasoning_traces ())
644
637
text = text .strip ()
645
638
if text .startswith ('"' ):
646
639
text = text [1 :- 1 ]
@@ -750,7 +743,6 @@ async def generate_next_step(
750
743
result = self .llm_task_manager .parse_task_output (
751
744
Task .GENERATE_NEXT_STEPS , output = result
752
745
)
753
- result = result .text
754
746
755
747
# If we don't have multi-step generation enabled, we only look at the first line.
756
748
if not self .config .enable_multi_step_generation :
@@ -1036,10 +1028,6 @@ async def generate_bot_message(
1036
1028
Task .GENERAL , output = result
1037
1029
)
1038
1030
1039
- result = _process_parsed_output (
1040
- result , self ._include_reasoning_traces ()
1041
- )
1042
-
1043
1031
log .info (
1044
1032
"--- :: LLM Bot Message Generation passthrough call took %.2f seconds" ,
1045
1033
time () - t0 ,
@@ -1111,10 +1099,6 @@ async def generate_bot_message(
1111
1099
Task .GENERATE_BOT_MESSAGE , output = result
1112
1100
)
1113
1101
1114
- result = _process_parsed_output (
1115
- result , self ._include_reasoning_traces ()
1116
- )
1117
-
1118
1102
# TODO: catch openai.error.InvalidRequestError from exceeding max token length
1119
1103
1120
1104
result = get_multiline_response (result )
@@ -1212,7 +1196,6 @@ async def generate_value(
1212
1196
result = self .llm_task_manager .parse_task_output (
1213
1197
Task .GENERATE_VALUE , output = result
1214
1198
)
1215
- result = result .text
1216
1199
1217
1200
# We only use the first line for now
1218
1201
# TODO: support multi-line values?
@@ -1433,7 +1416,6 @@ async def generate_intent_steps_message(
1433
1416
result = self .llm_task_manager .parse_task_output (
1434
1417
Task .GENERATE_INTENT_STEPS_MESSAGE , output = result
1435
1418
)
1436
- result = result .text
1437
1419
1438
1420
# TODO: Implement logic for generating more complex Colang next steps (multi-step),
1439
1421
# not just a single bot intent.
@@ -1516,7 +1498,6 @@ async def generate_intent_steps_message(
1516
1498
result = self .llm_task_manager .parse_task_output (
1517
1499
Task .GENERAL , output = result
1518
1500
)
1519
- result = _process_parsed_output (result , self ._include_reasoning_traces ())
1520
1501
text = result .strip ()
1521
1502
if text .startswith ('"' ):
1522
1503
text = text [1 :- 1 ]
@@ -1529,10 +1510,6 @@ async def generate_intent_steps_message(
1529
1510
events = [new_event_dict ("BotMessage" , text = text )],
1530
1511
)
1531
1512
1532
- def _include_reasoning_traces (self ) -> bool :
1533
- """Get the configuration value for whether to include reasoning traces in output."""
1534
- return _get_apply_to_reasoning_traces (self .config )
1535
-
1536
1513
1537
1514
def clean_utterance_content (utterance : str ) -> str :
1538
1515
"""
@@ -1550,27 +1527,3 @@ def clean_utterance_content(utterance: str) -> str:
1550
1527
# It should be translated to an actual \n character.
1551
1528
utterance = utterance .replace ("\\ n" , "\n " )
1552
1529
return utterance
1553
-
1554
-
1555
- def _record_reasoning_trace (trace : str ) -> None :
1556
- """Store the reasoning trace in context for later retrieval."""
1557
- reasoning_trace_var .set (trace )
1558
-
1559
-
1560
- def _assemble_response (text : str , trace : Optional [str ], include_reasoning : bool ) -> str :
1561
- """Combine trace and text if requested, otherwise just return text."""
1562
- return (trace + text ) if (trace and include_reasoning ) else text
1563
-
1564
-
1565
- def _process_parsed_output (
1566
- output : ParsedTaskOutput , include_reasoning_trace : bool
1567
- ) -> str :
1568
- """Record trace, then assemble the final LLM response."""
1569
- if reasoning_trace := output .reasoning_trace :
1570
- _record_reasoning_trace (reasoning_trace )
1571
- return _assemble_response (output .text , reasoning_trace , include_reasoning_trace )
1572
-
1573
-
1574
- def _get_apply_to_reasoning_traces (config : RailsConfig ) -> bool :
1575
- """Get the configuration value for whether to include reasoning traces in output."""
1576
- return config .rails .output .apply_to_reasoning_traces
0 commit comments