Skip to content

Commit

Permalink
Modifications based on UI changes of ChatGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
seii-saintway committed Jun 2, 2023
1 parent be4594c commit 7edbfef
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
30 changes: 15 additions & 15 deletions docs/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ <h4 id="remove_portal" class="doc_header"><code>remove_portal</code><a href="htt


<div class="output_markdown rendered_html output_subarea ">
<h4 id="request" class="doc_header"><code>request</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L400" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>request</code>(<strong><code>prompt</code></strong>:<code>str</code>)</p>
<h4 id="request" class="doc_header"><code>request</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L401" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>request</code>(<strong><code>prompt</code></strong>:<code>str</code>)</p>
</blockquote>

</div>
Expand All @@ -600,7 +600,7 @@ <h4 id="request" class="doc_header"><code>request</code><a href="https://github.


<div class="output_markdown rendered_html output_subarea ">
<h4 id="get_last_response" class="doc_header"><code>get_last_response</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L425" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>get_last_response</code>()</p>
<h4 id="get_last_response" class="doc_header"><code>get_last_response</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L433" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>get_last_response</code>()</p>
</blockquote>

</div>
Expand All @@ -625,7 +625,7 @@ <h4 id="get_last_response" class="doc_header"><code>get_last_response</code><a h


<div class="output_markdown rendered_html output_subarea ">
<h4 id="get_response" class="doc_header"><code>get_response</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L433" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>get_response</code>()</p>
<h4 id="get_response" class="doc_header"><code>get_response</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L441" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>get_response</code>()</p>
</blockquote>

</div>
Expand All @@ -650,7 +650,7 @@ <h4 id="get_response" class="doc_header"><code>get_response</code><a href="https


<div class="output_markdown rendered_html output_subarea ">
<h4 id="ask" class="doc_header"><code>ask</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L461" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>ask</code>(<strong><code>prompt</code></strong>:<code>str</code>)</p>
<h4 id="ask" class="doc_header"><code>ask</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L469" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>ask</code>(<strong><code>prompt</code></strong>:<code>str</code>)</p>
</blockquote>

</div>
Expand Down Expand Up @@ -699,7 +699,7 @@ <h4 id="ask" class="doc_header"><code>ask</code><a href="https://github.com/seii


<div class="output_markdown rendered_html output_subarea ">
<h4 id="get_screenshot" class="doc_header"><code>get_screenshot</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L468" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>get_screenshot</code>()</p>
<h4 id="get_screenshot" class="doc_header"><code>get_screenshot</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L476" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>get_screenshot</code>()</p>
</blockquote>

</div>
Expand Down Expand Up @@ -786,7 +786,7 @@ <h4 id="get_screenshot" class="doc_header"><code>get_screenshot</code><a href="h


<div class="output_markdown rendered_html output_subarea ">
<h2 id="attrdict" class="doc_header"><code>class</code> <code>attrdict</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L475" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>attrdict</code>() :: <code>dict</code></p>
<h2 id="attrdict" class="doc_header"><code>class</code> <code>attrdict</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L483" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>attrdict</code>() :: <code>dict</code></p>
</blockquote>
<p>dict() -&gt; new empty dictionary
dict(mapping) -&gt; new dictionary initialized from a mapping object's
Expand Down Expand Up @@ -820,7 +820,7 @@ <h2 id="attrdict" class="doc_header"><code>class</code> <code>attrdict</code><a


<div class="output_markdown rendered_html output_subarea ">
<h4 id="attributize" class="doc_header"><code>attributize</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L479" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>attributize</code>(<strong><code>obj</code></strong>)</p>
<h4 id="attributize" class="doc_header"><code>attributize</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L487" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>attributize</code>(<strong><code>obj</code></strong>)</p>
</blockquote>
<p>Add attributes to a dictionary and its sub-dictionaries.</p>

Expand All @@ -846,7 +846,7 @@ <h4 id="attributize" class="doc_header"><code>attributize</code><a href="https:/


<div class="output_markdown rendered_html output_subarea ">
<h4 id="retry_on_status_code" class="doc_header"><code>retry_on_status_code</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L489" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>retry_on_status_code</code>(<strong><code>func</code></strong>)</p>
<h4 id="retry_on_status_code" class="doc_header"><code>retry_on_status_code</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L497" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>retry_on_status_code</code>(<strong><code>func</code></strong>)</p>
</blockquote>
<p>Retry decorator that retries a function on specific status codes.</p>

Expand All @@ -872,7 +872,7 @@ <h4 id="retry_on_status_code" class="doc_header"><code>retry_on_status_code</cod


<div class="output_markdown rendered_html output_subarea ">
<h4 id="retry_on_status_code.<locals>.wrapper" class="doc_header"><code>retry_on_status_code.<locals>.wrapper</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L491" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>retry_on_status_code.<locals>.wrapper</code>(<strong>*<code>args</code></strong>, <strong>**<code>kwargs</code></strong>)</p>
<h4 id="retry_on_status_code.<locals>.wrapper" class="doc_header"><code>retry_on_status_code.<locals>.wrapper</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L499" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>retry_on_status_code.<locals>.wrapper</code>(<strong>*<code>args</code></strong>, <strong>**<code>kwargs</code></strong>)</p>
</blockquote>

</div>
Expand All @@ -897,7 +897,7 @@ <h4 id="retry_on_status_code.<locals>.wrapper" class="doc_header"><code>retry_on


<div class="output_markdown rendered_html output_subarea ">
<h4 id="new_id" class="doc_header"><code>new_id</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L525" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>new_id</code>()</p>
<h4 id="new_id" class="doc_header"><code>new_id</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L533" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>new_id</code>()</p>
</blockquote>

</div>
Expand All @@ -922,7 +922,7 @@ <h4 id="new_id" class="doc_header"><code>new_id</code><a href="https://github.co


<div class="output_markdown rendered_html output_subarea ">
<h4 id="delta" class="doc_header"><code>delta</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L530" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>delta</code>(<strong><code>prompt</code></strong>)</p>
<h4 id="delta" class="doc_header"><code>delta</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L538" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>delta</code>(<strong><code>prompt</code></strong>)</p>
</blockquote>

</div>
Expand All @@ -947,7 +947,7 @@ <h4 id="delta" class="doc_header"><code>delta</code><a href="https://github.com/


<div class="output_markdown rendered_html output_subarea ">
<h4 id="chat_delta" class="doc_header"><code>chat_delta</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L549" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>chat_delta</code>(<strong><code>prompt</code></strong>)</p>
<h4 id="chat_delta" class="doc_header"><code>chat_delta</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L557" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>chat_delta</code>(<strong><code>prompt</code></strong>)</p>
</blockquote>

</div>
Expand All @@ -972,7 +972,7 @@ <h4 id="chat_delta" class="doc_header"><code>chat_delta</code><a href="https://g


<div class="output_markdown rendered_html output_subarea ">
<h4 id="mock_create" class="doc_header"><code>mock_create</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L569" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mock_create</code>(<strong>*<code>args</code></strong>, <strong>**<code>kwargs</code></strong>)</p>
<h4 id="mock_create" class="doc_header"><code>mock_create</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L577" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mock_create</code>(<strong>*<code>args</code></strong>, <strong>**<code>kwargs</code></strong>)</p>
</blockquote>

</div>
Expand All @@ -997,7 +997,7 @@ <h4 id="mock_create" class="doc_header"><code>mock_create</code><a href="https:/


<div class="output_markdown rendered_html output_subarea ">
<h4 id="mock_chat_create" class="doc_header"><code>mock_chat_create</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L598" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mock_chat_create</code>(<strong>*<code>args</code></strong>, <strong>**<code>kwargs</code></strong>)</p>
<h4 id="mock_chat_create" class="doc_header"><code>mock_chat_create</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L606" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mock_chat_create</code>(<strong>*<code>args</code></strong>, <strong>**<code>kwargs</code></strong>)</p>
</blockquote>

</div>
Expand Down Expand Up @@ -1152,7 +1152,7 @@ <h4 id="mock_chat_create" class="doc_header"><code>mock_chat_create</code><a hre


<div class="output_markdown rendered_html output_subarea ">
<h4 id="mock_openai" class="doc_header"><code>mock_openai</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L630" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mock_openai</code>(<strong><code>monkeypatch</code></strong>)</p>
<h4 id="mock_openai" class="doc_header"><code>mock_openai</code><a href="https://github.com/seii-saintway/ipymock/tree/main/ipymock/browser.py#L638" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mock_openai</code>(<strong><code>monkeypatch</code></strong>)</p>
</blockquote>

