__init__.py
1.95 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# AIfeng/2024-12-19
# LLM模块包初始化文件
"""
LLM模块包 - 支持多种大语言模型
支持的模型:
- ChatGPT: OpenAI GPT模型
- Qwen: 阿里云通义千问模型
- Gemini: Google Gemini模型
- VllmGPT: VLLM加速的GPT模型
- Doubao: 火山引擎豆包模型
使用示例:
from llm.Doubao import Doubao
from llm.Qwen import Qwen
from llm.ChatGPT import ChatGPT
"""
__version__ = "1.0.0"
__author__ = "AIfeng"
# 导入所有模型类
try:
from .ChatGPT import ChatGPT
except ImportError:
ChatGPT = None
try:
from .Qwen import Qwen
except ImportError:
Qwen = None
try:
from .Gemini import Gemini
except ImportError:
Gemini = None
try:
from .VllmGPT import VllmGPT
except ImportError:
VllmGPT = None
try:
from .Doubao import Doubao
except ImportError:
Doubao = None
try:
from .LLM import LLM
except ImportError:
LLM = None
# 导入llm_response函数
try:
import sys
import os
# 添加项目根目录到路径
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
# 导入llm模块中的函数
import importlib.util
spec = importlib.util.spec_from_file_location("llm_module", os.path.join(parent_dir, "llm.py"))
llm_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(llm_module)
llm_response = llm_module.llm_response
except Exception as e:
print(f"Warning: Failed to import llm_response: {e}")
llm_response = None
# 可用模型列表
AVAILABLE_MODELS = []
if ChatGPT:
AVAILABLE_MODELS.append('ChatGPT')
if Qwen:
AVAILABLE_MODELS.append('Qwen')
if Gemini:
AVAILABLE_MODELS.append('Gemini')
if VllmGPT:
AVAILABLE_MODELS.append('VllmGPT')
if Doubao:
AVAILABLE_MODELS.append('Doubao')
if LLM:
AVAILABLE_MODELS.append('LLM')
__all__ = ['ChatGPT', 'Qwen', 'Gemini', 'VllmGPT', 'Doubao', 'LLM', 'llm_response', 'AVAILABLE_MODELS']