feat: bing模型支持显示信息来源 #70

This commit is contained in:
Soulter
2023-04-19 17:22:59 +08:00
parent e2bd612b8e
commit a5c43612bf
+18 -3
View File
@@ -31,8 +31,13 @@ class ProviderRevEdgeGPT(Provider):
while err_count < retry_count:
try:
resp = await self.bot.ask(prompt=prompt, conversation_style=ConversationStyle.creative)
# print("[RevEdgeGPT] "+str(resp))
reply_msg = resp['item']['messages'][len(resp['item']['messages'])-1]['text']
print("[RevEdgeGPT] "+str(resp))
msj_obj = resp['item']['messages'][len(resp['item']['messages'])-1]
reply_msg = msj_obj['text']
if 'sourceAttributions' in msj_obj:
reply_source = msj_obj['sourceAttributions']
else:
reply_source = []
if 'throttling' in resp['item']:
throttling = resp['item']['throttling']
# print(throttling)
@@ -46,8 +51,18 @@ class ProviderRevEdgeGPT(Provider):
await self.forget()
err_count += 1
continue
if reply_msg is None:
# 不想答复
return '', 0
else:
index = 1
if len(reply_source) > 0:
reply_msg += "\n\n信息来源:\n"
for i in reply_source:
reply_msg += f"[{str(index)}]: {i['seeMoreUrl']} | {i['providerDisplayName']}\n"
index += 1
if throttling is not None:
reply_msg += f"\n{throttling['numUserMessagesInConversation']}/{throttling['maxNumUserMessagesInConversation']}"
reply_msg += f"\n{throttling['numUserMessagesInConversation']}/{throttling['maxNumUserMessagesInConversation']}"
break
except BaseException as e:
# raise e