-
-
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)) | |
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'
``
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
bro i got also this error in terminal but after runing program it is working
properly
bhai chatgpt.py nhi chal rha kya karun
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.
$ "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
change the line filenamedate = "Brain\DataBase\" + filenamedate this will coreect you have a typo in your code the above code is correct