Skip to content

Instantly share code, notes, and snippets.

@teshanshanuka
Created August 3, 2023 15:59
Show Gist options
  • Save teshanshanuka/ae2080f33881d126f68b853ea44a1e3f to your computer and use it in GitHub Desktop.
Save teshanshanuka/ae2080f33881d126f68b853ea44a1e3f to your computer and use it in GitHub Desktop.
Simple Bard chat terminal script
#!/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