Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/models/google.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ credentials = service_account.Credentials.from_service_account_file(
'path/to/service-account.json',
scopes=['https://www.googleapis.com/auth/cloud-platform'],
)
provider = GoogleProvider(credentials=credentials)
provider = GoogleProvider(credentials=credentials, project='your-project-id')
model = GoogleModel('gemini-1.5-flash', provider=provider)
agent = Agent(model)
...
Expand Down
8 changes: 4 additions & 4 deletions tests/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
WARNING: running these tests will make use of the relevant API tokens (and cost money).
"""

import json
import os
from collections.abc import AsyncIterator, Callable
from pathlib import Path
Expand Down Expand Up @@ -40,14 +41,15 @@ def vertexai(_: httpx.AsyncClient, tmp_path: Path) -> Model:
from pydantic_ai.providers.google import GoogleProvider

service_account_content = os.environ['GOOGLE_SERVICE_ACCOUNT_CONTENT']
project_id = json.loads(service_account_content)['project_id']
service_account_path = tmp_path / 'service_account.json'
service_account_path.write_text(service_account_content)

credentials = service_account.Credentials.from_service_account_file( # type: ignore[reportUnknownReturnType]
service_account_path,
scopes=['https://www.googleapis.com/auth/cloud-platform'],
)
provider = GoogleProvider(credentials=credentials)
provider = GoogleProvider(credentials=credentials, project=project_id)
return GoogleModel('gemini-1.5-flash', provider=provider)


Expand Down Expand Up @@ -91,9 +93,7 @@ def cohere(http_client: httpx.AsyncClient, _tmp_path: Path) -> Model:
params = [
pytest.param(openai, id='openai'),
pytest.param(gemini, marks=pytest.mark.skip(reason='API seems very flaky'), id='gemini'),
pytest.param(
vertexai, marks=pytest.mark.skip(reason='This needs to be fixed. It raises RuntimeError.'), id='vertexai'
),
pytest.param(vertexai, id='vertexai'),
pytest.param(groq, id='groq'),
pytest.param(anthropic, id='anthropic'),
pytest.param(ollama, id='ollama'),
Expand Down