mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-13 21:57:16 +08:00
formatting issues
This commit is contained in:
parent
81c71ba44e
commit
d3ddff329f
@ -6,7 +6,7 @@
|
||||
# ]
|
||||
# ///
|
||||
import os
|
||||
from typing import Optional, Union
|
||||
from typing import Union
|
||||
|
||||
from rich import print
|
||||
|
||||
@ -20,7 +20,6 @@ def format_tool_results(
|
||||
if isinstance(results, WebSearchResponse):
|
||||
output = []
|
||||
output.append(f'Search results for "{user_search}":')
|
||||
print()
|
||||
for i, result in enumerate(results.results, 1):
|
||||
title = getattr(result, 'title', None)
|
||||
url_value = getattr(result, 'url', None)
|
||||
@ -44,7 +43,8 @@ def format_tool_results(
|
||||
output.append('')
|
||||
return '\n'.join(output).rstrip()
|
||||
|
||||
client = Client(headers={'Authorization': (os.getenv('OLLAMA_API_KEY'))})
|
||||
api_key = os.getenv('OLLAMA_API_KEY')
|
||||
client = Client(headers={'Authorization': f"Bearer {s.getenv('OLLAMA_API_KEY')}"} if api_key else None)
|
||||
available_tools = {'web_search': client.web_search, 'web_fetch': client.web_fetch}
|
||||
|
||||
query = "ollama's new engine"
|
||||
|
||||
@ -652,7 +652,7 @@ class Client(BaseClient):
|
||||
return self._request(
|
||||
WebSearchResponse,
|
||||
'POST',
|
||||
'https://ollama.com/api/web_search',
|
||||
'http://localhost:8080/api/web_search',
|
||||
json=WebSearchRequest(
|
||||
query=query,
|
||||
max_results=max_results,
|
||||
@ -675,7 +675,7 @@ class Client(BaseClient):
|
||||
return self._request(
|
||||
WebFetchResponse,
|
||||
'POST',
|
||||
'https://ollama.com/api/web_fetch',
|
||||
'http://localhost:8080/api/web_fetch',
|
||||
json=WebFetchRequest(
|
||||
url=url,
|
||||
).model_dump(exclude_none=True),
|
||||
@ -764,7 +764,7 @@ class AsyncClient(BaseClient):
|
||||
return await self._request(
|
||||
WebSearchResponse,
|
||||
'POST',
|
||||
'https://ollama.com/api/web_search',
|
||||
'http://localhost:8080/api/web_search',
|
||||
json=WebSearchRequest(
|
||||
query=query,
|
||||
max_results=max_results,
|
||||
@ -784,7 +784,7 @@ class AsyncClient(BaseClient):
|
||||
return await self._request(
|
||||
WebFetchResponse,
|
||||
'POST',
|
||||
'https://ollama.com/api/web_fetch',
|
||||
'http://localhost:8080/api/web_fetch',
|
||||
json=WebFetchRequest(
|
||||
url=url,
|
||||
).model_dump(exclude_none=True),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user