From a7396007143f5c27c2003a8fe01c5fbc365fa81b Mon Sep 17 00:00:00 2001 From: CBoYXD Date: Wed, 9 Aug 2023 17:40:49 +0300 Subject: [PATCH 1/2] Add google_api_key in chat --- bardapi/chat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bardapi/chat.py b/bardapi/chat.py index 00b414fcf..d12593042 100644 --- a/bardapi/chat.py +++ b/bardapi/chat.py @@ -27,6 +27,7 @@ def __init__( token: str = None, timeout: int = 20, proxies: dict = None, + google_translator_api_key: str = None, session: requests.Session = None, language: str = None, ): @@ -70,11 +71,13 @@ def __init__( or print("Bard API(__Secure-1PSID) Key must be entered.") ) self.proxies = proxies + self.google_translator_api_key = google_translator_api_key # Set Bard object self.bard = Bard( token=self.token, session=self.session, + google_translator_api_key=self.google_translator_api_key, timeout=self.timeout, language=self.language, proxies=self.proxies, From fad7741dea0b7dd35118a612f25ce49f83ebc122 Mon Sep 17 00:00:00 2001 From: CBoYXD Date: Wed, 9 Aug 2023 17:52:07 +0300 Subject: [PATCH 2/2] Fix README_DEV --- documents/README_DEV.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/documents/README_DEV.md b/documents/README_DEV.md index c73afa2a8..79fe03d3d 100644 --- a/documents/README_DEV.md +++ b/documents/README_DEV.md @@ -126,7 +126,7 @@ audio = bard.speech("Hello, I am bard! How can I assist you?", lang='en-US') # G # Save audio object. with open('bard_response.mp3', 'wb') as f: - f.write(audio) + f.write(audio['audio']) ```
@@ -167,6 +167,7 @@ from bardapi import Bard bard = Bard(token='xxxxxxxx') image = open('image.jpg', 'rb').read() # (jpeg, png, webp) are supported. bard_answer = bard.ask_about_image('What is in the image?', image) +print(bard_answer['content']) ```
@@ -231,7 +232,7 @@ from bardapi import Bard bard = Bard(token='xxxxxxxx') bard_answer = bard.get_answer('How are you?') url = bard.export_conversation(bard_answer, title='Example Shared conversation') -print(url) +print(url['url']) ``` @@ -249,7 +250,7 @@ url = bard.export_replit( code=bard_answer['code'], langcode=bard_answer['langCode'], ) -print(url) # https://replit.com/external/v1/claims/xxx/claim +print(url['url']) # https://replit.com/external/v1/claims/xxx/claim ```
@@ -300,7 +301,7 @@ cookie_dict = { } bard = BardCookies(cookie_dict=cookie_dict) -print(bard.get_answer("こんにちは")) +print(bard.get_answer("こんにちは")['content']) ```
@@ -374,7 +375,7 @@ chat.start() #### Features Customize User Prompt Users can customize the prompt displayed to the user before input by providing a custom prompt message to the start() method. -```pythno +```python chat.start(prompt="Enter your message: ") ```