Skip to content

Commit a28b406

Browse files
committed
move import litellm to header
1 parent 6c85587 commit a28b406

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

veadk/agent.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@
1717
import os
1818
from typing import Optional, Union
1919

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+
2027
from google.adk.agents import LlmAgent, RunConfig
2128
from google.adk.agents.base_agent import BaseAgent
2229
from google.adk.agents.llm_agent import InstructionProvider, ToolUnion
2330
from google.adk.agents.run_config import StreamingMode
31+
from google.adk.models.lite_llm import LiteLlm
2432
from google.adk.runners import Runner
2533
from google.genai import types
2634
from pydantic import ConfigDict, Field
@@ -141,14 +149,6 @@ def model_post_init(self, __context: Any) -> None:
141149
logger.info(f"Model extra config: {self.model_extra_config}")
142150

143151
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-
152152
self.model = LiteLlm(
153153
model=f"{self.model_provider}/{self.model_name}",
154154
api_key=self.model_api_key,

0 commit comments

Comments
 (0)