gllm-inference-binary 0.4.62__cp311-cp311-win_amd64.whl → 0.5.0__cp311-cp311-win_amd64.whl

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.

Potentially problematic release.


This version of gllm-inference-binary might be problematic. Click here for more details.

Files changed (85) hide show
  1. gllm_inference/builder/build_lm_request_processor.pyi +1 -4
  2. gllm_inference/catalog/catalog.pyi +34 -38
  3. gllm_inference/catalog/lm_request_processor_catalog.pyi +4 -10
  4. gllm_inference/catalog/prompt_builder_catalog.pyi +25 -37
  5. gllm_inference/constants.pyi +0 -3
  6. gllm_inference/em_invoker/__init__.pyi +1 -4
  7. gllm_inference/em_invoker/em_invoker.pyi +6 -25
  8. gllm_inference/em_invoker/google_em_invoker.pyi +1 -1
  9. gllm_inference/em_invoker/langchain/__init__.pyi +1 -2
  10. gllm_inference/em_invoker/langchain_em_invoker.pyi +2 -12
  11. gllm_inference/em_invoker/openai_em_invoker.pyi +1 -1
  12. gllm_inference/em_invoker/twelevelabs_em_invoker.pyi +2 -18
  13. gllm_inference/em_invoker/voyage_em_invoker.pyi +2 -5
  14. gllm_inference/lm_invoker/__init__.pyi +1 -4
  15. gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +7 -29
  16. gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +5 -18
  17. gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +6 -14
  18. gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +7 -14
  19. gllm_inference/lm_invoker/google_lm_invoker.pyi +7 -21
  20. gllm_inference/lm_invoker/langchain_lm_invoker.pyi +8 -21
  21. gllm_inference/lm_invoker/litellm_lm_invoker.pyi +6 -13
  22. gllm_inference/lm_invoker/lm_invoker.pyi +17 -18
  23. gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +8 -22
  24. gllm_inference/lm_invoker/openai_lm_invoker.pyi +18 -24
  25. gllm_inference/prompt_builder/__init__.pyi +1 -6
  26. gllm_inference/prompt_builder/prompt_builder.pyi +9 -102
  27. gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi +4 -4
  28. gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi +4 -4
  29. gllm_inference/prompt_formatter/llama_prompt_formatter.pyi +3 -3
  30. gllm_inference/prompt_formatter/mistral_prompt_formatter.pyi +3 -3
  31. gllm_inference/prompt_formatter/openai_prompt_formatter.pyi +4 -4
  32. gllm_inference/prompt_formatter/prompt_formatter.pyi +4 -4
  33. gllm_inference/request_processor/lm_request_processor.pyi +12 -25
  34. gllm_inference/request_processor/uses_lm_mixin.pyi +4 -10
  35. gllm_inference/schema/__init__.pyi +11 -4
  36. gllm_inference/schema/attachment.pyi +76 -0
  37. gllm_inference/schema/code_exec_result.pyi +14 -0
  38. gllm_inference/schema/enums.pyi +9 -9
  39. gllm_inference/schema/lm_output.pyi +36 -0
  40. gllm_inference/schema/message.pyi +52 -0
  41. gllm_inference/schema/model_id.pyi +1 -1
  42. gllm_inference/schema/reasoning.pyi +15 -0
  43. gllm_inference/schema/token_usage.pyi +11 -0
  44. gllm_inference/schema/tool_call.pyi +14 -0
  45. gllm_inference/schema/tool_result.pyi +11 -0
  46. gllm_inference/schema/type_alias.pyi +6 -8
  47. gllm_inference/utils/__init__.pyi +2 -3
  48. gllm_inference/utils/validation.pyi +12 -0
  49. gllm_inference.cp311-win_amd64.pyd +0 -0
  50. gllm_inference.pyi +8 -42
  51. {gllm_inference_binary-0.4.62.dist-info → gllm_inference_binary-0.5.0.dist-info}/METADATA +1 -7
  52. gllm_inference_binary-0.5.0.dist-info/RECORD +93 -0
  53. gllm_inference/builder/model_id.pyi +0 -13
  54. gllm_inference/catalog/component_map.pyi +0 -8
  55. gllm_inference/em_invoker/google_generativeai_em_invoker.pyi +0 -32
  56. gllm_inference/em_invoker/google_vertexai_em_invoker.pyi +0 -34
  57. gllm_inference/em_invoker/langchain/tei_embeddings.pyi +0 -71
  58. gllm_inference/em_invoker/tei_em_invoker.pyi +0 -48
  59. gllm_inference/lm_invoker/google_generativeai_lm_invoker.pyi +0 -51
  60. gllm_inference/lm_invoker/google_vertexai_lm_invoker.pyi +0 -54
  61. gllm_inference/lm_invoker/tgi_lm_invoker.pyi +0 -34
  62. gllm_inference/multimodal_em_invoker/__init__.pyi +0 -4
  63. gllm_inference/multimodal_em_invoker/google_vertexai_multimodal_em_invoker.pyi +0 -52
  64. gllm_inference/multimodal_em_invoker/multimodal_em_invoker.pyi +0 -35
  65. gllm_inference/multimodal_em_invoker/twelvelabs_multimodal_em_invoker.pyi +0 -49
  66. gllm_inference/multimodal_lm_invoker/__init__.pyi +0 -7
  67. gllm_inference/multimodal_lm_invoker/anthropic_multimodal_lm_invoker.pyi +0 -44
  68. gllm_inference/multimodal_lm_invoker/azure_openai_multimodal_lm_invoker.pyi +0 -41
  69. gllm_inference/multimodal_lm_invoker/google_generativeai_multimodal_lm_invoker.pyi +0 -30
  70. gllm_inference/multimodal_lm_invoker/google_vertexai_multimodal_lm_invoker.pyi +0 -67
  71. gllm_inference/multimodal_lm_invoker/multimodal_lm_invoker.pyi +0 -51
  72. gllm_inference/multimodal_lm_invoker/openai_multimodal_lm_invoker.pyi +0 -43
  73. gllm_inference/multimodal_prompt_builder/__init__.pyi +0 -3
  74. gllm_inference/multimodal_prompt_builder/multimodal_prompt_builder.pyi +0 -57
  75. gllm_inference/prompt_builder/agnostic_prompt_builder.pyi +0 -34
  76. gllm_inference/prompt_builder/huggingface_prompt_builder.pyi +0 -44
  77. gllm_inference/prompt_builder/llama_prompt_builder.pyi +0 -41
  78. gllm_inference/prompt_builder/mistral_prompt_builder.pyi +0 -41
  79. gllm_inference/prompt_builder/openai_prompt_builder.pyi +0 -35
  80. gllm_inference/schema/model_io.pyi +0 -178
  81. gllm_inference/utils/openai_multimodal_lm_helper.pyi +0 -36
  82. gllm_inference/utils/retry.pyi +0 -4
  83. gllm_inference/utils/utils.pyi +0 -142
  84. gllm_inference_binary-0.4.62.dist-info/RECORD +0 -115
  85. {gllm_inference_binary-0.4.62.dist-info → gllm_inference_binary-0.5.0.dist-info}/WHEEL +0 -0
