From 90fce12922676da2770320d3de0ffa9a23ebcf93 Mon Sep 17 00:00:00 2001 From: Yesudeep Mangalapilly Date: Tue, 18 Feb 2025 12:49:38 -0800 Subject: [PATCH] fix(mypy): 1/2 mypy complains about conflicting main.py modules if we do not use unique names for the sample modules ERROR: ``` samples/coffee-shop/main.py: error: Duplicate module named "main" (also at "./samples/basic-gemini/main.py") samples/coffee-shop/main.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info samples/coffee-shop/main.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH ``` CHANGELOG: - [ ] Use the same structure as other packages with unambiguous names for entry point modules to avoid collisions to satisfy mypy. - [ ] Enable strict mypy checks by default; relax as necessary. --- py/pyproject.toml | 23 +++---- py/samples/basic-gemini/src/basic-gemini.py | 12 ++++ py/samples/coffee-shop/main.py | 65 ------------------- py/samples/coffee-shop/src/coffee-shop.py | 12 ++++ py/samples/context-caching/main.py | 65 ------------------- .../context-caching/src/context-caching.py | 12 ++++ py/samples/flow-sample1/main.py | 65 ------------------- py/samples/flow-sample1/src/flow-sample1.py | 12 ++++ py/samples/hello/main.py | 65 ------------------- .../main.py => hello/src/hello.py} | 0 py/samples/menu/main.py | 65 ------------------- py/samples/menu/src/menu.py | 12 ++++ py/samples/prompt-file/main.py | 65 ------------------- py/samples/prompt-file/src/prompt-file.py | 12 ++++ py/samples/rag/main.py | 65 ------------------- py/samples/rag/src/rag.py | 12 ++++ py/samples/vertex-ai-model-garden/main.py | 65 ------------------- .../src/vertex-ai-model-garden.py | 12 ++++ py/samples/vertex-ai-reranker/main.py | 65 ------------------- .../src/vertex-ai-reranker.py | 12 ++++ py/samples/vertex-ai-vector-search/main.py | 65 ------------------- .../src/vertex-ai-vector-search.py | 12 ++++ 22 files changed, 132 insertions(+), 661 deletions(-) create mode 100644 py/samples/basic-gemini/src/basic-gemini.py delete mode 100644 py/samples/coffee-shop/main.py create mode 100644 py/samples/coffee-shop/src/coffee-shop.py delete mode 100644 py/samples/context-caching/main.py create mode 100644 py/samples/context-caching/src/context-caching.py delete mode 100644 py/samples/flow-sample1/main.py create mode 100644 py/samples/flow-sample1/src/flow-sample1.py delete mode 100644 py/samples/hello/main.py rename py/samples/{basic-gemini/main.py => hello/src/hello.py} (100%) delete mode 100644 py/samples/menu/main.py create mode 100644 py/samples/menu/src/menu.py delete mode 100644 py/samples/prompt-file/main.py create mode 100644 py/samples/prompt-file/src/prompt-file.py delete mode 100644 py/samples/rag/main.py create mode 100644 py/samples/rag/src/rag.py delete mode 100644 py/samples/vertex-ai-model-garden/main.py create mode 100644 py/samples/vertex-ai-model-garden/src/vertex-ai-model-garden.py delete mode 100644 py/samples/vertex-ai-reranker/main.py create mode 100644 py/samples/vertex-ai-reranker/src/vertex-ai-reranker.py delete mode 100644 py/samples/vertex-ai-vector-search/main.py create mode 100644 py/samples/vertex-ai-vector-search/src/vertex-ai-vector-search.py diff --git a/py/pyproject.toml b/py/pyproject.toml index 6e3b948ac..70919b11d 100644 --- a/py/pyproject.toml +++ b/py/pyproject.toml @@ -154,19 +154,20 @@ mypy_path = [ "plugins/ollama/src", "plugins/pinecone/src", "plugins/vertex-ai/src", - "samples/basic-gemini", - "samples/coffee-shop", - "samples/context-caching", - "samples/flow-sample1", - "samples/hello", - "samples/menu", - "samples/prompt-file", - "samples/rag", - "samples/vertex-ai-model-garden", - "samples/vertex-ai-reranker", - "samples/vertex-ai-vector-search", + "samples/basic-gemini/src", + "samples/coffee-shop/src", + "samples/context-caching/src", + "samples/flow-sample1/src", + "samples/hello/src", + "samples/menu/src", + "samples/prompt-file/src", + "samples/rag/src", + "samples/vertex-ai-model-garden/src", + "samples/vertex-ai-reranker/src", + "samples/vertex-ai-vector-search/src", ] namespace_packages = true +strict = true warn_unused_configs = true [tool.datamodel-codegen] diff --git a/py/samples/basic-gemini/src/basic-gemini.py b/py/samples/basic-gemini/src/basic-gemini.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/basic-gemini/src/basic-gemini.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/coffee-shop/main.py b/py/samples/coffee-shop/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/coffee-shop/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/coffee-shop/src/coffee-shop.py b/py/samples/coffee-shop/src/coffee-shop.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/coffee-shop/src/coffee-shop.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/context-caching/main.py b/py/samples/context-caching/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/context-caching/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/context-caching/src/context-caching.py b/py/samples/context-caching/src/context-caching.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/context-caching/src/context-caching.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/flow-sample1/main.py b/py/samples/flow-sample1/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/flow-sample1/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/flow-sample1/src/flow-sample1.py b/py/samples/flow-sample1/src/flow-sample1.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/flow-sample1/src/flow-sample1.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/hello/main.py b/py/samples/hello/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/hello/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/basic-gemini/main.py b/py/samples/hello/src/hello.py similarity index 100% rename from py/samples/basic-gemini/main.py rename to py/samples/hello/src/hello.py diff --git a/py/samples/menu/main.py b/py/samples/menu/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/menu/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/menu/src/menu.py b/py/samples/menu/src/menu.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/menu/src/menu.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/prompt-file/main.py b/py/samples/prompt-file/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/prompt-file/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/prompt-file/src/prompt-file.py b/py/samples/prompt-file/src/prompt-file.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/prompt-file/src/prompt-file.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/rag/main.py b/py/samples/rag/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/rag/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/rag/src/rag.py b/py/samples/rag/src/rag.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/rag/src/rag.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/vertex-ai-model-garden/main.py b/py/samples/vertex-ai-model-garden/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/vertex-ai-model-garden/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/vertex-ai-model-garden/src/vertex-ai-model-garden.py b/py/samples/vertex-ai-model-garden/src/vertex-ai-model-garden.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/vertex-ai-model-garden/src/vertex-ai-model-garden.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/vertex-ai-reranker/main.py b/py/samples/vertex-ai-reranker/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/vertex-ai-reranker/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/vertex-ai-reranker/src/vertex-ai-reranker.py b/py/samples/vertex-ai-reranker/src/vertex-ai-reranker.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/vertex-ai-reranker/src/vertex-ai-reranker.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main() diff --git a/py/samples/vertex-ai-vector-search/main.py b/py/samples/vertex-ai-vector-search/main.py deleted file mode 100644 index 74ee3af4b..000000000 --- a/py/samples/vertex-ai-vector-search/main.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -"""A hello world sample that just calls some flows.""" - -from typing import Any - -from genkit.core.schema_types import GenerateRequest, Message, Role, TextPart -from genkit.plugins.vertex_ai import VertexAI -from genkit.veneer.veneer import Genkit -from pydantic import BaseModel, Field - -ai = Genkit(plugins=[VertexAI()], model=VertexAI.VERTEX_AI_MODEL_NAME) - - -class MyInput(BaseModel): - a: int = Field(description='a field') - b: int = Field(description='b field') - - -def hi_fn(hi_input) -> GenerateRequest: - return GenerateRequest( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi, my name is ' + hi_input)], - ) - ] - ) - - -# hi = ai.define_prompt( -# name="hi", -# fn=hi_fn, -# model=gemini("gemini-1.5-flash")) -# -# @ai.flow() -# def hiPrompt(): -# return hi("Pavel") - - -@ai.flow() -def say_hi(name: str): - return ai.generate( - messages=[ - Message( - role=Role.user, - content=[TextPart(text='hi ' + name)], - ) - ] - ) - - -@ai.flow() -def sum_two_numbers2(my_input: MyInput) -> Any: - return my_input.a + my_input.b - - -def main() -> None: - print(say_hi('John Doe')) - print(sum_two_numbers2(MyInput(a=1, b=3))) - - -if __name__ == '__main__': - main() diff --git a/py/samples/vertex-ai-vector-search/src/vertex-ai-vector-search.py b/py/samples/vertex-ai-vector-search/src/vertex-ai-vector-search.py new file mode 100644 index 000000000..c80335864 --- /dev/null +++ b/py/samples/vertex-ai-vector-search/src/vertex-ai-vector-search.py @@ -0,0 +1,12 @@ +# Copyright 2025 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +"""A stub for the sample to come.""" + + +def main() -> None: + print('Hey') + + +if __name__ == '__main__': + main()