|
|
@ -1,11 +1,12 @@
|
|
|
|
from config.logger import setup_logging
|
|
|
|
from config.logger import setup_logging
|
|
|
|
from http import HTTPStatus
|
|
|
|
from http import HTTPStatus
|
|
|
|
from dashscope import Application
|
|
|
|
import dashscope
|
|
|
|
from core.providers.llm.base import LLMProviderBase
|
|
|
|
from core.providers.llm.base import LLMProviderBase
|
|
|
|
|
|
|
|
|
|
|
|
TAG = __name__
|
|
|
|
TAG = __name__
|
|
|
|
logger = setup_logging()
|
|
|
|
logger = setup_logging()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LLMProvider(LLMProviderBase):
|
|
|
|
class LLMProvider(LLMProviderBase):
|
|
|
|
def __init__(self, config):
|
|
|
|
def __init__(self, config):
|
|
|
|
self.api_key = config["api_key"]
|
|
|
|
self.api_key = config["api_key"]
|
|
|
@ -26,7 +27,8 @@ class LLMProvider(LLMProviderBase):
|
|
|
|
"api_key": self.api_key,
|
|
|
|
"api_key": self.api_key,
|
|
|
|
"app_id": self.app_id,
|
|
|
|
"app_id": self.app_id,
|
|
|
|
"session_id": session_id,
|
|
|
|
"session_id": session_id,
|
|
|
|
"messages": dialogue
|
|
|
|
"messages": dialogue,
|
|
|
|
|
|
|
|
"model" : "qwen-plus"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if self.memory_id != False:
|
|
|
|
if self.memory_id != False:
|
|
|
|
# 百练memory需要prompt参数
|
|
|
|
# 百练memory需要prompt参数
|
|
|
@ -35,7 +37,7 @@ class LLMProvider(LLMProviderBase):
|
|
|
|
call_params["prompt"] = prompt
|
|
|
|
call_params["prompt"] = prompt
|
|
|
|
logger.bind(tag=TAG).debug(f"【阿里百练API服务】处理后的prompt: {prompt}")
|
|
|
|
logger.bind(tag=TAG).debug(f"【阿里百练API服务】处理后的prompt: {prompt}")
|
|
|
|
|
|
|
|
|
|
|
|
responses = Application.call(**call_params)
|
|
|
|
responses = dashscope.Generation.call(**call_params)
|
|
|
|
if responses.status_code != HTTPStatus.OK:
|
|
|
|
if responses.status_code != HTTPStatus.OK:
|
|
|
|
logger.bind(tag=TAG).error(
|
|
|
|
logger.bind(tag=TAG).error(
|
|
|
|
f"code={responses.status_code}, "
|
|
|
|
f"code={responses.status_code}, "
|
|
|
|