Skip to content

Commit d3e7e2e

Browse files
fix: address gemini-code-assist review feedback
- Update LlmBackedUserSimulatorConfig.model type to Union[str, BaseLlm] - Use isinstance check for model string extraction in LlmRequest instead of accessing .model on potentially mocked objects
1 parent e1a28b0 commit d3e7e2e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/google/adk/evaluation/hallucinations_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def __init__(self, eval_metric: EvalMetric):
295295
self.segmenter_prompt = _HALLUCINATIONS_V1_SEGMENTER_PROMPT
296296
self.sentence_validator_prompt = _HALLUCINATIONS_V1_VALIDATOR_PROMPT
297297
judge_model = self._judge_model_options.judge_model
298-
self._model = judge_model.model if isinstance(judge_model, BaseLlm) else judge_model
298+
self._model = judge_model if isinstance(judge_model, str) else judge_model.model
299299
self._model_config = (
300300
self._judge_model_options.judge_model_config
301301
or genai_types.GenerateContentConfig()

src/google/adk/evaluation/llm_as_judge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async def evaluate_invocations(
137137
for actual, expected in zip(actual_invocations, expected_invocations):
138138
auto_rater_prompt = self.format_auto_rater_prompt(actual, expected)
139139
judge_model = self._judge_model_options.judge_model
140-
model_str = judge_model.model if isinstance(judge_model, BaseLlm) else judge_model
140+
model_str = judge_model if isinstance(judge_model, str) else judge_model.model
141141
llm_request = LlmRequest(
142142
model=model_str,
143143
contents=[

src/google/adk/evaluation/simulation/llm_backed_user_simulator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import logging
1818
from typing import ClassVar
1919
from typing import Optional
20+
from typing import Union
2021

2122
from google.genai import types as genai_types
2223
from pydantic import Field
@@ -48,9 +49,12 @@
4849
class LlmBackedUserSimulatorConfig(BaseUserSimulatorConfig):
4950
"""Contains configurations required by an LLM backed user simulator."""
5051

51-
model: str = Field(
52+
model: Union[str, BaseLlm] = Field(
5253
default="gemini-2.5-flash",
53-
description="The model to use for user simulation.",
54+
description=(
55+
"The model to use for user simulation. It can be a model name"
56+
" string or a BaseLlm instance for custom/self-hosted models."
57+
),
5458
)
5559

5660
model_configuration: genai_types.GenerateContentConfig = Field(

0 commit comments

Comments
 (0)