5757from nemoguardrails .embeddings .index import EmbeddingsIndex , IndexItem
5858from nemoguardrails .kb .kb import KnowledgeBase
5959from nemoguardrails .llm .prompts import get_prompt
60- from nemoguardrails .llm .taskmanager import LLMTaskManager , ParsedTaskOutput
60+ from nemoguardrails .llm .taskmanager import LLMTaskManager
6161from nemoguardrails .llm .types import Task
6262from nemoguardrails .logging .explain import LLMCallInfo
6363from nemoguardrails .patch_asyncio import check_sync_call_from_async_loop
@@ -496,7 +496,6 @@ async def generate_user_intent(
496496 result = self .llm_task_manager .parse_task_output (
497497 Task .GENERATE_USER_INTENT , output = result
498498 )
499- result = result .text
500499
501500 user_intent = get_first_nonempty_line (result )
502501 if user_intent is None :
@@ -594,10 +593,6 @@ async def generate_user_intent(
594593 Task .GENERAL , output = text
595594 )
596595
597- text = _process_parsed_output (
598- text , self ._include_reasoning_traces ()
599- )
600-
601596 else :
602597 # Initialize the LLMCallInfo object
603598 llm_call_info_var .set (LLMCallInfo (task = Task .GENERAL .value ))
@@ -639,8 +634,6 @@ async def generate_user_intent(
639634 text = self .llm_task_manager .parse_task_output (
640635 Task .GENERAL , output = result
641636 )
642-
643- text = _process_parsed_output (text , self ._include_reasoning_traces ())
644637 text = text .strip ()
645638 if text .startswith ('"' ):
646639 text = text [1 :- 1 ]
@@ -750,7 +743,6 @@ async def generate_next_step(
750743 result = self .llm_task_manager .parse_task_output (
751744 Task .GENERATE_NEXT_STEPS , output = result
752745 )
753- result = result .text
754746
755747 # If we don't have multi-step generation enabled, we only look at the first line.
756748 if not self .config .enable_multi_step_generation :
@@ -1036,10 +1028,6 @@ async def generate_bot_message(
10361028 Task .GENERAL , output = result
10371029 )
10381030
1039- result = _process_parsed_output (
1040- result , self ._include_reasoning_traces ()
1041- )
1042-
10431031 log .info (
10441032 "--- :: LLM Bot Message Generation passthrough call took %.2f seconds" ,
10451033 time () - t0 ,
@@ -1111,10 +1099,6 @@ async def generate_bot_message(
11111099 Task .GENERATE_BOT_MESSAGE , output = result
11121100 )
11131101
1114- result = _process_parsed_output (
1115- result , self ._include_reasoning_traces ()
1116- )
1117-
11181102 # TODO: catch openai.error.InvalidRequestError from exceeding max token length
11191103
11201104 result = get_multiline_response (result )
@@ -1212,7 +1196,6 @@ async def generate_value(
12121196 result = self .llm_task_manager .parse_task_output (
12131197 Task .GENERATE_VALUE , output = result
12141198 )
1215- result = result .text
12161199
12171200 # We only use the first line for now
12181201 # TODO: support multi-line values?
@@ -1433,7 +1416,6 @@ async def generate_intent_steps_message(
14331416 result = self .llm_task_manager .parse_task_output (
14341417 Task .GENERATE_INTENT_STEPS_MESSAGE , output = result
14351418 )
1436- result = result .text
14371419
14381420 # TODO: Implement logic for generating more complex Colang next steps (multi-step),
14391421 # not just a single bot intent.
@@ -1516,7 +1498,6 @@ async def generate_intent_steps_message(
15161498 result = self .llm_task_manager .parse_task_output (
15171499 Task .GENERAL , output = result
15181500 )
1519- result = _process_parsed_output (result , self ._include_reasoning_traces ())
15201501 text = result .strip ()
15211502 if text .startswith ('"' ):
15221503 text = text [1 :- 1 ]
@@ -1529,10 +1510,6 @@ async def generate_intent_steps_message(
15291510 events = [new_event_dict ("BotMessage" , text = text )],
15301511 )
15311512
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-
15361513
15371514def clean_utterance_content (utterance : str ) -> str :
15381515 """
@@ -1550,27 +1527,3 @@ def clean_utterance_content(utterance: str) -> str:
15501527 # It should be translated to an actual \n character.
15511528 utterance = utterance .replace ("\\ n" , "\n " )
15521529 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