|
19 | 19 | from google.adk.evaluation.app_details import AgentDetails |
20 | 20 | from google.adk.evaluation.app_details import AppDetails |
21 | 21 | from google.adk.evaluation.eval_case import IntermediateData |
| 22 | +from google.adk.evaluation.eval_case import Invocation |
22 | 23 | from google.adk.evaluation.eval_case import InvocationEvent |
23 | 24 | from google.adk.evaluation.eval_case import InvocationEvents |
24 | 25 | from google.adk.evaluation.eval_rubrics import RubricScore |
@@ -88,6 +89,49 @@ def test_get_text_from_content_with_mixed_parts(): |
88 | 89 | assert get_text_from_content(content) == "Hello\nWorld" |
89 | 90 |
|
90 | 91 |
|
| 92 | +def test_get_text_from_content_with_invocation_include_intermediate_responses_in_final(): |
| 93 | + """Tests get_text_from_content on an Invocation with and without the flag.""" |
| 94 | + intermediate_text = "Let me check." |
| 95 | + final_response_text = "Done." |
| 96 | + invocation = Invocation( |
| 97 | + user_content=genai_types.Content(parts=[genai_types.Part(text="user")]), |
| 98 | + intermediate_data=InvocationEvents( |
| 99 | + invocation_events=[ |
| 100 | + InvocationEvent( |
| 101 | + author="agent", |
| 102 | + content=genai_types.Content( |
| 103 | + parts=[genai_types.Part(text=intermediate_text)] |
| 104 | + ), |
| 105 | + ), |
| 106 | + InvocationEvent( |
| 107 | + author="tool", |
| 108 | + content=genai_types.Content( |
| 109 | + parts=[ |
| 110 | + genai_types.Part( |
| 111 | + function_call=genai_types.FunctionCall(name="t") |
| 112 | + ) |
| 113 | + ] |
| 114 | + ), |
| 115 | + ), |
| 116 | + ] |
| 117 | + ), |
| 118 | + final_response=genai_types.Content( |
| 119 | + parts=[genai_types.Part(text=final_response_text)] |
| 120 | + ), |
| 121 | + ) |
| 122 | + |
| 123 | + # Flag off (default): only the final response text is returned. |
| 124 | + assert get_text_from_content(invocation) == final_response_text |
| 125 | + |
| 126 | + # Flag on: intermediate text is concatenated before the final response. |
| 127 | + assert ( |
| 128 | + get_text_from_content( |
| 129 | + invocation, include_intermediate_responses_in_final=True |
| 130 | + ) |
| 131 | + == f"{intermediate_text}\n{final_response_text}" |
| 132 | + ) |
| 133 | + |
| 134 | + |
91 | 135 | def test_get_eval_status_with_none_score(): |
92 | 136 | """Tests get_eval_status returns NOT_EVALUATED for a None score.""" |
93 | 137 | assert get_eval_status(score=None, threshold=0.5) == EvalStatus.NOT_EVALUATED |
|
0 commit comments