priyanshuverma-dev / bard-chatbot

A Python-based chatbot project that integrates the Bard API for natural language processing and voice interaction. This chatbot can listen to voice input, process user queries, and respond with audio output.
MIT License
3 stars 2 forks source link

Add Function to open a website #1

Open priyanshuverma-dev opened 11 months ago

priyanshuverma-dev commented 11 months ago

Write an "if" statement to open a website when a user says any keyword in a query.

sukhmani1303 commented 11 months ago

I would love to contribute to this issue. Can you elaborate on the issue a little more, please?

imkrishnasarathi commented 11 months ago

I would like to contribute to this, but I need to know what website needs to be opened, like more details

priyanshuverma-dev commented 11 months ago

Any website that user wants like: user says: please open YouTube for me. user says: open google.com

imkrishnasarathi commented 11 months ago

I am a bit busy today. Please wait. I will send a PR by today night if I complete it :)

imkrishnasarathi commented 11 months ago

When I run your program:- Traceback (most recent call last): File "C:\Users\HP\PycharmProjects\bard-chatbot\bard.py", line 2, in <module> from bardapi import BardCookies File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\__init__.py", line 4, in <module> from bardapi.core import Bard File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core.py", line 28, in <module> from bardapi.models.result import BardResult File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\result.py", line 3, in <module> from bardapi.models.draft import BardDraft File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\draft.py", line 9, in <module> from bardapi.models.tools.map import BardMapContent File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py", line 6, in <module> class BardMapsPoint: File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py", line 58, in BardMapsPoint def title(self) -> Tuple[str, str]: ^^^^^ NameError: name 'Tuple' is not defined. Did you mean: 'tuple'?

imkrishnasarathi commented 11 months ago

If I go ahead and edit the map.py to have from typing import Tuple, I get this

C:\Users\HP\PycharmProjects\bard-chatbot\venv\Scripts\python.exe C:\Users\HP\PycharmProjects\bard-chatbot\bard.py 
Traceback (most recent call last):
  File "C:\Users\HP\PycharmProjects\bard-chatbot\bard.py", line 2, in <module>
    from bardapi import BardCookies, Bard
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\__init__.py", line 4, in <module>
    from bardapi.core import Bard
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core.py", line 28, in <module>
    from bardapi.models.result import BardResult
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\result.py", line 3, in <module>
    from bardapi.models.draft import BardDraft
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\draft.py", line 9, in <module>
    from bardapi.models.tools.map import BardMapContent
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py", line 124, in <module>
    class BardMapsDirections:
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py", line 141, in BardMapsDirections
    def sections(self) -> List[BardMapsRoadSection]:
                          ^^^^
NameError: name 'List' is not defined. Did you mean: 'list'?

Process finished with exit code 1
priyanshuverma-dev commented 11 months ago

See the readme file: (Optional) Make changes in .venv\Lib\site-packages\bardapi\core.py if gives any error like requests not found.

add at top:

import requests

(Optional) Make changes in ..venv\Lib\site-packages\bardapi\models\tools\map.py if gives any error like Tuple not found. add at top:

from typing import Optional, Tuple, List
priyanshuverma-dev commented 11 months ago

If I go ahead and edit the map.py to have from typing import Tuple, I get this

C:\Users\HP\PycharmProjects\bard-chatbot\venv\Scripts\python.exe C:\Users\HP\PycharmProjects\bard-chatbot\bard.py 
Traceback (most recent call last):
  File "C:\Users\HP\PycharmProjects\bard-chatbot\bard.py", line 2, in <module>
    from bardapi import BardCookies, Bard
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\__init__.py", line 4, in <module>
    from bardapi.core import Bard
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core.py", line 28, in <module>
    from bardapi.models.result import BardResult
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\result.py", line 3, in <module>
    from bardapi.models.draft import BardDraft
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\draft.py", line 9, in <module>
    from bardapi.models.tools.map import BardMapContent
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py", line 124, in <module>
    class BardMapsDirections:
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py", line 141, in BardMapsDirections
    def sections(self) -> List[BardMapsRoadSection]:
                          ^^^^
NameError: name 'List' is not defined. Did you mean: 'list'?

