Created
August 3, 2023 15:59
-
-
Save teshanshanuka/ae2080f33881d126f68b853ea44a1e3f to your computer and use it in GitHub Desktop.
Simple Bard chat terminal script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3.8 | |
# Author: Teshan Liyanage <[email protected]> | |
from Bard import Chatbot | |
# pip install GoogleBard | |
# tokens from Bard webpage: inspect -> Application -> Cookies -> bard.google.com -> __Secure-1PSID, __Secure-1PSIDTS | |
# ANSI colors | |
c_b, c_nc = "\033[94m", "\033[0m" | |
token_1psid = "<__Secure-1PSID>" | |
token_1psidts = "<__Secure-1PSIDTS>" | |
def chat(t1, t2): | |
chatbot = Chatbot(t1, t2) | |
while (ip := input("\n> ")) != "q": | |
if len(ip) < 2: | |
continue | |
resp = chatbot.ask(ip) | |
print(f"\n{c_b}{resp['content']}{c_nc}") | |
if __name__ == "__main__": | |
try: | |
chat(token_1psid, token_1psidts) | |
except (KeyboardInterrupt, EOFError): | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment