Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/data/data/com.termux/files/usr/bin/python3
- from bardapi import Bard
- import sys
- import json
- sys.stdout.reconfigure(encoding='utf-8')
- input_text = sys.argv[1]
- token = '__Secure-1PSID'
- bard = Bard(token=token, timeout=30)
- res = bard.get_answer(input_text)
- content = res['content']
- choices = res['choices']
- query = res['textQuery']
- links = res['links']
- imgset = res['images']
- conv_id = res['conversation_id']
- resp_id = res['response_id']
- facts = res['factualityQueries']
- images = list(imgset)
- output = {
- "content": (content),
- "choices": (choices),
- "conv_id": (conv_id),
- "resp_id": (resp_id),
- "links": (links),
- "images": (images),
- "facts": (facts),
- "enquiry": (query)
- }
- bardReply = json.dumps(output)
- with open("/data/data/com.termux/files/home/bard/output.txt", "w") as f:
- print("Links: ", (links), file=f)
- print(("Images: ", images), file=f)
- bpath = "/sdcard/Tasker Logs/Bard/json/"
- apath = "/sdcard/Tasker\ Logs/Bard/json/"
- with open(f'{bpath}{conv_id}.json', "w", encoding='utf-8') as jf:
- print((bardReply), file=jf)
- #sys.stdout.write(conv_id)
- print(f'{apath}{conv_id}.json')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement