File tree Expand file tree Collapse file tree 2 files changed +34
-22
lines changed
Expand file tree Collapse file tree 2 files changed +34
-22
lines changed Original file line number Diff line number Diff line change 5050from veadk .tracing .base_tracer import BaseTracer
5151from veadk .utils .logger import get_logger
5252from veadk .utils .patches import patch_asyncio , patch_tracer
53+ from veadk .utils .misc import check_litellm_version
5354from veadk .version import VERSION
5455
5556patch_tracer ()
@@ -159,28 +160,7 @@ def model_post_init(self, __context: Any) -> None:
159160 if not self .model :
160161 if self .enable_responses :
161162 min_version = "1.79.3"
162- from packaging .version import InvalidVersion
163- from packaging .version import parse as parse_version
164- import pkg_resources
165-
166- try :
167- installed = parse_version (
168- pkg_resources .get_distribution ("litellm" ).version
169- )
170- except pkg_resources .DistributionNotFound :
171- raise ImportError (
172- "litellm installation not detected, please install it first: pip install litellm>=1.79.3"
173- ) from None
174- except InvalidVersion as e :
175- raise ValueError (
176- f"Invalid format of litellm version number:{ e } "
177- ) from None
178- required = parse_version (min_version )
179- if installed < required :
180- raise ValueError (
181- "You have used `enable_responses=True`. If you want to use the `responses_api`, please install the relevant support:"
182- "\n pip install veadk-python[responses]"
183- )
163+ check_litellm_version (min_version )
184164
185165 from veadk .models .ark_llm import ArkLlm
186166
Original file line number Diff line number Diff line change @@ -182,3 +182,35 @@ def get_agent_dir():
182182 full_path = os .getcwd ()
183183
184184 return full_path
185+
186+
187+ def check_litellm_version (min_version : str ):
188+ """
189+ Check if the installed litellm version meets the minimum requirement.
190+
191+ Args:
192+ min_version (str): The minimum required version of litellm.
193+ """
194+ try :
195+ from packaging .version import InvalidVersion
196+ from packaging .version import parse as parse_version
197+ import pkg_resources
198+
199+ try :
200+ installed = parse_version (pkg_resources .get_distribution ("litellm" ).version )
201+ except pkg_resources .DistributionNotFound :
202+ raise ImportError (
203+ "litellm installation not detected, please install it first: pip install litellm>=1.79.3"
204+ ) from None
205+ except InvalidVersion as e :
206+ raise ValueError (f"Invalid format of litellm version number:{ e } " ) from None
207+ required = parse_version (min_version )
208+ if installed < required :
209+ raise ValueError (
210+ "You have used `enable_responses=True`. If you want to use the `responses_api`, please install the relevant support:"
211+ "\n pip install veadk-python[responses]"
212+ )
213+ except ImportError :
214+ raise ImportError (
215+ "packaging or pkg_resources not found. Please install them: pip install packaging setuptools"
216+ )
You can’t perform that action at this time.
0 commit comments