feat: 支持Matrix access_token登录,配置AI模型接口
This commit is contained in:
@@ -4,10 +4,28 @@ AI服务 - 调用大模型API
|
||||
import httpx
|
||||
from typing import List, Dict, Optional
|
||||
import json
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 默认配置
|
||||
DEFAULT_API_BASE = "http://192.168.2.17:19007/v1"
|
||||
DEFAULT_API_KEY = "xxxx"
|
||||
DEFAULT_MODEL = "auto"
|
||||
|
||||
|
||||
class AIService:
|
||||
def __init__(self, api_base: str = "http://192.168.2.17:19007/v1", api_key: str = "sk-local", model: str = "qwen3.5-4b"):
|
||||
def __init__(self, api_base: str = None, api_key: str = None, model: str = None):
|
||||
self.api_base = api_base or DEFAULT_API_BASE
|
||||
self.api_key = api_key or DEFAULT_API_KEY
|
||||
self.model = model or DEFAULT_MODEL
|
||||
|
||||
def update_config(self, api_base: str, api_key: str, model: str):
|
||||
"""更新配置"""
|
||||
self.api_base = api_base
|
||||
self.api_key = api_key
|
||||
self.model = model
|
||||
logger.info(f"AI配置已更新: {api_base}, model={model}")
|
||||
self.api_base = api_base
|
||||
self.api_key = api_key
|
||||
self.model = model
|
||||
|
||||
Reference in New Issue
Block a user