mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-18 12:40:06 +08:00
Merge pull request #2247 from byang822/abacusoft-alex
wenxin character model supports prompt
This commit is contained in:
@@ -19,6 +19,11 @@ class BaiduWenxinBot(Bot):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
wenxin_model = conf().get("baidu_wenxin_model")
|
wenxin_model = conf().get("baidu_wenxin_model")
|
||||||
|
self.prompt_enabled = conf().get("baidu_wenxin_prompt_enabled")
|
||||||
|
if self.prompt_enabled:
|
||||||
|
self.prompt = conf().get("character_desc", "")
|
||||||
|
if self.prompt == "":
|
||||||
|
logger.warn("[BAIDU] Although you enabled model prompt, character_desc is not specified.")
|
||||||
if wenxin_model is not None:
|
if wenxin_model is not None:
|
||||||
wenxin_model = conf().get("baidu_wenxin_model") or "eb-instant"
|
wenxin_model = conf().get("baidu_wenxin_model") or "eb-instant"
|
||||||
else:
|
else:
|
||||||
@@ -84,7 +89,7 @@ class BaiduWenxinBot(Bot):
|
|||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
payload = {'messages': session.messages}
|
payload = {'messages': session.messages, 'system': self.prompt} if self.prompt_enabled else {'messages': session.messages}
|
||||||
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
|
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
|
||||||
response_text = json.loads(response.text)
|
response_text = json.loads(response.text)
|
||||||
logger.info(f"[BAIDU] response text={response_text}")
|
logger.info(f"[BAIDU] response text={response_text}")
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ available_setting = {
|
|||||||
"baidu_wenxin_model": "eb-instant", # 默认使用ERNIE-Bot-turbo模型
|
"baidu_wenxin_model": "eb-instant", # 默认使用ERNIE-Bot-turbo模型
|
||||||
"baidu_wenxin_api_key": "", # Baidu api key
|
"baidu_wenxin_api_key": "", # Baidu api key
|
||||||
"baidu_wenxin_secret_key": "", # Baidu secret key
|
"baidu_wenxin_secret_key": "", # Baidu secret key
|
||||||
|
"baidu_wenxin_prompt_enabled": False, # Enable prompt if you are using ernie character model
|
||||||
# 讯飞星火API
|
# 讯飞星火API
|
||||||
"xunfei_app_id": "", # 讯飞应用ID
|
"xunfei_app_id": "", # 讯飞应用ID
|
||||||
"xunfei_api_key": "", # 讯飞 API key
|
"xunfei_api_key": "", # 讯飞 API key
|
||||||
|
|||||||
Reference in New Issue
Block a user