Skip to content

Commit

Permalink
Merge pull request #9 from hibobmaster/dev
Browse files Browse the repository at this point in the history
Support citing internet sources from Bing response
  • Loading branch information
hibobmaster authored Apr 14, 2023
2 parents b620dd2 + 57199b8 commit 1d0d175
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


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',
}
Expand All @@ -18,7 +18,7 @@ def __init__(self, session: aiohttp.ClientSession, bing_api_endpoint: str, jailb
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
Expand All @@ -44,7 +44,7 @@ async def ask_bing(self, prompt) -> str:
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)

Expand Down

0 comments on commit 1d0d175

Please sign in to comment.