-
Notifications
You must be signed in to change notification settings - Fork 337
feat: support OPENROUTER_API_KEY for perplexity #828
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,3 +46,33 @@ def test_read_url_arxiv_pdf(): | |||||||||
| # TODO: test that we can read it | ||||||||||
| # url = "https://arxiv.org/pdf/2410.12361v2" | ||||||||||
| pass | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @pytest.mark.slow | ||||||||||
| def test_search_perplexity(monkeypatch): | ||||||||||
| """Test Perplexity search with both API types.""" | ||||||||||
| import os | ||||||||||
|
|
||||||||||
| # Skip if no API keys available | ||||||||||
| has_perplexity = os.getenv("PERPLEXITY_API_KEY") is not None | ||||||||||
| has_openrouter = os.getenv("OPENROUTER_API_KEY") is not None | ||||||||||
|
|
||||||||||
| if not (has_perplexity or has_openrouter): | ||||||||||
| pytest.skip("No PERPLEXITY_API_KEY or OPENROUTER_API_KEY available") | ||||||||||
|
|
||||||||||
| # Test the search works | ||||||||||
| results = search("what is gptme", "perplexity") | ||||||||||
| assert results, "Should get results from Perplexity" | ||||||||||
| assert ( | ||||||||||
| "error" not in results.lower() or "Error" not in results | ||||||||||
| ), f"Got error: {results}" | ||||||||||
|
Comment on lines
+66
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: logical error in assertion - using
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/test_browser.py
Line: 66:68
Comment:
**logic:** logical error in assertion - using `or` instead of `and` means the assertion passes if either condition is true, which is incorrect
```suggestion
assert "error" not in results.lower(), f"Got error: {results}"
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||
|
|
||||||||||
| # If we have OpenRouter key, test that it works too | ||||||||||
| if has_openrouter and not has_perplexity: | ||||||||||
| # Clear Perplexity key to force OpenRouter usage | ||||||||||
| monkeypatch.delenv("PERPLEXITY_API_KEY", raising=False) | ||||||||||
| results2 = search("what is gptme", "perplexity") | ||||||||||
| assert results2, "Should get results from OpenRouter" | ||||||||||
| assert ( | ||||||||||
| "error" not in results2.lower() or "Error" not in results2 | ||||||||||
| ), f"Got error: {results2}" | ||||||||||
|
Comment on lines
+76
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: same logical error - using
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/test_browser.py
Line: 76:78
Comment:
**logic:** same logical error - using `or` instead of `and`
```suggestion
assert "error" not in results2.lower(), f"Got error: {results2}"
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion using 'or' may not reliably catch error messages. Replace 'or' with 'and' (or check just one case using lower-case) so that the test properly fails when an error is present.