add banbanmini backend
This commit is contained in:
41
talkingq-url/implementations/volcano_llm.py
Normal file
41
talkingq-url/implementations/volcano_llm.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from implementations.base_llm import BaseLLM
|
||||
from config import settings
|
||||
from typing import List, Dict
|
||||
|
||||
class VolcanoLLM(BaseLLM):
|
||||
def __init__(self, selected_role=None):
|
||||
self.model_id = settings.volcano_model_id
|
||||
if selected_role and "volcano_model_id" in selected_role:
|
||||
self.model_id = selected_role["volcano_model_id"]
|
||||
session_source = "角色配置"
|
||||
else:
|
||||
session_source = "全局配置"
|
||||
|
||||
if hasattr(self, 'logger'):
|
||||
self.logger.info(
|
||||
"unknown",
|
||||
f"Volcano模型ID: {self.model_id} (来源: {session_source})"
|
||||
)
|
||||
|
||||
if self.model_id.startswith("bot-"):
|
||||
base_url = f"{settings.volcano_base_url}/bots"
|
||||
else:
|
||||
base_url = settings.volcano_base_url
|
||||
|
||||
super().__init__(
|
||||
api_key=settings.volcano_api_key,
|
||||
base_url=base_url,
|
||||
service_name="Volcano LLM",
|
||||
selected_role=selected_role,
|
||||
)
|
||||
|
||||
async def prepare_request(
|
||||
self, transcript: str, history: List[Dict[str, str]], selected_role: dict
|
||||
) -> Dict:
|
||||
if selected_role and "volcano_model_id" in selected_role:
|
||||
self.model_id = selected_role["volcano_model_id"]
|
||||
if self.model_id.startswith("bot-"):
|
||||
self.base_url = f"{settings.volcano_base_url}/bots"
|
||||
else:
|
||||
self.base_url = settings.volcano_base_url
|
||||
return await super().prepare_request(transcript, history, selected_role)
|
||||
Reference in New Issue
Block a user