Support citing internet sources from Bing response #9

Merged
hibobmaster merged 1 commit from dev into main 2023-04-14 19:39:15 +08:00
2 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
## Introduction
This is a simple Matrix bot that uses OpenAI's GPT API and Bing AI to generate responses to user inputs. The bot responds to five types of prompts: `!gpt`, `!chat` and `!bing` and `!pic` and `!bard` depending on the first word of the prompt.
This is a simple Matrix bot that uses OpenAI's GPT API and Bing AI and Google Bard to generate responses to user inputs. The bot responds to five types of prompts: `!gpt`, `!chat` and `!bing` and `!pic` and `!bard` depending on the first word of the prompt.
![Bing](https://user-images.githubusercontent.com/32976627/231073146-3e380217-a6a2-413d-9203-ab36965b909d.png)
![Bard](https://i.imgur.com/OCXEuaa.png)
![ChatGPT](https://i.imgur.com/kK4rnPf.jpeg)

View file

@ -7,7 +7,7 @@ logger = getlogger()
class BingBot:
def __init__(self, session: aiohttp.ClientSession, bing_api_endpoint: str, jailbreakEnabled: bool = False):
def __init__(self, session: aiohttp.ClientSession, bing_api_endpoint: str, jailbreakEnabled: bool = True):
self.data = {
'clientOptions.clientToUse': 'bing',
}
@ -18,7 +18,7 @@ class BingBot:
self.jailbreakEnabled = jailbreakEnabled
if self.jailbreakEnabled:
self.data['jailbreakConversationId'] = json.dumps(True)
self.data['jailbreakConversationId'] = True
async def ask_bing(self, prompt) -> str:
self.data['message'] = prompt
@ -44,7 +44,7 @@ class BingBot:
self.data['conversationId'] = json_body['conversationId']
self.data['clientId'] = json_body['clientId']
self.data['invocationId'] = json_body['invocationId']
return json_body['response']
return json_body['details']['adaptiveCards'][0]['body'][0]['text']
except Exception as e:
logger.error("Error Exception", exc_info=True)