forked from ZhuLinsen/daily_stock_analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlitellm_stub.py
More file actions
30 lines (23 loc) · 749 Bytes
/
litellm_stub.py
File metadata and controls
30 lines (23 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
"""
Shared test helper to ensure imports work when litellm is unavailable.
"""
import importlib.util
import sys
import types
def ensure_litellm_stub() -> None:
"""Install a minimal litellm stub only when litellm is unavailable."""
if "litellm" in sys.modules:
return
try:
if importlib.util.find_spec("litellm") is not None:
return
except ValueError:
# A previously injected incomplete stub may leave __spec__ unset.
pass
litellm_stub = types.ModuleType("litellm")
class _DummyRouter: # pragma: no cover
pass
litellm_stub.Router = _DummyRouter
litellm_stub.completion = lambda **kwargs: None
sys.modules["litellm"] = litellm_stub