</div>
Expand Down
1 change: 1 addition & 0 deletions ipymock/_nbdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"remove_portal": "2_browser.ipynb",
"chatgpt_textbox": "2_browser.ipynb",
"chatgpt_disabled_button": "2_browser.ipynb",
"chatgpt_enabled_button": "2_browser.ipynb",
"chatgpt_streaming": "2_browser.ipynb",
"chatgpt_response": "2_browser.ipynb",
"chatgpt_red_500": "2_browser.ipynb",
Expand Down
14 changes: 11 additions & 3 deletions ipymock/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ def remove_portal():
pass

# Internal Cell
chatgpt_textbox = (By.TAG_NAME, 'textarea')
chatgpt_textbox = (By.XPATH, '//textarea[@id="prompt-textarea"]')
chatgpt_disabled_button = (By.XPATH, '//textarea/following-sibling::button[@disabled]')
chatgpt_enabled_button = (By.XPATH, '//textarea/following-sibling::button[not(@disabled)]')
chatgpt_streaming = (By.CLASS_NAME, 'result-streaming')
chatgpt_response = (By.XPATH, '//div[starts-with(@class, "flex flex-grow flex-col gap-3")]')
chatgpt_red_500 = (By.XPATH, '//div[contains(@class, "border-red-500 bg-red-500/10")]')
Expand All @@ -408,19 +409,26 @@ def request(prompt: str) -> None:
expected_conditions.element_to_be_clickable(chatgpt_textbox)
)
textbox.click()
# textbox.send_keys(prompt.strip())
common.driver.execute_script('''
var element = arguments[0], txt = arguments[1];
element.value += txt;
element.dispatchEvent(new Event("change"));
''',
textbox,
prompt,
prompt.strip(),
)
# textbox.send_keys(prompt)
# WebDriverWait(common.driver, 3).until_not(
# expected_conditions.presence_of_element_located(chatgpt_disabled_button)
# )
textbox.send_keys('\n')
textbox.send_keys(Keys.ENTER)
# try:
# WebDriverWait(common.driver, 5).until(
# expected_conditions.element_to_be_clickable(chatgpt_enabled_button)
# ).click()
# except TimeoutException:
# pass

def get_last_response():
responses = common.driver.find_elements(*chatgpt_big_response)
Expand Down
14 changes: 11 additions & 3 deletions nbs/2_browser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,9 @@
"outputs": [],
"source": [
"# exporti\n",
"chatgpt_textbox = (By.TAG_NAME, 'textarea')\n",
"chatgpt_textbox = (By.XPATH, '//textarea[@id=\"prompt-textarea\"]')\n",
"chatgpt_disabled_button = (By.XPATH, '//textarea/following-sibling::button[@disabled]')\n",
"chatgpt_enabled_button = (By.XPATH, '//textarea/following-sibling::button[not(@disabled)]')\n",
"chatgpt_streaming = (By.CLASS_NAME, 'result-streaming')\n",
"chatgpt_response = (By.XPATH, '//div[starts-with(@class, \"flex flex-grow flex-col gap-3\")]')\n",
"chatgpt_red_500 = (By.XPATH, '//div[contains(@class, \"border-red-500 bg-red-500/10\")]')\n",
Expand All @@ -649,19 +650,26 @@
" expected_conditions.element_to_be_clickable(chatgpt_textbox)\n",
" )\n",
" textbox.click()\n",
" # textbox.send_keys(prompt.strip())\n",
" common.driver.execute_script('''\n",
" var element = arguments[0], txt = arguments[1];\n",
" element.value += txt;\n",
" element.dispatchEvent(new Event(\"change\"));\n",
" ''',\n",
" textbox,\n",
" prompt,\n",
" prompt.strip(),\n",
" )\n",
" # textbox.send_keys(prompt)\n",
" # WebDriverWait(common.driver, 3).until_not(\n",
" # expected_conditions.presence_of_element_located(chatgpt_disabled_button)\n",
" # )\n",
" textbox.send_keys('\\n')\n",
" textbox.send_keys(Keys.ENTER)\n",
" # try:\n",
" # WebDriverWait(common.driver, 5).until(\n",
" # expected_conditions.element_to_be_clickable(chatgpt_enabled_button)\n",
" # ).click()\n",
" # except TimeoutException:\n",
" # pass\n",
"\n",
"def get_last_response():\n",
" responses = common.driver.find_elements(*chatgpt_big_response)\n",
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ author = andrew
author_email = [email protected]
copyright = 2023 onwards, Neuro Spirit, DAO.
branch = main
version = 1.1.1
version = 1.1.2
min_python = 3.6
audience = Developers
language = English
Expand Down

0 comments on commit 7edbfef

Please sign in to comment.