@@ -1,34 +0,0 @@
1
- from gllm_inference.lm_invoker.openai_compatible_lm_invoker import OpenAICompatibleLMInvoker as OpenAICompatibleLMInvoker
2
- from typing import Any
3
-
4
- DEPRECATION_MESSAGE: str
5
-
6
- class TGILMInvoker(OpenAICompatibleLMInvoker):
7
- """A language model invoker to interact with language models hosted in Text Generation Inference (TGI).
8
-
9
- This class has been deprecated as Text Generation Inference is now supported through `OpenAICompatibleLMInvoker`.
10
- This class is maintained for backward compatibility and will be removed in version 0.5.0.
11
-
12
- Attributes:
13
- model_id (str): The model ID of the language model.
14
- model_provider (str): The provider of the language model.
15
- model_name (str): The name of the language model.
16
- client (AsyncOpenAI): The OpenAI client instance.
17
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the model.
18
- tools (list[Any]): The list of tools provided to the model to enable tool calling.
19
- response_schema (ResponseSchema | None): The schema of the response. If provided, the model will output a
20
- structured response as defined by the schema. Supports both Pydantic BaseModel and JSON schema dictionary.
21
- output_analytics (bool): Whether to output the invocation analytics.
22
- retry_config (RetryConfig): The retry configuration for the language model.
23
- """
24
- def __init__(self, url: str, username: str = '', password: str = '', api_key: str = '', default_hyperparameters: dict[str, Any] | None = None) -> None:
25
- """Initializes a new instance of the TGILMInvoker class.
26
-
27
- Args:
28
- url (str): The URL of the TGI service.
29
- username (str, optional): The username for Basic Authentication. Defaults to an empty string.
30
- password (str, optional): The password for Basic Authentication. Defaults to an empty string.
31
- api_key (str, optional): The API key for authenticating with the TGI service. Defaults to an empty string.
32
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
33
- Defaults to None.
34
- """
@@ -1,4 +0,0 @@
1
- from gllm_inference.multimodal_em_invoker.google_vertexai_multimodal_em_invoker import GoogleVertexAIMultimodalEMInvoker as GoogleVertexAIMultimodalEMInvoker
2
- from gllm_inference.multimodal_em_invoker.twelvelabs_multimodal_em_invoker import TwelveLabsMultimodalEMInvoker as TwelveLabsMultimodalEMInvoker
3
-
4
- __all__ = ['GoogleVertexAIMultimodalEMInvoker', 'TwelveLabsMultimodalEMInvoker']
@@ -1,52 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_inference.multimodal_em_invoker.multimodal_em_invoker import BaseMultimodalEMInvoker as BaseMultimodalEMInvoker
3
- from gllm_inference.schema import Vector as Vector
4
- from gllm_inference.utils import get_mime_type as get_mime_type, is_local_file_path as is_local_file_path, is_remote_file_path as is_remote_file_path, load_google_vertexai_project_id as load_google_vertexai_project_id
5
-
6
- VALID_EXTENSION_MAP: Incomplete
7
- VALID_EXTENSIONS: Incomplete
8
- FILE_TYPE_KEY_MAP: Incomplete
9
- DEPRECATION_MESSAGE: str
10
-
11
- class GoogleVertexAIMultimodalEMInvoker(BaseMultimodalEMInvoker[str | bytes]):
12
- """A class to interact with multimodal embedding models hosted through Google's Vertex AI API endpoints.
13
-
14
- The `GoogleVertexAIMultimodalEMInvoker` class is responsible for invoking a multimodal embedding model using the
15
- Google Vertex AI API. It uses the multimodal embedding model to transform a content or a list of contents
16
- into their vector representations.
17
-
18
- Attributes:
19
- model (MultiModalEmbeddingModel): The multimodal embedding model to be used for embedding the input content.
20
- embedding_dimension (int): The dimension of the embedding vector.
21
-
22
- Notes:
23
- In order to use the `GoogleVertexAIMultimodalEMInvoker`, a credentials JSON file for a Google Cloud service
24
- account with the Vertex AI API enabled must be provided. For more information on how to create the credentials
25
- file, please refer to the following pages:
26
- 1. https://cloud.google.com/docs/authentication/application-default-credentials.
27
- 2. https://developers.google.com/workspace/guides/create-credentials.
28
-
29
- The `GoogleVertexAIMultimodalEMInvoker` currently supports the following contents:
30
- 1. Text, which can be passed as plain strings.
31
- 2. Image, which can be passed as:
32
- 1. Base64 encoded image bytes.
33
- 2. URL pointing to an image.
34
- 3. Local image file path.
35
- 4. Video, which can be passed as:
36
- 1. Base64 encoded video bytes.
37
- 2. URL pointing to a video.
38
- 3. Local video file path.
39
- """
40
- model: Incomplete
41
- embedding_dimension: Incomplete
42
- def __init__(self, model_name: str, credentials_path: str, project_id: str | None = None, location: str = 'us-central1', embedding_dimension: int = 1408) -> None:
43
- '''Initializes a new instance of the GoogleVertexAIMultimodalEMInvoker class.
44
-
45
- Args:
46
- model_name (str): The name of the multimodal embedding model to be used.
47
- credentials_path (str): The path to the Google Cloud service account credentials JSON file.
48
- project_id (str | None, optional): The Google Cloud project ID. Defaults to None, in which case the
49
- project ID will be loaded from the credentials file.
50
- location (str, optional): The location of the Google Cloud project. Defaults to "us-central1".
51
- embedding_dimension (int, optional): The dimension of the embedding vector. Defaults to 1408.
52
- '''
@@ -1,35 +0,0 @@
1
- import abc
2
- from abc import ABC
3
- from gllm_inference.schema import Vector as Vector
4
- from typing import Generic, TypeVar
5
-
6
- InputType = TypeVar('InputType')
7
-
8
- class BaseMultimodalEMInvoker(ABC, Generic[InputType], metaclass=abc.ABCMeta):
9
- """A base class for multimodal embedding model invokers used in Gen AI applications.
10
-
11
- The `BaseMultimodalEMInvoker` class provides a framework for invoking multimodal embedding models.
12
- The input may contain multimodal content that is defined by the type variable `InputType`.
13
-
14
- Attributes:
15
- None
16
- """
17
- async def invoke(self, content: InputType | list[InputType]) -> Vector | list[Vector]:
18
- """Invokes the multimodal embedding model with the provided content.
19
-
20
- This method validates the content and then invokes the multimodal embedding model by calling the
21
- `_invoke` method.
22
-
23
- Args:
24
- content (InputType | list[InputType]): The input content or list of input contents to be embedded using the
25
- multimodal embedding model. The content may contain multimodal inputs that is defined by the type
26
- variable `InputType`.
27
-
28
- Returns:
29
- Vector | list[Vector]: The vector representations of the input content:
30
- 1. If the input is a single content, the output is a `Vector`.
31
- 2. If the input is a list of contents, the output is a `list[Vector]`.
32
-
33
- Raises:
34
- ValueError: If the content is not of the correct type.
35
- """
@@ -1,49 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_inference.multimodal_em_invoker.multimodal_em_invoker import BaseMultimodalEMInvoker as BaseMultimodalEMInvoker
3
- from gllm_inference.schema import Vector as Vector
4
- from gllm_inference.utils import get_mime_type as get_mime_type, is_local_file_path as is_local_file_path, is_remote_file_path as is_remote_file_path
5
-
6
- VALID_EXTENSION_MAP: Incomplete
7
- VALID_EXTENSIONS: Incomplete
8
- FILE_TYPE_KEY_MAP: Incomplete
9
- DEFAULT_VIDEO_STATUS_CHECK_INTERVAL: int
10
- DEPRECATION_MESSAGE: str
11
-
12
- class TwelveLabsMultimodalEMInvoker(BaseMultimodalEMInvoker[str | bytes]):
13
- """A class to interact with multimodal embedding models hosted through TwelveLabs API endpoints.
14
-
15
- The `TwelveLabsMultimodalEMInvoker` class is responsible for invoking a multimodal embedding model using the
16
- TwelveLabs API. It uses the multimodal embedding model to transform a content or a list of contents
17
- into their vector representations.
18
-
19
- Attributes:
20
- client (TwelveLabs): The client for the TwelveLabs API.
21
- model_name (str): The name of the multimodal embedding model to be used.
22
-
23
- Notes:
24
- The `TwelveLabsMultimodalEMInvoker` currently supports the following contents:
25
- 1. Text, which can be passed as plain strings.
26
- 2. Audio, which can be passed as:
27
- 1. Base64 encoded audio bytes.
28
- 2. URL pointing to an audio file.
29
- 3. Local audio file path.
30
- 3. Image, which can be passed as:
31
- 1. Base64 encoded image bytes.
32
- 2. URL pointing to an image.
33
- 3. Local image file path.
34
- 4. Video, which can be passed as:
35
- 1. URL pointing to a video.
36
- 2. Local video file path.
37
- """
38
- client: Incomplete
39
- model_name: Incomplete
40
- video_status_check_interval: Incomplete
41
- def __init__(self, model_name: str, api_key: str, video_status_check_interval: int = ...) -> None:
42
- """Initializes a new instance of the TwelveLabsMultimodalEMInvoker class.
43
-
44
- Args:
45
- model_name (str): The name of the multimodal embedding model to be used.
46
- api_key (str): The API key for the TwelveLabs API.
47
- video_status_check_interval (int, optional): The interval in seconds to check the status of the video
48
- embedding task. Defaults to DEFAULT_VIDEO_STATUS_CHECK_INTERVAL.
49
- """
@@ -1,7 +0,0 @@
1
- from gllm_inference.multimodal_lm_invoker.anthropic_multimodal_lm_invoker import AnthropicMultimodalLMInvoker as AnthropicMultimodalLMInvoker
2
- from gllm_inference.multimodal_lm_invoker.azure_openai_multimodal_lm_invoker import AzureOpenAIMultimodalLMInvoker as AzureOpenAIMultimodalLMInvoker
3
- from gllm_inference.multimodal_lm_invoker.google_generativeai_multimodal_lm_invoker import GoogleGenerativeAIMultimodalLMInvoker as GoogleGenerativeAIMultimodalLMInvoker
4
- from gllm_inference.multimodal_lm_invoker.google_vertexai_multimodal_lm_invoker import GoogleVertexAIMultimodalLMInvoker as GoogleVertexAIMultimodalLMInvoker
5
- from gllm_inference.multimodal_lm_invoker.openai_multimodal_lm_invoker import OpenAIMultimodalLMInvoker as OpenAIMultimodalLMInvoker
6
-
7
- __all__ = ['AnthropicMultimodalLMInvoker', 'AzureOpenAIMultimodalLMInvoker', 'GoogleGenerativeAIMultimodalLMInvoker', 'GoogleVertexAIMultimodalLMInvoker', 'OpenAIMultimodalLMInvoker']
@@ -1,44 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_core.event import EventEmitter as EventEmitter
3
- from gllm_inference.multimodal_lm_invoker.multimodal_lm_invoker import BaseMultimodalLMInvoker as BaseMultimodalLMInvoker
4
- from gllm_inference.schema import PromptRole as PromptRole
5
- from gllm_inference.utils import get_mime_type as get_mime_type, is_local_file_path as is_local_file_path, is_remote_file_path as is_remote_file_path
6
- from typing import Any
7
-
8
- VALID_EXTENSIONS: Incomplete
9
- DEFAULT_MAX_TOKENS: int
10
- DEPRECATION_MESSAGE: str
11
-
12
- class AnthropicMultimodalLMInvoker(BaseMultimodalLMInvoker[str | bytes, str]):
13
- """An invoker to interact with multimodal language models hosted through Anthropic API endpoints.
14
-
15
- The `AnthropicMultimodalLMInvoker` class is designed to interact with multimodal language models hosted through
16
- Anthropic API endpoints. It provides a framework for invoking multimodal language models with the provided prompt
17
- and hyperparameters. It supports both standard and streaming invocation. Streaming mode is enabled if an event
18
- emitter is provided.
19
-
20
- Attributes:
21
- client (Anthropic): The Anthropic client instance.
22
- model_name (str): The name of the Anthropic model.
23
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the multimodal language model.
24
-
25
- Notes:
26
- The `AnthropicMultimodalLMInvoker` currently supports the following contents:
27
- 1. Text, which can be passed as plain strings.
28
- 2. Image, which can be passed as:
29
- 1. Base64 encoded image bytes.
30
- 2. URL pointing to an image.
31
- 3. Local image file path.
32
- """
33
- client: Incomplete
34
- model_name: Incomplete
35
- def __init__(self, model_name: str, api_key: str, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None) -> None:
36
- """Initializes a new instance of the AnthropicMultimodalLMInvoker class.
37
-
38
- Args:
39
- model_name (str): The name of the Anthropic model.
40
- api_key (str): The API key for authenticating with Anthropic.
41
- model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
42
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
43
- Defaults to None.
44
- """
@@ -1,41 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_core.event import EventEmitter as EventEmitter
3
- from gllm_inference.multimodal_lm_invoker.multimodal_lm_invoker import BaseMultimodalLMInvoker as BaseMultimodalLMInvoker
4
- from gllm_inference.utils.openai_multimodal_lm_helper import parse_prompt as parse_prompt, validate_content_type as validate_content_type
5
- from typing import Any
6
-
7
- DEPRECATION_MESSAGE: str
8
-
9
- class AzureOpenAIMultimodalLMInvoker(BaseMultimodalLMInvoker[str | bytes, str]):
10
- """An invoker to interact with multimodal language models hosted through Azure OpenAI API endpoints.
11
-
12
- The `AzureOpenAIMultimodalLMInvoker` class is designed to interact with multimodal language models hosted through
13
- Azure OpenAI API endpoints. It provides a framework for invoking multimodal language models with the provided prompt
14
- and hyperparameters. It supports both standard and streaming invocation.
15
- Streaming mode is enabled if an event emitter is provided.
16
-
17
- Attributes:
18
- client (AsyncAzureOpenAI): The AsyncAzureOpenAI client instance.
19
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the multimodal language model.
20
-
21
- Notes:
22
- The `AzureOpenAIMultimodalLMInvoker` currently supports the following contents:
23
- 1. Text, which can be passed as plain strings.
24
- 2. Image, which can be passed as:
25
- 1. Base64 encoded image bytes.
26
- 2. URL pointing to an image.
27
- 3. Local image file path.
28
- """
29
- client: Incomplete
30
- def __init__(self, api_key: str, azure_endpoint: str, azure_deployment: str, api_version: str, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None) -> None:
31
- """Initializes a new instance of the AzureOpenAIMultimodalLMInvoker class.
32
-
33
- Args:
34
- api_key (str): The API key for authenticating with Azure OpenAI.
35
- azure_endpoint (str): The endpoint of the Azure OpenAI service.
36
- azure_deployment (str): The deployment of the Azure OpenAI service.
37
- api_version (str): The API version of the Azure OpenAI service.
38
- model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
39
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
40
- Defaults to None.
41
- """
@@ -1,30 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_core.event import EventEmitter as EventEmitter
3
- from gllm_inference.lm_invoker import GoogleLMInvoker as GoogleLMInvoker
4
- from gllm_inference.multimodal_lm_invoker.multimodal_lm_invoker import BaseMultimodalLMInvoker as BaseMultimodalLMInvoker
5
- from pydantic import BaseModel as BaseModel
6
- from typing import Any
7
-
8
- DEPRECATION_MESSAGE: str
9
-
10
- class GoogleGenerativeAIMultimodalLMInvoker(BaseMultimodalLMInvoker[str | bytes, str]):
11
- """An invoker to interact with multimodal language models hosted through Google's Generative AI API endpoints.
12
-
13
- This class is deprecated as it has been replaced by the `GoogleLMInvoker` class.
14
-
15
- Attributes:
16
- model (GoogleLMInvoker): The Google Gemini model instance.
17
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the multimodal language model.
18
- """
19
- model: Incomplete
20
- def __init__(self, model_name: str, api_key: str, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, response_schema: BaseModel | None = None) -> None:
21
- """Initializes a new instance of the GoogleGenerativeAIMultimodalLMInvoker class.
22
-
23
- Args:
24
- model_name (str): The name of the Google Gemini model.
25
- api_key (str): The API key for authenticating with Google Gemini.
26
- model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
27
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
28
- Defaults to None.
29
- response_schema (BaseModel | None, optional): The response schema for the model. Defaults to None.
30
- """
@@ -1,67 +0,0 @@
1
- from _typeshed import Incomplete
2
- from enum import Enum as Enum
3
- from gllm_core.constants import EventLevel as EventLevel, EventType as EventType
4
- from gllm_core.event import EventEmitter as EventEmitter
5
- from gllm_inference.multimodal_lm_invoker.multimodal_lm_invoker import BaseMultimodalLMInvoker as BaseMultimodalLMInvoker
6
- from gllm_inference.schema import PromptRole as PromptRole
7
- from gllm_inference.utils import get_mime_type as get_mime_type, invoke_google_multimodal_lm as invoke_google_multimodal_lm, is_local_file_path as is_local_file_path, is_remote_file_path as is_remote_file_path, load_google_vertexai_project_id as load_google_vertexai_project_id
8
- from pydantic import BaseModel as BaseModel
9
- from typing import Any
10
-
11
- VALID_EXTENSION_MAP: Incomplete
12
- VALID_EXTENSIONS: Incomplete
13
- DEPRECATION_MESSAGE: str
14
-
15
- class GoogleVertexAIMultimodalLMInvoker(BaseMultimodalLMInvoker[str | bytes, str]):
16
- """An invoker to interact with multimodal language models hosted through Google's Vertex AI API endpoints.
17
-
18
- The `GoogleVertexAIMultimodalLMInvoker` class is designed to interact with multimodal language models hosted
19
- through Google's Vertex AI API endpoints. It provides a framework for invoking multimodal language models with
20
- the provided prompt and hyperparameters. It supports both standard and streaming invocation. Streaming mode is
21
- enabled if an event emitter is provided.
22
-
23
- Attributes:
24
- client (GenerativeModel): The Google Vertex AI client instance.
25
- extra_kwargs (dict[str, Any]): Additional keyword arguments for the `generate_content_async` method.
26
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the multimodal language model.
27
-
28
- Notes:
29
- The `GoogleVertexAIMultimodalLMInvoker` currently supports the following contents:
30
- 1. Text, which can be passed as plain strings.
31
- 2. Audio, which can be passed as:
32
- 1. Base64 encoded audio bytes.
33
- 2. URL pointing to an audio file.
34
- 3. Local audio file path.
35
- 3. Image, which can be passed as:
36
- 1. Base64 encoded image bytes.
37
- 2. URL pointing to an image.
38
- 3. Local image file path.
39
- 4. Video, which can be passed as:
40
- 1. Base64 encoded video bytes.
41
- 2. URL pointing to a video.
42
- 3. Local video file path.
43
- 5. Document, which can be passed as:
44
- 1. Base64 encoded document bytes.
45
- 2. URL pointing to a document.
46
- 3. Local document file path.
47
-
48
- The `GoogleVertexAIMultimodalLMInvoker` also supports structured outputs through the `response_schema`
49
- argument. For more information, please refer to the following page:
50
- https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output.
51
- """
52
- client: Incomplete
53
- extra_kwargs: Incomplete
54
- def __init__(self, model_name: str, credentials_path: str, project_id: str | None = None, location: str = 'us-central1', model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, response_schema: dict[str, Any] | None = None) -> None:
55
- '''Initializes a new instance of the GoogleVertexAIMultimodalLMInvoker class.
56
-
57
- Args:
58
- model_name (str): The name of the multimodal language model to be used.
59
- credentials_path (str): The path to the Google Cloud service account credentials JSON file.
60
- project_id (str | None, optional): The Google Cloud project ID. Defaults to None, in which case the
61
- project ID will be loaded from the credentials file.
62
- location (str, optional): The location of the Google Cloud project. Defaults to "us-central1".
63
- model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
64
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
65
- Defaults to None.
66
- response_schema (dict[str, Any] | None, optional): The response schema for the model. Defaults to None.
67
- '''
@@ -1,51 +0,0 @@
1
- import abc
2
- from _typeshed import Incomplete
3
- from abc import ABC
4
- from gllm_core.event import EventEmitter as EventEmitter
5
- from gllm_inference.constants import MESSAGE_TUPLE_LENGTH as MESSAGE_TUPLE_LENGTH
6
- from typing import Any, Generic
7
-
8
- InputType: Incomplete
9
- OutputType: Incomplete
10
-
11
- class BaseMultimodalLMInvoker(ABC, Generic[InputType, OutputType], metaclass=abc.ABCMeta):
12
- """A base class for multimodal language model invokers used in Gen AI applications.
13
-
14
- The `BaseMultimodalLMInvoker` class provides a framework for invoking multimodal language models with the provided
15
- prompt and hyperparameters. The prompt may contain multimodal inputs that is defined by the type variable
16
- `InputType`, while the multimodal output is defined by the type variable `OutputType`. It handles both standard
17
- and streaming invocation.
18
-
19
- Attributes:
20
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the multimodal language model.
21
- """
22
- default_hyperparameters: Incomplete
23
- def __init__(self, default_hyperparameters: dict[str, Any] | None = None) -> None:
24
- """Initializes a new instance of the BaseMultimodalLMInvoker class.
25
-
26
- Args:
27
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the
28
- multimodal language model. Defaults to None, in which case an empty dictionary is used.
29
- """
30
- async def invoke(self, prompt: list[tuple[str, list[InputType]]], hyperparameters: dict[str, Any] | None = None, event_emitter: EventEmitter | None = None) -> OutputType:
31
- """Invokes the multimodal language model with the provided prompt and hyperparameters.
32
-
33
- This method validates the prompt and invokes the multimodal language model with the provided prompt and
34
- hyperparameters. The prompt may contain multimodal inputs that is defined by the type variable `InputType`.
35
- It handles both standard and streaming invocation. Streaming mode is enabled if an event emitter is provided.
36
-
37
- Args:
38
- prompt (list[tuple[str, list[InputType]]]): The input prompt as a list of tuples containing a role-content
39
- list pair. The content list may contain multimodal inputs that is defined by the type variable
40
- `InputType`.
41
- hyperparameters (dict[str, Any] | None, optional): A dictionary of hyperparameters for the multimodal
42
- language model. Defaults to None, in which case the default hyperparameters are used.
43
- event_emitter (EventEmitter | None, optional): The event emitter for streaming tokens. If provided,
44
- streaming invocation is enabled. Defaults to None.
45
-
46
- Returns:
47
- OutputType: The generated response from the multimodal language model.
48
-
49
- Raises:
50
- ValueError: If the prompt is not in the correct format.
51
- """
@@ -1,43 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_core.event import EventEmitter as EventEmitter
3
- from gllm_inference.multimodal_lm_invoker.multimodal_lm_invoker import BaseMultimodalLMInvoker as BaseMultimodalLMInvoker
4
- from gllm_inference.utils import get_mime_type as get_mime_type, is_local_file_path as is_local_file_path, is_remote_file_path as is_remote_file_path
5
- from gllm_inference.utils.openai_multimodal_lm_helper import parse_prompt as parse_prompt, validate_content_type as validate_content_type
6
- from typing import Any
7
-
8
- VALID_EXTENSIONS: Incomplete
9
- DEPRECATION_MESSAGE: str
10
-
11
- class OpenAIMultimodalLMInvoker(BaseMultimodalLMInvoker[str | bytes, str]):
12
- """An invoker to interact with multimodal language models hosted through OpenAI API endpoints.
13
-
14
- The `OpenAIMultimodalLMInvoker` class is designed to interact with multimodal language models hosted through
15
- OpenAI API endpoints. It provides a framework for invoking multimodal language models with the provided prompt and
16
- hyperparameters. It supports both standard and streaming invocation. Streaming mode is enabled if an event emitter
17
- is provided.
18
-
19
- Attributes:
20
- client (AsyncOpenAI): The AsyncOpenAI client instance.
21
- model_name (str): The name of the OpenAI model.
22
- default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the multimodal language model.
23
-
24
- Notes:
25
- The `OpenAIMultimodalLMInvoker` currently supports the following contents:
26
- 1. Text, which can be passed as plain strings.
27
- 2. Image, which can be passed as:
28
- 1. Base64 encoded image bytes.
29
- 2. URL pointing to an image.
30
- 3. Local image file path.
31
- """
32
- client: Incomplete
33
- model_name: Incomplete
34
- def __init__(self, model_name: str, api_key: str, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None) -> None:
35
- """Initializes a new instance of the OpenAIMultimodalLMInvoker class.
36
-
37
- Args:
38
- model_name (str): The name of the OpenAI model.
39
- api_key (str): The API key for authenticating with OpenAI.
40
- model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
41
- default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
42
- Defaults to None.
43
- """
@@ -1,3 +0,0 @@
1
- from gllm_inference.multimodal_prompt_builder.multimodal_prompt_builder import MultimodalPromptBuilder as MultimodalPromptBuilder
2
-
3
- __all__ = ['MultimodalPromptBuilder']
@@ -1,57 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_inference.schema import PromptRole as PromptRole
3
- from gllm_inference.utils import get_prompt_keys as get_prompt_keys, validate_prompt_builder_kwargs as validate_prompt_builder_kwargs
4
- from typing import Any
5
-
6
- DEPRECATION_MESSAGE: str
7
-
8
- class MultimodalPromptBuilder:
9
- """A prompt builder that is compatible with multimodal language models.
10
-
11
- Attributes:
12
- system_template (str): The system prompt template. May contain placeholders enclosed in curly braces `{}`.
13
- user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
14
- prompt_key_set (set[str]): A set of expected keys that must be present in the prompt templates.
15
-
16
- WARNING: This module is deprecated. Please use `gllm_inference.prompt_builder` instead.
17
- This module will be removed in version 0.5.0.
18
- """
19
- system_template: Incomplete
20
- user_template: Incomplete
21
- prompt_key_set: Incomplete
22
- def __init__(self, system_template: str = '', user_template: str = '') -> None:
23
- """Initializes a new instance of the MultimodalPromptBuilder class.
24
-
25
- Args:
26
- system_template (str, optional): The system prompt template. May contain placeholders enclosed in curly
27
- braces `{}`. Defaults to an empty string.
28
- user_template (str, optional): The user prompt template. May contain placeholders enclosed in curly
29
- braces `{}`. Defaults to an empty string.
30
-
31
- Raises:
32
- ValueError: If both `system_template` and `user_template` are empty.
33
- """
34
- def format_as_message_list(self, history: list[tuple[PromptRole, list[Any]]] | None = None, system_multimodal_contents: list[Any] | None = None, user_multimodal_contents: list[Any] | None = None, **kwargs: Any) -> list[tuple[PromptRole, list[Any]]]:
35
- """Formats the prompt templates as a list of message tuples (role, formatted list of contents).
36
-
37
- This method processes each prompt template, replacing the placeholders in the template content with the
38
- corresponding values from `kwargs`. If a required key is missing from `kwargs`, it raises a `ValueError`. It
39
- returns a list of tuples, where each tuple consists of a role and the corresponding formatted list of contents,
40
- which may contain multimodal inputs.
41
-
42
- Args:
43
- history (list[tuple[PromptRole, list[Any]]] | None, optional): The optional chat history to be included in
44
- the prompt. Defaults to None.
45
- system_multimodal_contents (list[Any] | None, optional): The optional multimodal contents for the system
46
- prompt. Defaults to None.
47
- user_multimodal_contents (list[Any] | None, optional): The optional multimodal contents for the user
48
- prompt. Defaults to None.
49
- **kwargs (Any): A dictionary of placeholder values to be injected into the prompt templates.
50
-
51
- Returns:
52
- list[tuple[PromptRole, list[Any]]]: A list of tuples, each containing a role and the corresponding
53
- formatted list of contents, which may contain multimodal inputs.
54
-
55
- Raises:
56
- ValueError: If a required key for the prompt template is missing from `kwargs`.
57
- """
@@ -1,34 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_inference.prompt_builder.prompt_builder import BasePromptBuilder as BasePromptBuilder
3
- from gllm_inference.prompt_formatter import AgnosticPromptFormatter as AgnosticPromptFormatter
4
- from gllm_inference.schema import PromptRole as PromptRole
5
-
6
- DEPRECATION_MESSAGE: str
7
-
8
- class AgnosticPromptBuilder(BasePromptBuilder):
9
- """A prompt builder that is agnostic to specific model types and formats prompts with a customizable separator.
10
-
11
- The `AgnosticPromptBuilder` class constructs a prompt by joining the content of the prompt templates using a
12
- specified separator. It is designed to work independently of specific model types.
13
-
14
- Attributes:
15
- system_template (str): The system prompt template. May contain placeholders enclosed in curly braces `{}`.
16
- user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
17
- prompt_key_set (set[str]): A set of expected keys that must be present in the prompt templates.
18
- ignore_extra_keys (bool): Whether to ignore extra keys when formatting the prompt.
19
- formatter (AgnosticPromptFormatter): The formatter to be used to format the prompt into a string in the
20
- `format_as_string` method.
21
- """
22
- formatter: Incomplete
23
- def __init__(self, system_template: str = '', user_template: str = '', separator: str = '\n', ignore_extra_keys: bool = False) -> None:
24
- '''Initializes a new instance of the AgnosticPromptBuilder class.
25
-
26
- Args:
27
- system_template (str, optional): The system prompt template. May contain placeholders enclosed in curly
28
- braces `{}`. Defaults to an empty string.
29
- user_template (str, optional): The user prompt template. May contain placeholders enclosed in curly
30
- braces `{}`. Defaults to an empty string.
31
- separator (str, optional): A string used to separate each prompt template\'s content. Defaults to "\\n".
32
- ignore_extra_keys (bool, optional): Whether to ignore extra keys when formatting the prompt.
33
- Defaults to False.
34
- '''
@@ -1,44 +0,0 @@
1
- from _typeshed import Incomplete
2
- from gllm_inference.prompt_builder.prompt_builder import BasePromptBuilder as BasePromptBuilder
3
- from gllm_inference.prompt_formatter import HuggingFacePromptFormatter as HuggingFacePromptFormatter
4
- from gllm_inference.schema import PromptRole as PromptRole
5
-
6
- DEPRECATION_MESSAGE: str
7
-
8
- class HuggingFacePromptBuilder(BasePromptBuilder):
9
- """A prompt builder for Hugging Face models that support chat templating.
10
-
11
- The `HuggingFacePromptBuilder` class is designed to create prompts compatible with models hosted in Hugging Face,
12
- given that the model support chat templating. It loads the appropriate tokenizer and formats the prompt by
13
- injecting placeholder values.
14
-
15
- Attributes:
16
- system_template (str): The system prompt template. May contain placeholders enclosed in curly braces `{}`.
17
- user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
18
- prompt_key_set (set[str]): A set of expected keys that must be present in the prompt templates.
19
- ignore_extra_keys (bool): Whether to ignore extra keys when formatting the prompt.
20
- formatter (HuggingFacePromptFormatter): The formatter to be used to format the prompt into a string in the
21
- `format_as_string` method.
22
-
23
- Note:
24
- If you're trying to access the prompt builder template of a gated model, you'd need to:
25
- 1. Request access to the gated repo using your HuggingFace account.
26
- 2. Login to HuggingFace in your system. This can be done as follows:
27
- 2.1. Install huggingface-hub: ```pip install huggingface-hub```
28
- 2.2. Login to HuggingFace: ```huggingface-cli login```
29
- 2.3. Enter your HuggingFace token.
30
- """
31
- formatter: Incomplete
32
- def __init__(self, system_template: str = '', user_template: str = '', model_name_or_path: str = '', ignore_extra_keys: bool = False) -> None:
33
- """Initializes a new instance of the HuggingFacePromptBuilder class.
34
-
35
- Args:
36
- system_template (str, optional): The system prompt template. May contain placeholders enclosed in curly
37
- braces `{}`. Defaults to an empty string.
38
- user_template (str, optional): The user prompt template. May contain placeholders enclosed in curly
39
- braces `{}`. Defaults to an empty string.
40
- model_name_or_path (str, optional): The model name or path of the Hugging Face model tokenizer to be loaded.
41
- Defaults to an empty string.
42
- ignore_extra_keys (bool, optional): Whether to ignore extra keys when formatting the prompt.
43
- Defaults to False.
44
- """