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
1 change: 1 addition & 0 deletions py/packages/genkit/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies = [
"sse-starlette>=2.2.1",
"pillow",
"strenum>=0.4.15; python_version < '3.11'",
"dotpromptz>=0.1.4",
"uvicorn>=0.34.0",
"anyio>=4.9.0",
]
Expand Down
16 changes: 16 additions & 0 deletions py/plugins/anthropic/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

[project]
authors = [{ name = "Google" }]
classifiers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@


def _create_model_span(
model_name: str = "gemini-pro",
path: str = "/{myflow,t:flow}",
model_name: str = 'gemini-pro',
path: str = '/{myflow,t:flow}',
output: str = '{"usage": {"inputTokens": 100, "outputTokens": 50}}',
is_ok: bool = True,
start_time: int = 1000000000,
Expand All @@ -45,30 +45,30 @@ def _create_model_span(
"""
mock_span = MagicMock(spec=ReadableSpan)
mock_span.attributes = {
"genkit:type": "action",
"genkit:metadata:subtype": "model",
"genkit:name": model_name,
"genkit:path": path,
"genkit:output": output,
'genkit:type': 'action',
'genkit:metadata:subtype': 'model',
'genkit:name': model_name,
'genkit:path': path,
'genkit:output': output,
}
mock_span.status.is_ok = is_ok
mock_span.start_time = start_time
mock_span.end_time = end_time
return mock_span


@patch("genkit.plugins.firebase.add_gcp_telemetry")
@patch('genkit.plugins.firebase.add_gcp_telemetry')
def test_firebase_telemetry_delegates_to_gcp(mock_add_gcp_telemetry):
"""Test that Firebase telemetry delegates to GCP telemetry."""
add_firebase_telemetry()
mock_add_gcp_telemetry.assert_called_once_with(force_export=False)


@patch("genkit.plugins.google_cloud.telemetry.metrics._output_tokens")
@patch("genkit.plugins.google_cloud.telemetry.metrics._input_tokens")
@patch("genkit.plugins.google_cloud.telemetry.metrics._latency")
@patch("genkit.plugins.google_cloud.telemetry.metrics._failures")
@patch("genkit.plugins.google_cloud.telemetry.metrics._requests")
@patch('genkit.plugins.google_cloud.telemetry.metrics._output_tokens')
@patch('genkit.plugins.google_cloud.telemetry.metrics._input_tokens')
@patch('genkit.plugins.google_cloud.telemetry.metrics._latency')
@patch('genkit.plugins.google_cloud.telemetry.metrics._failures')
@patch('genkit.plugins.google_cloud.telemetry.metrics._requests')
def test_record_generate_metrics_with_model_action(
mock_requests,
mock_failures,
Expand All @@ -91,16 +91,16 @@ def test_record_generate_metrics_with_model_action(

# Create test span using helper
mock_span = _create_model_span(
model_name="gemini-pro",
path="/{myflow,t:flow}",
model_name='gemini-pro',
path='/{myflow,t:flow}',
output='{"usage": {"inputTokens": 100, "outputTokens": 50}}',
)

# Execute
record_generate_metrics(mock_span)

# Verify dimensions
expected_dimensions = {"model": "gemini-pro", "source": "myflow", "error": "none"}
expected_dimensions = {'model': 'gemini-pro', 'source': 'myflow', 'error': 'none'}

# Verify requests counter
mock_request_counter.add.assert_called_once_with(1, expected_dimensions)
Expand Down
2 changes: 1 addition & 1 deletion py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

[project]
dependencies = [
"dotpromptz==0.1.3",
"dotpromptz==0.1.4",
"genkit",
"genkit-plugin-anthropic",
"genkit-plugin-dev-local-vectorstore",
Expand Down
34 changes: 25 additions & 9 deletions py/samples/anthropic-hello/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

[project]
name = "anthropic-hello"
version = "0.1.0"
description = "Anthropic Hello Sample"
requires-python = ">=3.10"
dependencies = [
"genkit",
"genkit-plugin-anthropic",
"pydantic>=2.0.0",
"structlog>=24.0.0",
"genkit",
"genkit-plugin-anthropic",
"pydantic>=2.0.0",
"structlog>=24.0.0",
]
description = "Anthropic Hello Sample"
name = "anthropic-hello"
requires-python = ">=3.10"
version = "0.1.0"

[tool.uv.sources]
genkit-plugin-anthropic = { workspace = true }

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
requires = ["hatchling"]

[tool.hatch.build.targets.wheel]
packages = ["src"]
Loading
Loading