Skip to content

Commit

Permalink
improve browser agent code parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Sep 10, 2024
1 parent eed2945 commit 1c92c07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/browser/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from siteuse import site_use

def take_screenshot():
time.sleep(1)
time.sleep(2)
driver.save_screenshot("screenshot.png")
shutil.copy("screenshot.png", f"storage/screenshot-{int(time.time())}.png")

Expand All @@ -36,7 +36,7 @@ def take_screenshot():
exec(code)
take_screenshot()
except Exception as e:
print(f"Failed to use browser, details follow.\n```{code}```\n\n```{e}```\n")
print(f"Failed to use browser, details follow.\n```{code}```\n\n```\n{e}```\n")

prompt = h9.input("Taking screenshot, what next?")

Expand Down
3 changes: 3 additions & 0 deletions apps/browser/siteuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
At the beginning of the code, use print() to communicate what the code will do.
Only reply with a code block for python code.
"""

Expand All @@ -24,4 +25,6 @@ def site_use(prompt, current):
completion = Groq().chat.completions.create(model = "llama3-70b-8192", messages = messages)
content = completion.choices[0].message.content
extracted = h9.extract(content, language = "*")
if len(extracted) == 0:
return content
return extracted

0 comments on commit 1c92c07

Please sign in to comment.