Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added lynx browser support #214

Merged
merged 3 commits into from
Oct 28, 2024
Merged

feat: added lynx browser support #214

merged 3 commits into from
Oct 28, 2024

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Oct 22, 2024

Fixes #205


Important

Adds Lynx browser support and refactors browser functions to handle both Playwright and Lynx backends.

  • Behavior:
    • Adds Lynx browser support in browser.py, selecting between Playwright and Lynx based on availability.
    • Refactors read_url, search, and screenshot_url in browser.py to support both Playwright and Lynx.
    • screenshot_url raises an error if Lynx is used, as Lynx does not support screenshots.
  • New Module:
    • Adds _browser_lynx.py with read_url and search functions for Lynx.
  • Refactoring:
    • Moves read_url and search logic to _browser_playwright.py and _browser_lynx.py.
    • Introduces search_playwright in browser.py for Playwright-specific search logic.
  • Tests:
    • Updates test_browser.py to reflect changes, with a note to test Lynx backend.

This description was created by Ellipsis for f9268db. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to 02db7d9 in 45 seconds

More details
  • Looked at 295 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. gptme/tools/_browser_lynx.py:14
  • Draft comment:
    Ensure that the query parameter is properly sanitized to prevent command injection vulnerabilities.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. gptme/tools/browser.py:27
  • Draft comment:
    Consider renaming the lambda functions to follow the standard naming conventions, such as has_playwright and has_lynx, to improve code readability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The lambda functions for checking the availability of playwright and lynx are not following the standard naming conventions for functions.
3. gptme/tools/browser.py:99
  • Draft comment:
    Add a check to handle the case where the browser is None to prevent runtime errors.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_EcrO1voqVPoNpNvj


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.



def read_url(url):
return subprocess.run(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for subprocess.run to catch exceptions if the lynx command fails. This will help in debugging and provide meaningful error messages.

raise ValueError(f"Unknown search engine: {engine}")


def test_read_url():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a testing framework like unittest or pytest for the test functions instead of print statements. This will make the tests more robust and easier to manage.

@codecov-commenter
Copy link

codecov-commenter commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 51.85185% with 39 lines in your changes missing coverage. Please review.

Project coverage is 74.84%. Comparing base (3dcef9f) to head (f9268db).
Report is 26 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
gptme/tools/_browser_lynx.py 0.00% 15 Missing ⚠️
gptme/tools/browser.py 51.72% 14 Missing ⚠️
gptme/tools/_browser_playwright.py 72.97% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #214      +/-   ##
==========================================
- Coverage   75.31%   74.84%   -0.47%     
==========================================
  Files          57       58       +1     
  Lines        3609     3650      +41     
==========================================
+ Hits         2718     2732      +14     
- Misses        891      918      +27     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 73.78% <51.85%> (-0.46%) ⬇️
openai/gpt-4o-mini 73.39% <51.85%> (-0.45%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on 62fb25d in 22 seconds

More details
  • Looked at 34 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/test_browser.py:3
  • Draft comment:
    Consider adding tests for the Lynx backend to ensure the new functionality is working as expected. This is important for verifying the integration of Lynx alongside Playwright.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is redundant because the TODO comment already addresses the need for testing the Lynx backend. The automated comment does not provide any new information or actionable steps beyond what is already noted in the TODO.
    I might be overlooking the possibility that the automated comment provides additional context or urgency that the TODO does not. However, the TODO is a clear indicator of the need for future work.
    The TODO comment is sufficient to indicate the need for testing the Lynx backend, and the automated comment does not add any new value.
    Delete the comment as it is redundant and does not provide additional value beyond the existing TODO comment.

Workflow ID: wflow_pnyflKAX8RFcrh3U


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on b3d378d in 14 seconds

More details
  • Looked at 34 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/test_browser.py:3
  • Draft comment:
    Consider adding tests for the Lynx backend to ensure its functionality is covered.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The comment on line 3 suggests testing the Lynx backend, but no tests are implemented for it. This is a missing feature in the test suite.

Workflow ID: wflow_TT02Z9AyVXcFapVr


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on f9268db in 14 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_1Vejxi4hrPCIP5fT


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@ErikBjare ErikBjare changed the title feat: started working on lynx browser support feat: added lynx browser support Oct 28, 2024
@ErikBjare ErikBjare merged commit 2cd9ffb into master Oct 28, 2024
7 checks passed
@ErikBjare ErikBjare deleted the dev/browser-lynx branch October 28, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement lynx-backed browser tool
2 participants