Support citing internet sources from Bing response
This commit is contained in:
parent
bbd45e78fa
commit
57199b8cee
2 changed files with 4 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
## Introduction
|
## 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)
|
![Bing](https://user-images.githubusercontent.com/32976627/231073146-3e380217-a6a2-413d-9203-ab36965b909d.png)
|
||||||
![Bard](https://i.imgur.com/OCXEuaa.png)
|
![Bard](https://i.imgur.com/OCXEuaa.png)
|
||||||
![ChatGPT](https://i.imgur.com/kK4rnPf.jpeg)
|
![ChatGPT](https://i.imgur.com/kK4rnPf.jpeg)
|
||||||
|
|
6
bing.py
6
bing.py
|
@ -7,7 +7,7 @@ logger = getlogger()
|
||||||
|
|
||||||
|
|
||||||
class BingBot:
|
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 = {
|
self.data = {
|
||||||
'clientOptions.clientToUse': 'bing',
|
'clientOptions.clientToUse': 'bing',
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class BingBot:
|
||||||
self.jailbreakEnabled = jailbreakEnabled
|
self.jailbreakEnabled = jailbreakEnabled
|
||||||
|
|
||||||
if self.jailbreakEnabled:
|
if self.jailbreakEnabled:
|
||||||
self.data['jailbreakConversationId'] = json.dumps(True)
|
self.data['jailbreakConversationId'] = True
|
||||||
|
|
||||||
async def ask_bing(self, prompt) -> str:
|
async def ask_bing(self, prompt) -> str:
|
||||||
self.data['message'] = prompt
|
self.data['message'] = prompt
|
||||||
|
@ -44,7 +44,7 @@ class BingBot:
|
||||||
self.data['conversationId'] = json_body['conversationId']
|
self.data['conversationId'] = json_body['conversationId']
|
||||||
self.data['clientId'] = json_body['clientId']
|
self.data['clientId'] = json_body['clientId']
|
||||||
self.data['invocationId'] = json_body['invocationId']
|
self.data['invocationId'] = json_body['invocationId']
|
||||||
return json_body['response']
|
return json_body['details']['adaptiveCards'][0]['body'][0]['text']
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Error Exception", exc_info=True)
|
logger.error("Error Exception", exc_info=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue