Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,12 @@ async def web_search(self, query: str, max_results: int = 3) -> WebSearchRespons

Returns:
WebSearchResponse with the search results
Raises:
ValueError: If OLLAMA_API_KEY environment variable is not set
"""
if not self._client.headers.get('authorization', '').startswith('Bearer '):
raise ValueError('Authorization header with Bearer token is required for web search')

return await self._request(
WebSearchResponse,
'POST',
Expand All @@ -821,7 +826,12 @@ async def web_fetch(self, url: str) -> WebFetchResponse:

Returns:
WebFetchResponse with the fetched result
Raises:
ValueError: If OLLAMA_API_KEY environment variable is not set
"""
if not self._client.headers.get('authorization', '').startswith('Bearer '):
raise ValueError('Authorization header with Bearer token is required for web fetch')

return await self._request(
WebFetchResponse,
'POST',
Expand Down