From 57199b8cee8d11afb3951b814a8d53cb38ddcb1c Mon Sep 17 00:00:00 2001 From: hibobmaster Date: Fri, 14 Apr 2023 19:35:40 +0800 Subject: [PATCH] Support citing internet sources from Bing response --- README.md | 2 +- bing.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2bcd877..927fbcb 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/bing.py b/bing.py index a06c837..ddedff3 100644 --- a/bing.py +++ b/bing.py @@ -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)