Skip to content

Commit

Permalink
doc(readme): polish
Browse files Browse the repository at this point in the history
  • Loading branch information
helmut-hoffer-von-ankershoffen committed Jan 1, 2025
1 parent 9a80f51 commit 8b92c6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ from brave_search_python_client import (
WebSearchRequest,
)

# Load .env file and check for Brave Search API Key
# Load .env file and get Brave Search API key from environment
load_dotenv()
api_key = os.getenv("BRAVE_SEARCH_API_KEY")
if not api_key:
raise Exception("BRAVE_SEARCH_API_KEY found in environment")
raise Exception("BRAVE_SEARCH_API_KEY not found in environment")


async def search():
"""Run various searches using the Brave Search Python Client"""

# Initialize the BraveSearch client, using the API key from the environment
# Initialize the Brave Search Python client, using the API key from the environment
bs = BraveSearch()

# Perform a web search
Expand All @@ -107,7 +107,6 @@ async def search():
search_lang=LanguageCode.DE,
)
)

print("# Advanced search results")
for result in response.web.results if response.web else []:
print(f"[{result.title}]({result.url})")
Expand All @@ -131,8 +130,8 @@ async def search():
print(f"![{item.title}]({item.url})")


# Execute the search function
# Alternatively use await(search()) in an async function
# Run the async search function
# Alternatively use await search() from an async function
asyncio.run(search())
```

Expand Down
11 changes: 5 additions & 6 deletions examples/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
WebSearchRequest,
)

# Load .env file and check for Brave Search API Key
# Load .env file and get Brave Search API key from environment
load_dotenv()
api_key = os.getenv("BRAVE_SEARCH_API_KEY")
if not api_key:
raise Exception("BRAVE_SEARCH_API_KEY found in environment")
raise Exception("BRAVE_SEARCH_API_KEY not found in environment")


async def search():
"""Run various searches using the Brave Search Python Client"""

# Initialize the BraveSearch client, using the API key from the environment
# Initialize the Brave Search Python client, using the API key from the environment
bs = BraveSearch()

# Perform a web search
Expand All @@ -48,7 +48,6 @@ async def search():
search_lang=LanguageCode.DE,
)
)

print("# Advanced search results")
for result in response.web.results if response.web else []:
print(f"[{result.title}]({result.url})")
Expand All @@ -72,6 +71,6 @@ async def search():
print(f"![{item.title}]({item.url})")


# Execute the search function
# Alternatively use await(search()) in an async function
# Run the async search function
# Alternatively use await search() from an async function
asyncio.run(search())

0 comments on commit 8b92c6f

Please sign in to comment.