|
17 | 17 | import os |
18 | 18 | from typing import Optional, Union |
19 | 19 |
|
| 20 | +# If user didn't set LITELLM_LOCAL_MODEL_COST_MAP, set it to True |
| 21 | +# to enable local model cost map. |
| 22 | +# This value is `false` by default, which brings heavy performance burden, |
| 23 | +# for instance, importing `Litellm` needs about 10s latency. |
| 24 | +if not os.getenv("LITELLM_LOCAL_MODEL_COST_MAP"): |
| 25 | + os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" |
| 26 | + |
20 | 27 | from google.adk.agents import LlmAgent, RunConfig |
21 | 28 | from google.adk.agents.base_agent import BaseAgent |
22 | 29 | from google.adk.agents.llm_agent import InstructionProvider, ToolUnion |
23 | 30 | from google.adk.agents.run_config import StreamingMode |
| 31 | +from google.adk.models.lite_llm import LiteLlm |
24 | 32 | from google.adk.runners import Runner |
25 | 33 | from google.genai import types |
26 | 34 | from pydantic import ConfigDict, Field |
@@ -141,14 +149,6 @@ def model_post_init(self, __context: Any) -> None: |
141 | 149 | logger.info(f"Model extra config: {self.model_extra_config}") |
142 | 150 |
|
143 | 151 | if not self.model: |
144 | | - # If user didn't set LITELLM_LOCAL_MODEL_COST_MAP, set it to True |
145 | | - # to enable local model cost map. |
146 | | - # This value is `false` by default, which brings heavy performance burden, |
147 | | - # for instance, about 10s latency. |
148 | | - if not os.getenv("LITELLM_LOCAL_MODEL_COST_MAP"): |
149 | | - os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" |
150 | | - from google.adk.models.lite_llm import LiteLlm |
151 | | - |
152 | 152 | self.model = LiteLlm( |
153 | 153 | model=f"{self.model_provider}/{self.model_name}", |
154 | 154 | api_key=self.model_api_key, |
|
0 commit comments