Giter VIP home page Giter VIP logo

talkingheads's People

Contributors

codekiln avatar itsmeadarsh2008 avatar ugorsahin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

talkingheads's Issues

exception by selecting model GPT-4

Super project!!! Thx.
In Chrome browser GPT-4 is correctly selected as default.

Ran correctly until now.
Since 1 day (?) unfortunately always the model GPT-3.5 is selected using this ChatGPT_Client.
The WebUI has changed a bit ;-(

calling
chatgpt.switch_model("GPT-4")
returns the error message:

Exception has occurred: ElementClickInterceptedException       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Message: element click intercepted: Element <span class="truncate text-sm font-medium md:pr-1.5 pr-1.5">...</span> is not clickable at point (1177, 49). Other element would receive the click: <div class="grid-cols-[10px_1fr_10px] grid h-full w-full grid-rows-[minmax(10px,_1fr)_auto_minmax(10px,_1fr)] md:grid-rows-[minmax(20px,_1fr)_auto_minmax(20px,_1fr)] overflow-y-auto">...</div>
  (Session info: chrome=114.0.5735.133)

Would be great if this works again to use the pro account properly.

No module named 'undetected_chromedriver'

>>> from chatgpt_automation.chatgpt_client import ChatGPT_Client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/c/Users/srskr/ChatGPT_Automation/chatgpt_automation/chatgpt_client.py", line 4, in <module>
    import undetected_chromedriver as uc
ModuleNotFoundError: No module named 'undetected_chromedriver'

Though I did "pip install ."
Just plain "pip install undetected_chromedriver" solved the problem. It could be specified in setup.py

Error on example script

Hello, you're projects seems awesome!
Unfortunately, I cannot get it to work.
I am trying to run the example:

from handler import Handler

chatgpt = Handler("spasswd", "spasswd")
answer = chatgpt.interact("Hellow, how are you today")
print(answer)

I am using python 3.10.10 and Linux.

This is the error I get:

Traceback (most recent call last):
  File "$HOME/ChatGPT_Selenium/main.py", line 3, in <module>
    chatgpt = Handler("spasswd", "spasswd")
  File "$HOME/ChatGPT_Selenium/handler.py", line 94, in __init__
    self.browser = uc.Chrome(options=options)
  File "$HOME/ChatGPT_Selenium/env/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 409, in __init__
    browser = subprocess.Popen(
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1722, in _execute_child
    and os.path.dirname(executable)
  File "/usr/lib/python3.10/posixpath.py", line 152, in dirname
    p = os.fspath(p)

No Such Element for reset_xq

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[text()="New chat"]"}
(Session info: chrome=113.0.5672.127)

so it should be replaced by
reset_xq = '//a[span[text()="New chat"]]'

Unable to locate text area tag. Switching to ID search

2023/08/24 00:07:44 INFO Verbose mode active
2023/08/24 00:07:44 INFO Loading undetected Chrome
2023/08/24 00:07:44 INFO patching driver executable ./chromedriver.exe
2023/08/24 00:07:44 INFO Loaded Undetected chrome
2023/08/24 00:07:44 INFO Opening chatgpt
2023/08/24 00:07:46 INFO Element //button[//div[text()="Log in"]] has found
2023/08/24 00:07:46 INFO Clicked login button
2023/08/24 00:07:48 INFO Element username has found
2023/08/24 00:07:48 INFO Filled email box
2023/08/24 00:07:48 INFO Element //button[text()="Continue"] has found
2023/08/24 00:07:50 INFO Clicked continue button
2023/08/24 00:07:50 INFO Element password has found
2023/08/24 00:07:50 INFO Filled password box
2023/08/24 00:07:53 INFO Logged in
2023/08/24 00:07:58 INFO Info screen skipped
2023/08/24 00:07:58 INFO ChatGPT is ready to interact
2023/08/24 00:07:58 INFO Unable to locate text area tag. Switching to ID search
Traceback (most recent call last):
File "c:/Users/iMusic/Desktop/chatgpt_headless_chrome/chatgpt_automata.py", line 18, in
answer = chatgpt.interact(question="based on eva lyrics, to summarize its keywords")
File "C:\Users\iMusic\AppData\Local\Programs\Python\Python38\lib\site-packages\chatgpt_automation\chatgpt_client.py", line 258, in interact
raise RuntimeError('Unable to find the text prompt area. Please raise an issue with verbose=True')
RuntimeError: Unable to find the text prompt area. Please raise an issue with verbose=True

ChatGPT unable to locate TextArea

Last 3 - 5 days I faced the issue.

GPT Client does not able to locate text are field.

I have next funciton that is called once an hour without saving sessions. Some automated script is running via cron every hour

def ask_question(self, question):
    chat_head = ChatGPTClient()
    response = chat_head.interact(question)
    logger.debug("EasyGpt: %s", response)
    return response

The trace is:

2024-04-20 10:12:18,652: ChatGPT: Loaded undetected Chrome
2024-04-20 10:12:18,670: ChatGPT: Opening ChatGPT
2024-04-20 10:12:18,671: ChatGPT: The preload behavior is not implemented
2024-04-20 10:12:19,934: ChatGPT: Waiting element //button[//div[text()='Log in']] to appear.
2024-04-20 10:12:19,943: ChatGPT: Element //button[//div[text()='Log in']] appeared.
2024-04-20 10:12:20,227: ChatGPT: Clicked login button
2024-04-20 10:12:21,231: ChatGPT: Waiting element //input[@class='email-input' or @id='username'] to appear.
2024-04-20 10:12:21,313: ChatGPT: Element //input[@class='email-input' or @id='username'] appeared.
2024-04-20 10:12:21,585: ChatGPT: Filled email box
2024-04-20 10:12:21,585: ChatGPT: Waiting element //button[text()='Continue'] to appear.
2024-04-20 10:12:21,595: ChatGPT: Element //button[text()='Continue'] appeared.
2024-04-20 10:12:24,095: ChatGPT: Clicked continue button
2024-04-20 10:12:24,095: ChatGPT: Waiting element password to appear.
2024-04-20 10:12:24,104: ChatGPT: Element password appeared.
2024-04-20 10:12:24,140: ChatGPT: Filled password box
2024-04-20 10:12:25,166: ChatGPT: Logged in
2024-04-20 10:12:30,268: ChatGPT: Info screen skipped
2024-04-20 10:12:30,271: ChatGPT: ChatGPT is ready to interact
2024-04-20 10:12:30,283: ChatGPT: Unable to locate text area tag. Switching to ID search
2024-04-20 10:12:30,320: src.processor: Unable to find the text prompt area. Please raise an issue with verbose=True

In headles=False Mode i see this image:

image

[QUESTION] Why did you write the code this way?

in chatgpt_client.py , line 262

    for each_line in question.split('\n'):
        text_area.send_keys(each_line)
        text_area.send_keys(Keys.SHIFT + Keys.ENTER)

Why did you split based on \n?
If you don't do this, will openAI detect an anomaly?

Can't I just insert it all at once instead of splitting it (by \n)?

Cant work on command-line CentOS 8 system

I'm running this code on a command-line CentOS 8 system, using Chrome 112 with headless mode enabled. However, I'm consistently facing login issues. The process seems to get stuck at the following point.
I'm wondering if there's any way to provide assistance in resolving this?
Your help would be greatly appreciated!!!!

File "/root/gptAuto/main.py", line 3, in
chatgpt = ChatGPT_Client(XXX,XXX)
File "/usr/local/lib/python3.9/site-packages/chatgpt_automation/chatgpt_client.py", line 88, in init
self.pass_verification()
File "/usr/local/lib/python3.9/site-packages/chatgpt_automation/chatgpt_client.py", line 111, in pass_verification
time.sleep(1)

Consider using find_chrome_executable from undetected_chromedriver in detect_chrome_version

On mac, I don't think google-chrome is normally added to path. undetected-chromedriver has a function find_chrome_executable that looks designed to find chrome in a way that supports more platform way; consider using that.

dev/TalkingHeads/src/talkingheads/utils.py", line 36, in detect_chrome_version
    out = subprocess.check_output(['google-chrome', '--version'])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'google-chrome'

from undetected_chromedriver import find_chrome_executable
find_chrome_executable()
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'

HTTP Error 404: Not Found

Hi.An error occurred while using. It remains the same even though you used the "pip install -e git+https://github.com/jdholtz/undetected-chromedriver.git@29551bd27954dacaf09864cf77935524db642c1b#egg=undetected_chromedriver " on the Issue tab. How do you want me to fix it?

`---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_25336/947264807.py in
1 from chatgpt_automation import ChatGPT_Client
2
----> 3 chatgpt = ChatGPT_Client(YOUR_USERNAME, YOUR_PASSWORD)
4
5 answer = chatgpt.interact("Hello, how are you today")

~\anaconda3\lib\site-packages\chatgpt_automation\chatgpt_client.py in init(self, username, password, headless, cold_start, incognito, driver_executable_path, driver_arguments, driver_version, verbose)
88 self.browser.get('https://chat.openai.com/auth/login?next=/chat')
89 if not cold_start:
---> 90 self.pass_verification()
91 self.login(username, password)
92 logging.info('ChatGPT is ready to interact')

~\anaconda3\lib\site-packages\undetected_chromedriver_init_.py in init(self, options, user_data_dir, driver_executable_path, browser_executable_path, port, enable_cdp_events, service_args, service_creationflags, desired_capabilities, advanced_elements, service_log_path, keep_alive, log_level, headless, version_main, patcher_force_close, suppress_welcome, use_subprocess, debug, no_sandbox, **kw)

~\anaconda3\lib\site-packages\undetected_chromedriver\patcher.py in auto(self, executable_path, force, version_main)

~\anaconda3\lib\site-packages\undetected_chromedriver\patcher.py in fetch_release_number(self)

~\anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
212 else:
213 opener = _opener
--> 214 return opener.open(url, data, timeout)
215
216 def install_opener(opener):

~\anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout)
521 for processor in self.process_response.get(protocol, []):
522 meth = getattr(processor, meth_name)
--> 523 response = meth(req, response)
524
525 return response

~\anaconda3\lib\urllib\request.py in http_response(self, request, response)
630 # request was successfully received, understood, and accepted.
631 if not (200 <= code < 300):
--> 632 response = self.parent.error(
633 'http', request, response, code, msg, hdrs)
634

~\anaconda3\lib\urllib\request.py in error(self, proto, *args)
559 if http_err:
560 args = (dict, 'default', 'http_error_default') + orig_args
--> 561 return self._call_chain(*args)
562
563 # XXX probably also want an abstract factory that knows when it makes

~\anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
492 for handler in handlers:
493 func = getattr(handler, meth_name)
--> 494 result = func(*args)
495 if result is not None:
496 return result

~\anaconda3\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs)
639 class HTTPDefaultErrorHandler(BaseHandler):
640 def http_error_default(self, req, fp, code, msg, hdrs):
--> 641 raise HTTPError(req.full_url, code, msg, hdrs, fp)
642
643 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found`

Unable to find the text prompt area. Please raise an issue with verbose=True

Code:

from talkingheads import ChatGPTClient
chathead = ChatGPTClient(
    cold_start=True,
    incognito=False,
    headless=False,
    user_data_dir='/Users/ishandutta2007/Library/Application Support/BraveSoftware/Brave-Browser/Default'
)
answer = chathead.interact("Hello, how are you today")
print(answer)

Command:

python mycodefile.py  --verbose=True

Error:

Traceback (most recent call last):
File "index.py", line 65, in
answer = chathead.interact("Hello, how are you today")
File "/Users/ishandutta2007/.pyenv/versions/3.8.0/lib/python3.8/site-packages/talkingheads/model_library/chatgpt.py", line 133, in interact
raise RuntimeError(
RuntimeError: Unable to find the text prompt area. Please raise an issue with verbose=True

  • I am facing same issue with HuggingChatClient as well. For Claude and Gemini the webdriver launches just fine for me to login.
  • I am on OSX 10.15
  • My python version is 3.8.0

[FEATURE] Login with Google

OpenAI has more than one type of login options. One of them is Google SSO.

A feature to automate the whole process from clicking button to completing SSO.

Previously mentioned #15

improve

Adding a time.sleep to this function can prevent the browser from slowing down and the logo being output has not been loaded. This situation often occurs on computers with poor performance.

def wait_to_disappear(self, by, query, sleep_duration=1):
'''
Waits until the specified web element disappears from the page.

    This function continuously checks for the presence of a web element.
    It waits until the element is no longer present on the page.
    Once the element has disappeared, the function returns.

    Args:
        by (selenium.webdriver.common.by.By): The method used to locate the element.
        query (str): The query string to locate the element.
        sleep_duration (int, optional): The duration to sleep between checks. Default: 1.

    Returns:
        None
    '''
    !!!!!!!!!!!!here!!!!!!
    time.sleep(1)
    !!!!!!!!!!!! here !!!!!!!!
    while True:
        thinking = self.browser.find_elements(by, query)
        if len(thinking) == 0:
            logging.info(f'Element {query} is present, waiting')
            break
        time.sleep(sleep_duration)
    return

selecting ChatGPT model and regenerate?

Hi. This code works great so far. I have two questions:

(1) I'd like to choose ChatGPT4 sometimes and ChatGPT3.5 other times. When I manually open a new chat with a ChatGPT Plus subscription, I see a model selection dropdown at the top of the page. How can I access that through the object returned by ChatGPT_Client(args.username, args.password) and make the appropriate selection? I'm not proficient in HTML but it doesn't look like a regular dropdown menu to me. Here is the button that allows the user to see the model options:

<button class="relative flex cursor-pointer flex-col rounded-md bg-white py-2 pl-3 pr-10 text-left dark:bg-gray-800 sm:text-sm w-full border border-black/10 focus:border-green-600 focus:outline-none focus:ring-1 focus:ring-green-600 dark:border-white/20" id="headlessui-listbox-button-:r1r:" type="button" aria-haspopup="true" aria-expanded="true" data-headlessui-state="open" aria-labelledby="headlessui-listbox-label-:r1s: headlessui-listbox-button-:r1r:" aria-controls="headlessui-listbox-options-:r2c:"><label class="block text-xs text-gray-700 dark:text-gray-500" id="headlessui-listbox-label-:r1s:" data-headlessui-state="open">Model</label><span class="inline-flex w-full truncate"><span class="flex h-6 items-center gap-1 truncate">GPT-4</span></span><span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4 text-gray-400" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><polyline points="6 9 12 15 18 9"></polyline></svg></span></button>

The options are "ChatGPT-3.5", the default, and "ChatGPT-4", which must be selected if desired. Here is the code for that option:

<li class="group relative flex h-[42px] cursor-pointer select-none items-center overflow-hidden border-b border-black/10 pl-3 pr-9 last:border-0 dark:border-white/20 text-gray-900" id="headlessui-listbox-option-:r2h:" role="option" tabindex="-1" aria-selected="false" data-headlessui-state=""><span class="flex items-center gap-1.5 truncate"><span class="flex h-6 items-center gap-1 text-gray-800 dark:text-gray-100">GPT-4</span></span></li>

(2) There are times when I'd prefer to hit the "regenerate" button rather than resubmitting the same question since doing so does not, I believe, contribute to the ChatGPT4 usage limits. How do I access this button?

Exception occurred: WebDriverException (Windows 10)

my code is
from talkingheads import ChatGPTClient
chathead = ChatGPTClient(
incognito=False,
user_data_dir='C:/.........../Google/Chrome/User Data',
credential_check=False,
skip_login=True
)

my uc version is 3.5.x
chrome version is 119.x
but the error occur:

2023/12/01 21:54:29 WARNING Windows detected, no version number is provided, default: 112
---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)

.........................

WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:10568
from chrome not reachable
Stacktrace:
Backtrace:
	GetHandleVerifier [0x00BEDCE3+50899]
	(No symbol) [0x00B7E111]
	(No symbol) [0x00A85450]
	(No symbol) [0x00A7B2B5]
	(No symbol) [0x00AA51C8]
	(No symbol) [0x00A9F5B1]
	(No symbol) [0x00A9F391]
	(No symbol) [0x00AD1FFE]
	(No symbol) [0x00AD1CEC]
	(No symbol) [0x00ACB6F6]
	(No symbol) [0x00AA7708]
	(No symbol) [0x00AA886D]
	GetHandleVerifier [0x00E53EAE+2566302]
	GetHandleVerifier [0x00E892B1+2784417]
	GetHandleVerifier [0x00E8327C+2759788]
	GetHandleVerifier [0x00C85740+672048]
	(No symbol) [0x00B88872]
	(No symbol) [0x00B841C8]
	(No symbol) [0x00B842AB]
	(No symbol) [0x00B771B7]
	BaseThreadInitThunk [0x751BFCC9+25]
	RtlGetAppContainerNamedObjectPath [0x770B7C6E+286]
	RtlGetAppContainerNamedObjectPath [0x770B7C3E+238]

[BUG] Error in pass_verification, the service not load...

Traceback (most recent call last):
File "code.py", line 18, in
chatgpt = ChatGPT_Client(OPENAI_EMAIL, OPENAI_PASSWORD)
File "/usr/local/lib/python3.8/site-packages/chatgpt_automation/chatgpt_client.py", line 105, in init
self.pass_verification()
File "/usr/local/lib/python3.8/site-packages/chatgpt_automation/chatgpt_client.py", line 146, in pass_verification
verify_button[0].click()
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 93, in click
self._execute(Command.CLICK_ELEMENT)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 394, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: stale element not found
(Session info: chrome=117.0.5938.92); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#stale-element-reference-exception
Stacktrace:
#0 0x56149368c6b3
#1 0x5614933621e7
#2 0x56149336ff09
#3 0x561493367644
#4 0x56149336625b
#5 0x5614933689c0
#6 0x561493368a7c
#7 0x5614933aae19
#8 0x56149339f451
#9 0x5614933cb0c2
#10 0x56149339ef16
#11 0x5614933cb28e
#12 0x5614933e4322
#13 0x5614933cae93
#14 0x56149339d934
#15 0x56149339e71e
#16 0x561493651cb8
#17 0x561493655bf0
#18 0x56149366019c
#19 0x561493656808
#20 0x56149362327f
#21 0x56149367ae88
#22 0x56149367b059
#23 0x56149368b843
#24 0x7ff5b955c044

2023/11/27 17:55:42 ERROR It is not possible to pass verification

I successfully used your library https://github.com/ugorsahin/ChatGPT_Automation on September 6, 2023. I had installed on my Windows 10 PC:

  • Google Chrome Version 116.0.5845.188 (Official Build) (64 bits)
  • Stable version 116.0.5845.96 of chromedriver.exe installed in C:\Program Files\Google\Chrome\Application
  • Selenium version 4.9.0

My Google Chrome version has been updated to 119.0.6045.160 (Official Build) (64 bits), and I've changed chromedriver.exe stable version to 119.0.6045.105 (even tried 119.0.6045.159).
I'm installing https://github.com/ugorsahin/TalkingHeads with 'pip install talkingheads', which forces the installation of Selenium version 4.15.2:

Installing collected packages: selenium, talkingheads
Attempting uninstall: selenium
Found existing installation: selenium 4.9.0
Uninstalling selenium-4.9.0:
Successfully uninstalled selenium-4.9.0
Successfully installed selenium-4.15.2 talkingheads-0.2.1

However, the Python instruction chathead = ChatGPTClient(username=username, password=password, driver_version=119, verbose=True) no longer works:

2023/11/27 17:55:16 WARNING The usage of username and password parameters are deprecated and will be removed in near feature.Please adjust your environment variables to pass username and password.
2023/11/27 17:55:16 INFO Verbose mode active
2023/11/27 17:55:16 INFO Loading undetected Chrome
2023/11/27 17:55:29 INFO patching driver executable C:\Users\Free_Max367\appdata\roaming\undetected_chromedriver\undetected_chromedriver.exe
2023/11/27 17:55:30 INFO Loaded Undetected chrome
2023/11/27 17:55:30 INFO Opening ChatGPT
2023/11/27 17:55:30 INFO Preload behaviour is not implemented, that may be normal if verification is not necessary
2023/11/27 17:55:31 INFO Verification button is not present or clickable
2023/11/27 17:55:32 INFO Clicked verification button
2023/11/27 17:55:33 INFO Clicked verification button
2023/11/27 17:55:34 INFO Clicked verification button
2023/11/27 17:55:35 INFO Clicked verification button
2023/11/27 17:55:36 INFO Clicked verification button
2023/11/27 17:55:37 INFO Clicked verification button
2023/11/27 17:55:39 INFO Clicked verification button
2023/11/27 17:55:40 INFO Clicked verification button
2023/11/27 17:55:41 INFO Clicked verification button
2023/11/27 17:55:42 ERROR It is not possible to pass verification
2023/11/27 17:55:42 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 1
2023/11/27 17:55:43 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 2
2023/11/27 17:55:44 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 3
2023/11/27 17:55:45 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 4
2023/11/27 17:55:46 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 5
2023/11/27 17:55:47 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 6
2023/11/27 17:55:48 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 7
2023/11/27 17:55:49 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 8
2023/11/27 17:55:50 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 9
2023/11/27 17:55:51 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 10
2023/11/27 17:55:52 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 11
2023/11/27 17:55:53 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 12
2023/11/27 17:55:54 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 13
2023/11/27 17:55:55 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 14
2023/11/27 17:55:56 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 15
2023/11/27 17:55:57 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 16
2023/11/27 17:55:58 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 17
2023/11/27 17:55:59 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 18
2023/11/27 17:56:00 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 19
2023/11/27 17:56:01 INFO Element //button[//div[text()="Log in"]] is not present, attempt: 20
Traceback (most recent call last):
File ~\AppData\Local\anaconda3\envs\report\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\Free_Max367\onedrive\projets\brand\2023\s2ts\whisper_python\data4_anomaly_detection\compte_rendu (1).py:196
chathead = ChatGPTClient(username = username,
File ~\AppData\Local\anaconda3\envs\report\lib\site-packages\talkingheads\model_library\chatgpt.py:47 in init
super().init(
File ~\AppData\Local\anaconda3\envs\report\lib\site-packages\talkingheads\model_library\base_browser.py:104 in init
self.login(username, password)
File ~\AppData\Local\anaconda3\envs\report\lib\site-packages\talkingheads\model_library\chatgpt.py:106 in login
login_button.click()
AttributeError: 'list' object has no attribute 'click'

Have you ever encountered this type of malfunction?
Could you advise me on the origin of the problem?
Thanks in advance.

[FEATURE] Perserve cookies

Is it possible to retain the login cookies and utilize them for subsequent script executions, rather than having to log in each time?

PiClient Not Working

i run defualt code not work

File "/home/user/.local/lib/python3.10/site-packages/talkingheads/base_browser.py", line 169, in del
self.browser.close()
AttributeError: 'PiClient' object has no attribute 'browser'

Popup every access on Italy

Hi, there is a way to bypass this banner on Italy?

We’re pleased to resume offering ChatGPT in Italy. To continue on ChatGPT, please confirm that you are 18+ or are 13+ and have consent from your parent or guardian to use ChatGPT.
For information about how we collect and use personal data, please see our Privacy policy. For information about how we develop and train ChatGPT, please see this help center article.

The question is asked at every login and doesn't allow you to continue

Thankyou

if you use chrome 114 , it can't run

2023/07/10 12:49:15 WARNING Windows detected, no version number is provided, default: 112
Traceback (most recent call last):
File "d:\Documents\new2.py", line 3, in
chatgpt = ChatGPT_Client(USERNAME, PASSWORD)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatgpt_automation\chatgpt_client.py", line 62, in init
self.browser = uc.Chrome(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver_init_.py", line 443, in init
super(Chrome, self).init(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 49, in init
super().init(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 54, in init
super().init(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in init
self.start_session(capabilities)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver_init_.py", line 674, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 291, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute
self.error_handler.check_response(response)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:52952
from session not created: This version of ChromeDriver only supports Chrome version 112
Current browser version is 114.0.5735.199
Stacktrace:
Backtrace:
GetHandleVerifier [0x0099DCE3+50899]
(No symbol) [0x0092E111]
(No symbol) [0x00835588]
(No symbol) [0x0085570C]
(No symbol) [0x0084F5B1]
(No symbol) [0x0084F391]
(No symbol) [0x00881FFE]
(No symbol) [0x00881CEC]
(No symbol) [0x0087B6F6]
(No symbol) [0x00857708]
(No symbol) [0x0085886D]
GetHandleVerifier [0x00C03EAE+2566302]
GetHandleVerifier [0x00C392B1+2784417]
GetHandleVerifier [0x00C3327C+2759788]
GetHandleVerifier [0x00A35740+672048]
(No symbol) [0x00938872]
(No symbol) [0x009341C8]
(No symbol) [0x009342AB]
(No symbol) [0x009271B7]
BaseThreadInitThunk [0x761D7D59+25]
RtlInitializeExceptionChain [0x7739B74B+107]
RtlClearBits [0x7739B6CF+191]

[Bug] Only return ChatGPT

Hi, now only return the name "ChatGPT"

from gpt_lib import initGPT, initHuggingChat

chathead = initGPT(username ="email_pgt", password= "pass_gpt")

answer = chathead.interact("Hello, how are you today")

print(answer)

imagen

Nothing is happening

I have hardcoded the chrome version to 117, I am on Mac, and have the selenium driver and everything. Even after running the code on debugging the thing gets stuck at login page verification. What should be done.

Error: Message: no such element: Unable to locate element

Hello, this error appears as soon as you start the connection, a few hours ago it was working correctly.

Error: Message: no such element: Unable to locate element: {"method":"tag name","selector":"textarea"}
  (Session info: chrome=114.0.5735.198); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x55dcb8ccc4e3 <unknown>
#1 0x55dcb89fbc76 <unknown>
#2 0x55dcb8a37c96 <unknown>
#3 0x55dcb8a37dc1 <unknown>
#4 0x55dcb8a717f4 <unknown>
#5 0x55dcb8a5703d <unknown>
#6 0x55dcb8a6f30e <unknown>

[BUG] Error: Unable to find the text prompt area. Please raise an issue with verbose=True

At now i have this problem:

2023/10/13 18:51:10 INFO Verbose mode active
2023/10/13 18:51:10 INFO Loading undetected Chrome
2023/10/13 18:51:10 INFO The version is 114
2023/10/13 18:51:10 INFO patching driver executable /root/.local/share/undetected_chromedriver/undetected_chromedriver
2023/10/13 18:51:11 INFO Loaded Undetected chrome
2023/10/13 18:51:11 INFO Opening chatgpt
2023/10/13 18:51:12 INFO Element //button[//div[text()="Log in"]] has found
2023/10/13 18:51:13 INFO Clicked login button
2023/10/13 18:51:14 INFO Element username has found
2023/10/13 18:51:14 INFO Filled email box
2023/10/13 18:51:14 INFO Element //button[text()="Continue"] has found
2023/10/13 18:51:16 INFO Clicked continue button
2023/10/13 18:51:16 INFO Element password has found
2023/10/13 18:51:16 INFO Filled password box
2023/10/13 18:51:18 INFO Logged in
2023/10/13 18:51:23 INFO Info screen skipped
2023/10/13 18:51:23 INFO ChatGPT is ready to interact

....

2023/10/13 19:01:29 INFO Unable to locate text area tag. Switching to ID search
Error: Unable to find the text prompt area. Please raise an issue with verbose=True

EDIT:

imagen

Using talkingheads new library and ChatGPT

[BUG] Error: list index out of range in ChatGPT

For a week now, I get this error:

Login OK:
2023/10/31 06:19:23 INFO Element password has found
2023/10/31 06:19:23 INFO Filled password box
2023/10/31 06:19:25 INFO Logged in
2023/10/31 06:19:30 INFO Info screen skipped
2023/10/31 06:19:30 INFO ChatGPT is ready to interact
...

And interact error:

2023/10/31 06:19:38 INFO Message sent, waiting for response
2023/10/31 06:19:38 INFO Waiting element text-2xl to disappear.
2023/10/31 06:19:38 INFO Element text-2xl disappeared.
Error: list index out of range

How to start a new chat?

Hello, I need to start a new chat for each response that comes back to me.

How can I start a new chat?

Cannot change to GPT-4

from talkingheads import ChatGPTClient
chathead = ChatGPTClient(
    ........
)

chathead.switch_model('GPT-4')

However, the output is

2023/12/02 09:43:23 ERROR Button is not present
False

Usage block of README is obsolete

from chatgpt_automation import ChatGPT_Client
chatgpt = Handler(YOUR_USERNAME, YOUR_PASSWORD)

The last line should be

chatgpt = ChatGPT_Client(YOUR_USERNAME, YOUR_PASSWORD)

Not login at new version of ChatGPT [BUG]

The scripts send:

Traceback (most recent call last):
  File "code.py", line 14, in <module>
    chatgpt = ChatGPT_Client(OPENAI_EMAIL, OPENAI_PASSWORD)
  File "/usr/local/lib/python3.8/site-packages/chatgpt_automation/chatgpt_client.py", line 72, in __init__
    self.login(username, password)
  File "/usr/local/lib/python3.8/site-packages/chatgpt_automation/chatgpt_client.py", line 146, in login
    continue_button.click()
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 94, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 395, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=114.0.5735.133)

ChatGPT change the main login page:

imagen

Exception has occurred: WebDriverException (Windows 10)

Following the quick example:

from handler import Handler

chatgpt = Handler(<<my username>>, <<my password>>)

answer = chatgpt.interact("Hello, how are you today")

print(answer)

I receive the following error:

Exception has occurred: WebDriverException
Message: unknown error: cannot connect to chrome at 127.0.0.1:65421
from unknown error: unable to discover open pages
Stacktrace:
Backtrace:
	GetHandleVerifier [0x007ADCE3+50899]
	(No symbol) [0x0073E111]
	(No symbol) [0x00645588]
	(No symbol) [0x006655A9]
	(No symbol) [0x0065F5B1]
	(No symbol) [0x0065F391]
	(No symbol) [0x00691FFE]
	(No symbol) [0x00691CEC]
	(No symbol) [0x0068B6F6]
	(No symbol) [0x00667708]
	(No symbol) [0x0066886D]
	GetHandleVerifier [0x00A13EAE+2566302]
	GetHandleVerifier [0x00A492B1+2784417]
	GetHandleVerifier [0x00A4327C+2759788]
	GetHandleVerifier [0x00845740+672048]
	(No symbol) [0x00748872]
	(No symbol) [0x007441C8]
	(No symbol) [0x007442AB]
	(No symbol) [0x007371B7]
	BaseThreadInitThunk [0x769F0099+25]
	RtlGetAppContainerNamedObjectPath [0x77AD7B6E+286]
	RtlGetAppContainerNamedObjectPath [0x77AD7B3E+238]
  File "C:\Users\<<user>>\Projects\ChatGPT_Selenium\handler.py", line 94, in __init__
    self.browser = uc.Chrome(options=options, use_subprocess=True)
  File "C:\Users\<<user>>\Projects\ChatGPT_Selenium\chat.py", line 8, in <module>
    chatgpt = Handler(YOUR_USERNAME, YOUR_PASSWORD)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:65421
from unknown error: unable to discover open pages
Stacktrace:
Backtrace:
	GetHandleVerifier [0x007ADCE3+50899]
	(No symbol) [0x0073E111]
	(No symbol) [0x00645588]
	(No symbol) [0x006655A9]
	(No symbol) [0x0065F5B1]
	(No symbol) [0x0065F391]
	(No symbol) [0x00691FFE]
	(No symbol) [0x00691CEC]
	(No symbol) [0x0068B6F6]
	(No symbol) [0x00667708]
	(No symbol) [0x0066886D]
	GetHandleVerifier [0x00A13EAE+2566302]
	GetHandleVerifier [0x00A492B1+2784417]
	GetHandleVerifier [0x00A4327C+2759788]
	GetHandleVerifier [0x00845740+672048]
	(No symbol) [0x00748872]
	(No symbol) [0x007441C8]
	(No symbol) [0x007442AB]
	(No symbol) [0x007371B7]
	BaseThreadInitThunk [0x769F0099+25]
	RtlGetAppContainerNamedObjectPath [0x77AD7B6E+286]
	RtlGetAppContainerNamedObjectPath [0x77AD7B3E+238]

I have confirmed both WebDriver and undetected_chromedriver function on their own with sample scripts, however the handler doesn't seem to want to connect.
I've tried specifying the chromedriver.exe in the options within handler.py but that hasn't work, and specifying the path wasn't necessary in the quick checks of undetected_chromedriver and WebDriver on their own.

I'm using ChromeDriver 112.0.5615.49 (bd2a7bcb881c11e8cfe3078709382934e3916914-refs/branch-heads/5615@{#936}) attempting to align with Chrome 112.0.5615.138 (Official Build) (64-bit).

Thanks in advance for any thoughts.

[FEATURE] Login with Microsoft

OpenAI has more than one type of login options. One of them is Microsoft Account SSO.

We need a feature to automate the whole process from clicking button to completing SSO.

Fix ChatGPT and Claude

Hello,

Since the ChatGPT and Claude websites have been updated to a new version, the old codes no longer work. Could you please update them?

When deployed I am detected

Hey
Thanks for this code. It works locally but when I deploy it I get detected by Cloudflare. It says I have been blocked. I think it is related to the IP. Did you get that?

Unable to locate 'textarea' element when running the demo code

Hi, first of all thank you for this clever project !

Operating System:

macOS 13.4.1 (22F82)

Description:
I encountered an error while running the demo code on my local machine. The code is designed to interact with a chatbot using the credentials provided. However, when executing the code, I received a NoSuchElementException indicating that the 'textarea' element could not be located.

Steps to Reproduce:

  1. Clone the repository and navigate to the appropriate directory.
  2. Ensure all necessary dependencies are installed.
  3. Run the demo code with valid credentials.
  4. Observe the error traceback.

Expected Behavior:
The code should successfully locate the 'textarea' element and interact with the chatbot, providing an appropriate response.

Actual Behavior:
The code fails to locate the 'textarea' element and raises a NoSuchElementException error.

Error Message:

Traceback (most recent call last):
  File "/Users/art/Dropbox/dev/chatgpt/main.py", line 5, in <module>
    answer = chatgpt.interact("Hello, how are you today")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/chatgpt_automation/chatgpt_client.py", line 242, in interact
    text_area = self.browser.find_element(By.TAG_NAME, 'textarea')
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 740, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute
    self.error_handler.check_response(response)
  File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"tag name","selector":"textarea"}
  (Session info: chrome=114.0.5735.198); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
0   undetected_chromedriver             0x00000001047886b8 undetected_chromedriver + 4937400
1   undetected_chromedriver             0x000000010477fb73 undetected_chromedriver + 4901747
2   undetected_chromedriver             0x000000010433d616 undetected_chromedriver + 435734
3   undetected_chromedriver             0x0000000104380e0f undetected_chromedriver + 712207
4   undetected_chromedriver             0x00000001043810a1 undetected_chromedriver + 712865
5   undetected_chromedriver             0x00000001043c29a4 undetected_chromedriver + 981412
6   undetected_chromedriver             0x00000001043a503d undetected_chromedriver + 860221
7   undetected_chromedriver             0x00000001043bfe76 undetected_chromedriver + 970358
8   undetected_chromedriver             0x00000001043a4de3 undetected_chromedriver + 859619
9   undetected_chromedriver             0x0000000104372d7f undetected_chromedriver + 654719
10  undetected_chromedriver             0x00000001043740de undetected_chromedriver + 659678
11  undetected_chromedriver             0x00000001047442ad undetected_chromedriver + 4657837
12  undetected_chromedriver             0x0000000104749130 undetected_chromedriver + 4677936
13  undetected_chromedriver             0x000000010474fdef undetected_chromedriver + 4705775
14  undetected_chromedriver             0x000000010474a05a undetected_chromedriver + 4681818
15  undetected_chromedriver             0x000000010471c92c undetected_chromedriver + 4495660
16  undetected_chromedriver             0x0000000104767838 undetected_chromedriver + 4802616
17  undetected_chromedriver             0x00000001047679b7 undetected_chromedriver + 4802999
18  undetected_chromedriver             0x000000010477899f undetected_chromedriver + 4872607
19  libsystem_pthread.dylib             0x00007ff80c1c71d3 _pthread_start + 125
20  libsystem_pthread.dylib             0x00007ff80c1c2bd3 thread_start + 15

Installation

Sorry for disturbing you for the second time about the similar question.
It just took me 2 days to prepare my system to use your package. Though it still not ready.
It seems the installation of undetected-chromedriver could be painful. It requires 2 files and if you haven't worked with it earlier you should somehow guess their names, versions and compability of versions. undetected-chromedriver doesn't have a good installation manual.

My current one

sudo apt-get install libc-dev

wget https://chromedriver.storage.googleapis.com/113.0.5672.63/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/
sudo chmod +x /usr/bin/chromedriver

wget dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_113.0.5672.92-1_amd64.deb
sudo dpkg -i google-chrome-stable_113.0.5672.92-1_amd64.deb

Though I'm not still sure it will work with you package. At the moment it worked for running undetected-chromedriver but I used ChromeOptions and your ChatGPT_Client doesn't allow me to do the same. I'm confused with system environments and PATH. Which of chrome files I should to specify and where.

So I ask you to consider adding my commands in case they are right and describe what environment variables and PATH additions your package expects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.