__init__.py 1.95 KB
# 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']