前端不发送cookie,使用本地配置文件保存
This commit is contained in:
parent
21db91ee71
commit
d37921099d
|
|
@ -8,6 +8,21 @@ from app.services.zhipu_kb_service import ZhipuKbService
|
|||
from app.services.openai_service import OpenaiService
|
||||
from app.utils.prompt_repository import PromptRepository # Add this import
|
||||
from app.utils.sessions import init_session
|
||||
import os
|
||||
|
||||
CONFIG_FILE = 'llm_service_config.json'
|
||||
|
||||
def get_current_service():
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
with open(CONFIG_FILE, 'r') as f:
|
||||
config = json.load(f)
|
||||
return config.get('llm_service', 'zhipu')
|
||||
return 'zhipu' # Default to zhipu if file doesn't exist
|
||||
|
||||
def set_current_service(service):
|
||||
config = {'llm_service': service}
|
||||
with open(CONFIG_FILE, 'w') as f:
|
||||
json.dump(config, f)
|
||||
|
||||
zhipu_controller_v2 = Blueprint('zhipu_controller_v2', __name__)
|
||||
|
||||
|
|
@ -157,16 +172,19 @@ def analysis_stream():
|
|||
if 'zhipu' in message.lower() or '智谱' in message:
|
||||
logger.info(f'switch to zhipu service, save to session')
|
||||
session['llm_service'] = 'zhipu'
|
||||
set_current_service('zhipu')
|
||||
return format_chunk("切换到智谱AI服务", None, None)
|
||||
if 'openai' in message.lower() or 'openai' in message:
|
||||
logger.info(f'switch to openai service, save to session')
|
||||
session['llm_service'] = 'openai'
|
||||
set_current_service('openai')
|
||||
return format_chunk("切换到openai服务", None, None)
|
||||
# 默认使用智谱AI服务
|
||||
llm_service = zhipu_service
|
||||
logger.info(f'llm_service: {session["llm_service"]}')
|
||||
current_service = session.get('llm_service', 'zhipu') # Default to 'zhipu' if not set
|
||||
|
||||
# current_service = session.get('llm_service', 'zhipu') # Default to 'zhipu' if not set
|
||||
current_service = get_current_service()
|
||||
|
||||
if current_service == 'openai':
|
||||
logger.info('Using OpenAI service')
|
||||
llm_service = openai_service
|
||||
|
|
@ -263,3 +281,4 @@ def analysis_stream():
|
|||
|
||||
return Response(event_stream(), mimetype='text/event-stream', headers=response_headers)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue