-
Notifications
You must be signed in to change notification settings - Fork 1
fixes #10
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
Merged
fixes #10
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/usr/bin/env python3 | ||
| """Test script for the Serper API.""" | ||
|
|
||
| import os | ||
| import json | ||
| import requests | ||
| from dotenv import load_dotenv | ||
|
|
||
| # Load environment variables | ||
| load_dotenv() | ||
|
|
||
| def test_serper_api(): | ||
| """Test direct search with Serper API.""" | ||
| print("🔍 Testing search functionality with Serper API...") | ||
|
|
||
| # Get API key from environment | ||
| api_key = os.environ.get("SERPER_API_KEY", "") | ||
|
|
||
| if not api_key: | ||
| print("❌ No API key found in environment variables.") | ||
| return | ||
|
|
||
| # Mask the key for display | ||
| key_length = len(api_key) | ||
| if key_length > 8: | ||
| masked_key = f"{api_key[:4]}{'*' * (key_length - 8)}{api_key[-4:]}" | ||
| else: | ||
| masked_key = "****" | ||
| print(f"🔑 Using API key: {masked_key}") | ||
|
|
||
| # Configure the Serper API request | ||
| serper_url = "https://google.serper.dev/search" | ||
| headers = { | ||
| 'X-API-KEY': api_key, | ||
| 'Content-Type': 'application/json' | ||
| } | ||
| query = "What is the capital of France?" | ||
| payload = { | ||
| 'q': query, | ||
| 'gl': 'us', | ||
| 'hl': 'en' | ||
| } | ||
|
|
||
| print(f"🔎 Searching for: '{query}'") | ||
|
|
||
| try: | ||
| response = requests.post(serper_url, headers=headers, json=payload) | ||
| print(f"Status code: {response.status_code}") | ||
|
|
||
| if response.status_code == 200: | ||
| result = response.json() | ||
| print("✅ Success! Response received:") | ||
| # Print only a portion of the response to avoid clutter | ||
| if 'organic' in result and result['organic']: | ||
| print(f"Found {len(result['organic'])} organic results") | ||
| first_result = result['organic'][0] | ||
| print(f"First result: {json.dumps(first_result, indent=2)}") | ||
| else: | ||
| print("No organic results found.") | ||
| else: | ||
| print(f"❌ Error: {response.status_code}") | ||
| print(f"Response: {response.text}") | ||
| except Exception as e: | ||
| print(f"❌ Exception: {str(e)}") | ||
|
|
||
| if __name__ == "__main__": | ||
| test_serper_api() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove unnecessary f-string prefix.
The logging statement doesn't contain any placeholders.
Apply this diff:
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.11.9)
193-193: f-string without any placeholders
Remove extraneous
fprefix(F541)
🪛 Pylint (3.3.7)
[warning] 193-193: Use lazy % formatting in logging functions
(W1203)
[warning] 193-193: Using an f-string that does not have any interpolated variables
(W1309)
🤖 Prompt for AI Agents