Skip to content

Instantly share code, notes, and snippets.

@KaushikShresth07
Created September 9, 2023 11:25
Show Gist options
  • Select an option

  • Save KaushikShresth07/aa60caba82fe18f2c2d53077e2dfb641 to your computer and use it in GitHub Desktop.

Select an option

Save KaushikShresth07/aa60caba82fe18f2c2d53077e2dfb641 to your computer and use it in GitHub Desktop.
# Text Modification Function -
def split_and_save_paragraphs(data, filename):
paragraphs = data.split('\n\n')
with open(filename, 'w') as file:
file.write(data)
data = paragraphs[:2]
separator = ', '
joined_string = separator.join(data)
return joined_string
# Main Execution
while True:
Question = input("Enter The Query : ")
RealQuestion = str(Question)
results = bard.get_answer(RealQuestion)['content']
current_datetime = datetime.datetime.now()
formatted_time = current_datetime.strftime("%H%M%S")
filenamedate = str(formatted_time) + str(".txt")
filenamedate = "DataBase//" + filenamedate
print(split_and_save_paragraphs(results, filename=filenamedate))
# Image Detection
while True:
imagename = str(input("Enter The Image Name : "))
image = open(imagename,'rb').read()
bard = BardCookies(cookie_dict=cookie_dict)
results = bard.ask_about_image('what is in the image?',image=image)['content']
current_datetime = datetime.datetime.now()
formatted_time = current_datetime.strftime("%H%M%S")
filenamedate = str(formatted_time) + str(".txt")
filenamedate = "DataBase//" + filenamedate
print(split_and_save_paragraphs(results, filename=filenamedate))
@djdhairya

Copy link
Copy Markdown

Traceback (most recent call last):
File "C:\JarAI\Brain\bard.py", line 74, in
print(split_and_save_paragraphs(results, filename=filenamedate))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\JarAI\Brain\bard.py", line 58, in split_and_save_paragraphs
with open(filenamedate, 'w') as file:
^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'DataBase\233533.txt'

@Mohammed-051

Mohammed-051 commented Nov 6, 2023

Copy link
Copy Markdown

``

Traceback (most recent call last): File "C:\JarAI\Brain\bard.py", line 74, in print(split_and_save_paragraphs(results, filename=filenamedate)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\JarAI\Brain\bard.py", line 58, in split_and_save_paragraphs with open(filenamedate, 'w') as file: ^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'DataBase\233533.txt'

`
import os
from bardapi import BardCookies
import datetime

cookie_dict = {
"__Secure-1PSID": "cwgmelgUK2RVvqxg-oxz6BjkoLfvK157joOFuKlNlO1b1kbAgXQ1PAkZkh2XkL-1owW0rg.",
"__Secure-1PSIDTS": "sidts-CjEBSAxbGX-KmQkZqNw7tQalxBNTH5bXJuzKt0K1jdRKPeGLAlNhYvDjFHqT3InsXd_cEEA",
"__Secure-1PSIDCC": "ACA-OxNuCKjHSCKHEmEqY5yPCQtMEtuyr-TI1WOvhrImLD_0ANAmXt__keMD4TARp2KDNr4vS-I",
}
bard = BardCookies(cookie_dict=cookie_dict)

def split_and_save_paragraphs(data, filename):
paragraphs = data.split('\n\n')

directory = os.path.dirname(filename)
os.makedirs(directory, exist_ok=True)

with open(filename, 'w') as file:
    file.write(data)

data = paragraphs[:2]
separator = ', '
joined_string = separator.join(data)
return joined_string

while True:
Question = input("Enter The Query: ")
RealQuestion = str(Question)
results = bard.get_answer(RealQuestion)['content']
current_datetime = datetime.datetime.now()
formatted_time = current_datetime.strftime("%H%M%S")
filenamedate = str(formatted_time) + str(".txt")
filenamedate = "Brain/DataBase/" + filenamedate
print(split_and_save_paragraphs(results, filename=filenamedate))`
Try this fix

@aniway89

Copy link
Copy Markdown

bro i got also this error in terminal but after runing program it is working
properly

@pra-code390

Copy link
Copy Markdown

bhai chatgpt.py nhi chal rha kya karun

@TNTBOYKARTIK

TNTBOYKARTIK commented Nov 27, 2023

Copy link
Copy Markdown

ChatGPT is not working and when i ask Bard about elon musk it is saying that I'm a text-based AI and can't assist with that.

@mahadiul-hasan

Copy link
Copy Markdown

$ "c:/Users/Mahadiul Hasan/Desktop/jarvis/venv/Scripts/python.exe" "c:/Users/Mahadiul Hasan/Desktop/jarvis/Features/ImageDetection.py"
Enter The Image Name : C:\Users\Mahadiul Hasan\Downloads\carousel.jpg
Traceback (most recent call last):
File "c:\Users\Mahadiul Hasan\Desktop\jarvis\Features\ImageDetection.py", line 82, in
results = bard.ask_about_image('what is in the image?',image=image)['content']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mahadiul Hasan\Desktop\jarvis\venv\Lib\site-packages\bardapi\core_cookies.py", line 211, in ask_about_image
return super().ask_about_image(input_text, image, lang)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mahadiul Hasan\Desktop\jarvis\venv\Lib\site-packages\bardapi\core.py", line 674, in ask_about_image
translator_to_eng = GoogleTranslator(source="auto", target="en")
^^^^^^^^^^^^^^^^
NameError: name 'GoogleTranslator' is not defined

This error given in image ditection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment