suvereo-model-google 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ Metadata-Version: 2.4
2
+ Name: suvereo-model-google
3
+ Version: 1.0.0
4
+ Summary: A plugin for Suvereo that provides a Google Gemini connector.
5
+ Author: Damian Sowiński
6
+ Author-email: damian.sowinski@upsidelab.io
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Requires-Dist: google-genai (>=1.70.0,<2.0.0)
16
+ Requires-Dist: langchain-core (>=1.2,<2.0)
17
+ Requires-Dist: langchain-google-genai (>=4.2,<5.0)
18
+ Requires-Dist: suvereo-common (>=1.0.0,<2)
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Google models
22
+
23
+ ## This Suvereo plugin enables Google models for generating embeddings and LLMs
24
+
25
+ ### 1. Install the `suvereo-model-google` package using pip:
26
+
27
+ ```shell
28
+ pip install suvereo-model-google
29
+ ```
30
+ ### 3. Set environment variable
31
+ ```
32
+ GOOGLE_API_KEY=<your_gemini_api_key>
33
+ ```
34
+
35
+
@@ -0,0 +1,14 @@
1
+ # Google models
2
+
3
+ ## This Suvereo plugin enables Google models for generating embeddings and LLMs
4
+
5
+ ### 1. Install the `suvereo-model-google` package using pip:
6
+
7
+ ```shell
8
+ pip install suvereo-model-google
9
+ ```
10
+ ### 3. Set environment variable
11
+ ```
12
+ GOOGLE_API_KEY=<your_gemini_api_key>
13
+ ```
14
+
@@ -0,0 +1,18 @@
1
+ [tool.poetry]
2
+ name = "suvereo-model-google"
3
+ version = "1.0.0"
4
+ description = "A plugin for Suvereo that provides a Google Gemini connector."
5
+ authors = ["Damian Sowiński <damian.sowinski@upsidelab.io>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ langchain-core = "^1.2"
10
+ python = "^3.10"
11
+ suvereo-common = ">=1.0.0,<2"
12
+ google-genai = "^1.70.0"
13
+ langchain-google-genai = "^4.2"
14
+
15
+
16
+ [build-system]
17
+ requires = ["poetry-core"]
18
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,2 @@
1
+ from .embedding import GoogleEmbeddingProvider as GoogleEmbeddingProvider
2
+ from .language_model import GoogleLanguageModelProvider as GoogleLanguageModelProvider
@@ -0,0 +1,35 @@
1
+ from google import genai
2
+ from google.genai.types import EmbedContentConfig
3
+ from suvereo_common.registry.embeddings import EmbeddingProvider
4
+ from suvereo_common.utils import prioritize_items
5
+
6
+ PRIORITIZED_MODELS = ["models/embedding-001", "models/text-embedding-004"]
7
+
8
+
9
+ class GoogleEmbeddingProvider(EmbeddingProvider):
10
+ NAME = "Google"
11
+
12
+ def generate_embeddings(self, content: str) -> list[float]:
13
+ """
14
+ Generates and returns an embedding vector for the given content using OpenAI's embeddings API.
15
+
16
+ Args:
17
+ content (str): The input text for which the embedding vector is to be generated.
18
+ """
19
+ config = EmbedContentConfig(output_dimensionality=self._dimensions)
20
+ with genai.Client() as client:
21
+ google_embedding = client.models.embed_content(
22
+ model=self._model,
23
+ config=config,
24
+ contents=content,
25
+ )
26
+
27
+ return google_embedding.embeddings[0].values
28
+
29
+ @staticmethod
30
+ def available_models() -> list[str]:
31
+ with genai.Client() as client:
32
+ all_models = client.models.list()
33
+
34
+ embedding_models = [model.name for model in all_models if "embedContent" in model.supported_actions]
35
+ return prioritize_items(embedding_models, PRIORITIZED_MODELS)
@@ -0,0 +1,49 @@
1
+ from google import genai
2
+ from langchain_core.callbacks import BaseCallbackHandler
3
+ from langchain_core.language_models import BaseLanguageModel
4
+ from langchain_google_genai import ChatGoogleGenerativeAI
5
+ from suvereo_common.registry.llm import LanguageModelProvider
6
+ from suvereo_common.structures import BaseContent, LLMFile
7
+ from suvereo_common.utils import prioritize_items
8
+
9
+ PRIORITIZED_MODELS = ["models/gemini-2.0-flash", "models/gemini-1.5-flash"]
10
+
11
+
12
+ class GoogleAIImageContent(BaseContent):
13
+ image_url: str
14
+
15
+
16
+ class GoogleAIFileContent(BaseContent):
17
+ mime_type: str
18
+ data: str
19
+
20
+
21
+ class GoogleLanguageModelProvider(LanguageModelProvider):
22
+ NAME = "Google"
23
+ STREAMING_AVAILABLE = False
24
+
25
+ def provide_language_model(self, callbacks: list[BaseCallbackHandler] | None = None) -> BaseLanguageModel:
26
+ return ChatGoogleGenerativeAI(model=self._model, callbacks=callbacks)
27
+
28
+ def model_name(self) -> str:
29
+ return self._model
30
+
31
+ @staticmethod
32
+ def available_models() -> list[str]:
33
+ with genai.Client() as client:
34
+ all_models = client.models.list()
35
+
36
+ gemini_models = [model.name for model in all_models if "generateContent" in model.supported_actions]
37
+ return prioritize_items(gemini_models, PRIORITIZED_MODELS)
38
+
39
+ @staticmethod
40
+ def prepare_image_object(file_object: LLMFile) -> GoogleAIImageContent:
41
+ image_url = f"data:{file_object.content_type};base64,{file_object.content}"
42
+ return GoogleAIImageContent(
43
+ type="image_url",
44
+ image_url=image_url,
45
+ )
46
+
47
+ @staticmethod
48
+ def prepare_file_object(file_object: LLMFile) -> GoogleAIFileContent:
49
+ return GoogleAIFileContent(type="media", data=file_object.content, mime_type=file_object.content_type)