Process finished with exit code 1

do this: (Optional) Make changes in C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\models\tools\map.py if gives any error like Tuple not found. add at top:

from typing import Optional, Tuple, List

@imkrishnasarathi

imkrishnasarathi commented 11 months ago

ok thanks. I got a school assignment today, so I couldn't keep my words. I will try to complete it by tmmro noon. Please don't reassign it to anyone :)

priyanshuverma-dev commented 11 months ago

@imkrishnasarathi Not problem. I am also a school student I can understand. I will not unassign you. As we are friends.👏

imkrishnasarathi commented 11 months ago

Now this :-

Traceback (most recent call last):
  File "C:\Users\HP\PycharmProjects\bard-chatbot\bard.py", line 2, in <module>
    from bardapi import BardCookies, Bard
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\__init__.py", line 4, in <module>
    from bardapi.core import Bard
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core.py", line 39, in <module>
    class Bard:
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core.py", line 49, in Bard
    session: Optional[requests.Session] = None,
                      ^^^^^^^^
NameError: name 'requests' is not defined
imkrishnasarathi commented 11 months ago

If I import requests in the core.py file, then I get this:-

Traceback (most recent call last):
  File "C:\Users\HP\PycharmProjects\bard-chatbot\bard.py", line 33, in <module>
    bard = BardCookies(cookie_dict=bard_dict, language="english")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core_cookies.py", line 53, in __init__
    self.SNlM0e = self._get_snim0e()
                  ^^^^^^^^^^^^^^^^^^
  File "C:\Users\HP\PycharmProjects\bard-chatbot\venv\Lib\site-packages\bardapi\core_cookies.py", line 119, in _get_snim0e
    raise Exception(
Exception: SNlM0e value not found in response. Check __Secure-1PSID value.
priyanshuverma-dev commented 11 months ago

Add .env file. Check readme.md and contributing.md for that @imkrishnasarathi . You will get token from bard.google.com In cookies:

imkrishnasarathi commented 11 months ago

Ok thanks

imkrishnasarathi commented 11 months ago

Done. Submitted a PR

sukhmani1303 commented 11 months ago

🚨 I don't think the issue is resolved yet... this issue is not just any if-else type of problem as context & sentiment must also be considered. For example; if someone types "I cannot open youtube.com due to XYZ error. What should I do?" In this case, @imkrishnasarathi 's code will open the website but that was not what the user asked for. The solution to this issue is relatively comprehensive where you need to identify if the user wants to open a website or wants an answer. This can be solved by either training your own model using custom data (query - answer) which is for this particular task only or using any other pre-trained summarize etc.... & based on its output we can decide if to open a webpage or provide an answer @p7uverma

imkrishnasarathi commented 11 months ago

Oh I just did the simple solution for just opening it

On Thu, 5 Oct, 2023, 9:50 PM YUVRAJ SINGH SUKHMANI, < @.***> wrote:

🚨 I don't think the issue is resolved yet... this issue is not just any if-else type of problem as context & sentiment must also be considered. For example; if someone types "I cannot open youtube.com due to XYZ error. What should I do?" In this case, @imkrishnasarathi https://github.com/imkrishnasarathi 's code will open the website but that was not what the user asked for. The solution to this issue is relatively comprehensive where you need to identify if the user wants to open a website or wants an answer. This can be solved by either training your own model using custom data (query - answer) which is for this particular task only or using any other pre-trained summarize etc.... & based on its output we can decide if to open a webpage or provide an answer @p7uverma https://github.com/p7uverma

— Reply to this email directly, view it on GitHub https://github.com/p7uverma/bard-chatbot/issues/1#issuecomment-1749253854, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUO4KGGXZTKEDUXH5OOQLYDX53M3XAVCNFSM6AAAAAA5PGTVGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGI2TGOBVGQ . You are receiving this because you were mentioned.Message ID: @.***>

priyanshuverma-dev commented 11 months ago

@sukhmani1303 Got you! If you're able to do that try and fix this. I have assigned you this task.

sukhmani1303 commented 11 months ago

It's a very comprehensive issue actually... will take a lot of time but i will try 👍