gllm-inference-binary 0.4.40__cp312-cp312-manylinux_2_31_x86_64.whl → 0.5.6__cp312-cp312-manylinux_2_31_x86_64.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 (104) hide show
  1. gllm_inference/builder/build_lm_invoker.pyi +2 -1
  2. gllm_inference/builder/build_lm_request_processor.pyi +7 -6
  3. gllm_inference/catalog/catalog.pyi +34 -38
  4. gllm_inference/catalog/lm_request_processor_catalog.pyi +54 -40
  5. gllm_inference/catalog/prompt_builder_catalog.pyi +27 -42
  6. gllm_inference/constants.pyi +1 -3
  7. gllm_inference/em_invoker/__init__.pyi +1 -4
  8. gllm_inference/em_invoker/azure_openai_em_invoker.pyi +1 -1
  9. gllm_inference/em_invoker/em_invoker.pyi +7 -26
  10. gllm_inference/em_invoker/google_em_invoker.pyi +2 -2
  11. gllm_inference/em_invoker/langchain/__init__.pyi +1 -2
  12. gllm_inference/em_invoker/langchain_em_invoker.pyi +3 -13
  13. gllm_inference/em_invoker/openai_compatible_em_invoker.pyi +1 -1
  14. gllm_inference/em_invoker/openai_em_invoker.pyi +2 -2
  15. gllm_inference/em_invoker/twelevelabs_em_invoker.pyi +3 -19
  16. gllm_inference/em_invoker/voyage_em_invoker.pyi +3 -6
  17. gllm_inference/exceptions/exceptions.pyi +38 -18
  18. gllm_inference/lm_invoker/__init__.pyi +1 -4
  19. gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +28 -44
  20. gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +6 -19
  21. gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +13 -17
  22. gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +10 -12
  23. gllm_inference/lm_invoker/google_lm_invoker.pyi +63 -23
  24. gllm_inference/lm_invoker/langchain_lm_invoker.pyi +9 -22
  25. gllm_inference/lm_invoker/litellm_lm_invoker.pyi +52 -13
  26. gllm_inference/lm_invoker/lm_invoker.pyi +18 -19
  27. gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +53 -25
  28. gllm_inference/lm_invoker/openai_lm_invoker.pyi +23 -26
  29. gllm_inference/lm_invoker/schema/anthropic.pyi +1 -1
  30. gllm_inference/lm_invoker/schema/datasaur.pyi +10 -0
  31. gllm_inference/lm_invoker/schema/google.pyi +2 -0
  32. gllm_inference/lm_invoker/schema/openai.pyi +6 -1
  33. gllm_inference/lm_invoker/schema/openai_compatible.pyi +19 -2
  34. gllm_inference/model/__init__.pyi +9 -0
  35. gllm_inference/model/em/__init__.pyi +0 -0
  36. gllm_inference/model/em/google_em.pyi +16 -0
  37. gllm_inference/model/em/openai_em.pyi +15 -0
  38. gllm_inference/model/em/twelvelabs_em.pyi +13 -0
  39. gllm_inference/model/em/voyage_em.pyi +20 -0
  40. gllm_inference/model/lm/__init__.pyi +0 -0
  41. gllm_inference/model/lm/anthropic_lm.pyi +20 -0
  42. gllm_inference/model/lm/google_lm.pyi +17 -0
  43. gllm_inference/model/lm/openai_lm.pyi +27 -0
  44. gllm_inference/prompt_builder/__init__.pyi +1 -6
  45. gllm_inference/prompt_builder/prompt_builder.pyi +17 -107
  46. gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi +4 -4
  47. gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi +4 -4
  48. gllm_inference/prompt_formatter/llama_prompt_formatter.pyi +3 -3
  49. gllm_inference/prompt_formatter/mistral_prompt_formatter.pyi +3 -3
  50. gllm_inference/prompt_formatter/openai_prompt_formatter.pyi +4 -4
  51. gllm_inference/prompt_formatter/prompt_formatter.pyi +4 -4
  52. gllm_inference/request_processor/lm_request_processor.pyi +12 -25
  53. gllm_inference/request_processor/uses_lm_mixin.pyi +4 -10
  54. gllm_inference/schema/__init__.pyi +11 -4
  55. gllm_inference/schema/attachment.pyi +88 -0
  56. gllm_inference/schema/code_exec_result.pyi +14 -0
  57. gllm_inference/schema/enums.pyi +13 -9
  58. gllm_inference/schema/lm_output.pyi +36 -0
  59. gllm_inference/schema/message.pyi +52 -0
  60. gllm_inference/schema/model_id.pyi +1 -1
  61. gllm_inference/schema/reasoning.pyi +15 -0
  62. gllm_inference/schema/token_usage.pyi +11 -0
  63. gllm_inference/schema/tool_call.pyi +14 -0
  64. gllm_inference/schema/tool_result.pyi +11 -0
  65. gllm_inference/schema/type_alias.pyi +6 -8
  66. gllm_inference/utils/__init__.pyi +2 -3
  67. gllm_inference/utils/validation.pyi +12 -0
  68. gllm_inference.cpython-312-x86_64-linux-gnu.so +0 -0
  69. gllm_inference.pyi +14 -45
  70. {gllm_inference_binary-0.4.40.dist-info → gllm_inference_binary-0.5.6.dist-info}/METADATA +5 -11
  71. gllm_inference_binary-0.5.6.dist-info/RECORD +93 -0
  72. gllm_inference/builder/model_id.pyi +0 -13
  73. gllm_inference/catalog/component_map.pyi +0 -8
  74. gllm_inference/em_invoker/google_generativeai_em_invoker.pyi +0 -32
  75. gllm_inference/em_invoker/google_vertexai_em_invoker.pyi +0 -34
  76. gllm_inference/em_invoker/langchain/tei_embeddings.pyi +0 -71
  77. gllm_inference/em_invoker/tei_em_invoker.pyi +0 -48
  78. gllm_inference/lm_invoker/google_generativeai_lm_invoker.pyi +0 -51
  79. gllm_inference/lm_invoker/google_vertexai_lm_invoker.pyi +0 -54
  80. gllm_inference/lm_invoker/tgi_lm_invoker.pyi +0 -34
  81. gllm_inference/multimodal_em_invoker/__init__.pyi +0 -4
  82. gllm_inference/multimodal_em_invoker/google_vertexai_multimodal_em_invoker.pyi +0 -52
  83. gllm_inference/multimodal_em_invoker/multimodal_em_invoker.pyi +0 -35
  84. gllm_inference/multimodal_em_invoker/twelvelabs_multimodal_em_invoker.pyi +0 -49
  85. gllm_inference/multimodal_lm_invoker/__init__.pyi +0 -7
  86. gllm_inference/multimodal_lm_invoker/anthropic_multimodal_lm_invoker.pyi +0 -44
  87. gllm_inference/multimodal_lm_invoker/azure_openai_multimodal_lm_invoker.pyi +0 -41
  88. gllm_inference/multimodal_lm_invoker/google_generativeai_multimodal_lm_invoker.pyi +0 -30
  89. gllm_inference/multimodal_lm_invoker/google_vertexai_multimodal_lm_invoker.pyi +0 -67
  90. gllm_inference/multimodal_lm_invoker/multimodal_lm_invoker.pyi +0 -51
  91. gllm_inference/multimodal_lm_invoker/openai_multimodal_lm_invoker.pyi +0 -43
  92. gllm_inference/multimodal_prompt_builder/__init__.pyi +0 -3
  93. gllm_inference/multimodal_prompt_builder/multimodal_prompt_builder.pyi +0 -57
  94. gllm_inference/prompt_builder/agnostic_prompt_builder.pyi +0 -34
  95. gllm_inference/prompt_builder/huggingface_prompt_builder.pyi +0 -44
  96. gllm_inference/prompt_builder/llama_prompt_builder.pyi +0 -41
  97. gllm_inference/prompt_builder/mistral_prompt_builder.pyi +0 -41
  98. gllm_inference/prompt_builder/openai_prompt_builder.pyi +0 -35
  99. gllm_inference/schema/model_io.pyi +0 -175
  100. gllm_inference/utils/openai_multimodal_lm_helper.pyi +0 -36
  101. gllm_inference/utils/retry.pyi +0 -4
  102. gllm_inference/utils/utils.pyi +0 -142
  103. gllm_inference_binary-0.4.40.dist-info/RECORD +0 -104
  104. {gllm_inference_binary-0.4.40.dist-info → gllm_inference_binary-0.5.6.dist-info}/WHEEL +0 -0
@@ -65,7 +65,8 @@ def build_lm_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
65
65
  },
66
66
  )
67
67
  ```
68
- Providing credentials through environment variable is not supported for Bedrock.
68
+ The credentials can also be provided through the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
69
+ environment variables.
69
70
 
70
71
  # Using Datasaur LLM Projects Deployment API
71
72
  ```python
@@ -1,7 +1,6 @@
1
1
  from _typeshed import Incomplete
2
2
  from gllm_inference.builder.build_lm_invoker import build_lm_invoker as build_lm_invoker
3
3
  from gllm_inference.builder.build_output_parser import build_output_parser as build_output_parser
4
- from gllm_inference.output_parser.output_parser import BaseOutputParser as BaseOutputParser
5
4
  from gllm_inference.prompt_builder import PromptBuilder as PromptBuilder
6
5
  from gllm_inference.request_processor.lm_request_processor import LMRequestProcessor as LMRequestProcessor
7
6
  from gllm_inference.schema.model_id import ModelId as ModelId
@@ -9,7 +8,7 @@ from typing import Any
9
8
 
10
9
  logger: Incomplete
11
10
 
12
- def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[str, Any] | None = None, config: dict[str, Any] | None = None, system_template: str = '', user_template: str = '', output_parser_type: str = 'none', output_parser: BaseOutputParser | None = None) -> LMRequestProcessor:
11
+ def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[str, Any] | None = None, config: dict[str, Any] | None = None, system_template: str = '', user_template: str = '', key_defaults: dict[str, Any] | None = None, output_parser_type: str = 'none') -> LMRequestProcessor:
13
12
  '''Build a language model invoker based on the provided configurations.
14
13
 
15
14
  Args:
@@ -30,10 +29,11 @@ def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[
30
29
  Defaults to an empty string.
31
30
  user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
32
31
  Defaults to an empty string.
32
+ key_defaults (dict[str, str] | None, optional): Default values for the keys in the prompt templates.
33
+ Applied when the corresponding keys are not provided in the runtime input.
34
+ Defaults to None, in which case no default values will be assigned to the keys.
33
35
  output_parser_type (str, optional): The type of output parser to use. Supports "json" and "none".
34
36
  Defaults to "none".
35
- output_parser (BaseOutputParser | None, optional): Deprecated parameter to pass an output parser.
36
- Will be removed in v0.5.0. Defaults to None.
37
37
 
38
38
  Returns:
39
39
  LMRequestProcessor: The initialized language model request processor.
@@ -66,13 +66,14 @@ def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[
66
66
  )
67
67
  ```
68
68
 
69
- # With system template
69
+ # With custom prompt builder configuration
70
70
  ```python
71
71
  lm_request_processor = build_lm_request_processor(
72
72
  model_id="openai/gpt-4o-mini",
73
73
  credentials="sk-...",
74
- system_template="Talk like a pirate.",
74
+ system_template="Talk like a {role}.",
75
75
  user_template="{query}",
76
+ key_defaults={"role": "pirate"},
76
77
  )
77
78
  ```
78
79
 
@@ -13,46 +13,42 @@ class BaseCatalog(ABC, BaseModel, Generic[T], arbitrary_types_allowed=True, meta
13
13
  Attributes:
14
14
  components (dict[str, T]): A dictionary containing the components.
15
15
 
16
- Load from Google Sheets using client email and private key example:
17
- ```python
18
- catalog = BaseCatalog.from_gsheets(
19
- sheet_id="...",
20
- worksheet_id="...",
21
- client_email="...",
22
- private_key="...",
23
- )
24
-
25
- component = catalog.name
26
- ```
27
-
28
- Load from Google Sheets using credential file example:
29
- ```python
30
- catalog = BaseCatalog.from_gsheets(
31
- sheet_id="...",
32
- worksheet_id="...",
33
- credential_file_path="...",
34
- )
35
-
36
- component = catalog.name
37
- ```
38
-
39
- Load from CSV example:
40
- ```python
41
- catalog = BaseCatalog.from_csv(csv_path="...")
42
-
43
- component = catalog.name
44
- ```
45
-
46
- Load from records example:
47
- ```python
48
- catalog = BaseCatalog.from_records(
49
- records=[
16
+ Initialization:
17
+ # Example 1: Load from Google Sheets using client email and private key
18
+ ```python
19
+ catalog = BaseCatalog.from_gsheets(
20
+ sheet_id="...",
21
+ worksheet_id="...",
22
+ client_email="...",
23
+ private_key="...",
24
+ )
25
+ component = catalog.name
26
+ ```
27
+
28
+ # Example 2: Load from Google Sheets using credential file
29
+ ```python
30
+ catalog = BaseCatalog.from_gsheets(
31
+ sheet_id="...",
32
+ worksheet_id="...",
33
+ credential_file_path="...",
34
+ )
35
+ component = catalog.name
36
+ ```
37
+
38
+ # Example 3: Load from CSV
39
+ ```python
40
+ catalog = BaseCatalog.from_csv(csv_path="...")
41
+ component = catalog.name
42
+ ```
43
+
44
+ # Example 4: Load from records
45
+ ```python
46
+ records = [
50
47
  {"name": "...", "col_1": "...", "col_2": "..."},
51
48
  {"name": "...", "col_1": "...", "col_2": "..."},
52
- ],
53
- )
54
-
55
- component = catalog.name
49
+ ]
50
+ catalog = BaseCatalog.from_records(records=records)
51
+ component = catalog.name
56
52
  ```
57
53
  '''
58
54
  components: dict[str, T]
@@ -1,15 +1,12 @@
1
1
  from _typeshed import Incomplete
2
- from gllm_inference.builder import build_lm_request_processor as build_lm_request_processor, build_output_parser as build_output_parser
3
- from gllm_inference.catalog.catalog import BaseCatalog as BaseCatalog, logger as logger
4
- from gllm_inference.catalog.component_map import LM_INVOKER_TYPE_MAP as LM_INVOKER_TYPE_MAP, PROMPT_BUILDER_TYPE_MAP as PROMPT_BUILDER_TYPE_MAP
5
- from gllm_inference.lm_invoker.lm_invoker import BaseLMInvoker as BaseLMInvoker
6
- from gllm_inference.multimodal_lm_invoker.multimodal_lm_invoker import BaseMultimodalLMInvoker as BaseMultimodalLMInvoker
7
- from gllm_inference.multimodal_prompt_builder.multimodal_prompt_builder import MultimodalPromptBuilder as MultimodalPromptBuilder
8
- from gllm_inference.output_parser.output_parser import BaseOutputParser as BaseOutputParser
9
- from gllm_inference.prompt_builder.prompt_builder import BasePromptBuilder as BasePromptBuilder, PromptBuilder as PromptBuilder
2
+ from gllm_inference.builder import build_lm_request_processor as build_lm_request_processor
3
+ from gllm_inference.catalog.catalog import BaseCatalog as BaseCatalog
10
4
  from gllm_inference.request_processor import LMRequestProcessor as LMRequestProcessor
11
5
 
6
+ MODEL_ID_ENV_VAR_REGEX_PATTERN: str
12
7
  LM_REQUEST_PROCESSOR_REQUIRED_COLUMNS: Incomplete
8
+ CONFIG_SCHEMA_MAP: Incomplete
9
+ logger: Incomplete
13
10
 
14
11
  class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
15
12
  '''Loads multiple LM request processors from certain sources.
@@ -50,49 +47,66 @@ class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
50
47
 
51
48
  # Example 4: Load from record
52
49
  ```python
53
- catalog = LMRequestProcessorCatalog.from_records(
54
- name="...",
55
- system_template="...",
56
- user_template="...",
57
- model_id="...",
58
- credentials="...",
59
- config="...",
60
- output_parser_type="...",
61
- )
62
-
63
- lm_request_processor = catalog.name
50
+ records=[
51
+ {
52
+ "name": "answer_question",
53
+ "system_template": (
54
+ "You are helpful assistant.\\n"
55
+ "Answer the following question based on the provided context.\\n"
56
+ "```{context}```"
57
+ ),
58
+ "user_template": "{query}",
59
+ "key_defaults": \'{"context": "<default context>"}\',
60
+ "model_id": "openai/gpt-4.1-nano",
61
+ "credentials": "OPENAI_API_KEY",
62
+ "config": "",
63
+ "output_parser_type": "none",
64
+ },
65
+ ]
66
+ catalog = LMRequestProcessorCatalog.from_records(records=records)
67
+ lm_request_processor = catalog.answer_question
64
68
  ```
65
69
 
66
70
  Template Format Example:
67
71
  # Example 1: Google Sheets
68
- For an example of how a Google Sheets file can be formatted to be loaded using LMRequestProcessorCatalog,
69
- see: https://docs.google.com/spreadsheets/d/1CX9i45yEinv1UdB3s6uHNMj7mxr2-s1NFHfFDvMsq0E/edit?usp=drive_link
72
+ For an example of how a Google Sheets file can be formatted to be loaded using LMRequestProcessorCatalog, see:
73
+ https://docs.google.com/spreadsheets/d/1CX9i45yEinv1UdB3s6uHNMj7mxr2-s1NFHfFDvMsq0E/edit?usp=drive_link
70
74
 
71
75
  # Example 2: CSV
72
76
  For an example of how a CSV file can be formatted to be loaded using LMRequestProcessorCatalog, see:
73
- https://drive.google.com/file/d/11FzAy_7IoKFhHSKVcC1HFMBbWIyWtbcT/view?usp=drive_link
77
+ https://drive.google.com/file/d/1_2rSoxh3CR2KZxIyUmpowMrt0Lm0YqAb/view?usp=drive_link
74
78
 
75
79
  Template Explanation:
76
80
  The required columns are:
77
- 1. name (str): The name of the LM request processor.
78
- 2. system_template (str): The system template of the prompt builder.
79
- 3. user_template (str): The user template of the prompt builder.
80
- 4. model_id (str): The model ID of the LM invoker.
81
- 5. credentials (str | json_str): The credentials of the LM invoker.
82
- 6. config (json_str): The additional configuration of the LM invoker.
83
- 7. output_parser_type (str): The type of the output parser.
81
+ 1. name (str): The name of the LM request processor.
82
+ 2. system_template (str): The system template of the prompt builder.
83
+ 3. user_template (str): The user template of the prompt builder.
84
+ 4. key_defaults (json_str): The default values for the prompt template keys.
85
+ 5. model_id (str): The model ID of the LM invoker.
86
+ 6. credentials (str | json_str): The credentials of the LM invoker.
87
+ 7. config (json_str): The additional configuration of the LM invoker.
88
+ 8. output_parser_type (str): The type of the output parser.
84
89
 
85
90
  Important Notes:
86
91
  1. At least one of `system_template` or `user_template` must be filled.
87
- 2. `model_id` must be filled with the model ID of the LM invoker. For available model IDs, see:
88
- https://gdplabs.gitbook.io/sdk/supported-models
89
- 3. `credentials` is optional. If it is filled, it can either be:
90
- 3.1. An environment variable name containing the API key (e.g. OPENAI_API_KEY).
91
- 3.2. A path to a credentials JSON file, currently only supported for Google Vertex AI.
92
- 3.3. A dictionary of credentials, currently supported for Bedrock and LangChain.
93
- 4. `config` is optional. When this column is empty, the LM invoker will use the
94
- default configuration. If it is filled, it must be a valid JSON string.
95
- 5. `output_parser_type` can either be:
96
- 5.1. none: No output parser will be used.
97
- 5.2. json: The JSONOutputParser will be used.
92
+ 2. `key_defaults` is optional. If filled, must be a dictionary containing the default values for the
93
+ prompt template keys. These default values will be applied when the corresponding keys are not provided
94
+ in the runtime input. If it is empty, the prompt template keys will not have default values.
95
+ 3. The `model_id`:
96
+ 3.1. Must be filled with the model ID of the LM invoker, e.g. "openai/gpt-4.1-nano".
97
+ 3.2. Can be partially loaded from the environment variable using the "${ENV_VAR_KEY}" syntax,
98
+ e.g. "azure-openai/${AZURE_ENDPOINT}/${AZURE_DEPLOYMENT}".
99
+ 3.3. For the available model ID formats, see: https://gdplabs.gitbook.io/sdk/resources/supported-models
100
+ 4. `credentials` is optional. If it is filled, it can either be:
101
+ 4.1. An environment variable name containing the API key (e.g. OPENAI_API_KEY).
102
+ 4.2. An environment variable name containing the path to a credentials JSON file
103
+ (e.g. GOOGLE_CREDENTIALS_FILE_PATH). Currently only supported for Google Vertex AI.
104
+ 4.3. A dictionary of credentials, with each value being an environment variable name corresponding to the
105
+ credential (e.g. {"api_key": "OPENAI_API_KEY"}). Currently supported for Bedrock and LangChain.
106
+ If it is empty, the LM invoker will use the default credentials loaded from the environment variables.
107
+ 5. `config` is optional. If filled, must be a dictionary containing the configuration for the LM invoker.
108
+ If it is empty, the LM invoker will use the default configuration.
109
+ 6. `output_parser_type` can either be:
110
+ 6.1. none: No output parser will be used.
111
+ 6.2. json: The JSONOutputParser will be used.
98
112
  '''
@@ -1,18 +1,15 @@
1
1
  from _typeshed import Incomplete
2
- from gllm_inference.catalog.catalog import BaseCatalog as BaseCatalog, logger as logger
3
- from gllm_inference.catalog.component_map import PROMPT_BUILDER_TYPE_MAP as PROMPT_BUILDER_TYPE_MAP
4
- from gllm_inference.multimodal_prompt_builder import MultimodalPromptBuilder as MultimodalPromptBuilder
5
- from gllm_inference.prompt_builder.prompt_builder import BasePromptBuilder as BasePromptBuilder, PromptBuilder as PromptBuilder
2
+ from gllm_inference.catalog.catalog import BaseCatalog as BaseCatalog
3
+ from gllm_inference.prompt_builder.prompt_builder import PromptBuilder as PromptBuilder
6
4
 
7
- PROMPT_BUILDER_MODEL_PARAM_MAP: Incomplete
8
5
  PROMPT_BUILDER_REQUIRED_COLUMNS: Incomplete
6
+ logger: Incomplete
9
7
 
10
- class PromptBuilderCatalog(BaseCatalog[BasePromptBuilder | MultimodalPromptBuilder | PromptBuilder]):
8
+ class PromptBuilderCatalog(BaseCatalog[PromptBuilder]):
11
9
  '''Loads multiple prompt builders from certain sources.
12
10
 
13
11
  Attributes:
14
- components (dict[str, BasePromptBuilder | MultimodalPromptBuilder | PromptBuilder]):
15
- Dictionary of the loaded prompt builders.
12
+ components (dict[str, PromptBuilder]): Dictionary of the loaded prompt builders.
16
13
 
17
14
  Initialization:
18
15
  # Example 1: Load from Google Sheets using client email and private key
@@ -23,7 +20,6 @@ class PromptBuilderCatalog(BaseCatalog[BasePromptBuilder | MultimodalPromptBuild
23
20
  client_email="...",
24
21
  private_key="...",
25
22
  )
26
-
27
23
  prompt_builder = catalog.name
28
24
  ```
29
25
 
@@ -34,42 +30,30 @@ class PromptBuilderCatalog(BaseCatalog[BasePromptBuilder | MultimodalPromptBuild
34
30
  worksheet_id="...",
35
31
  credential_file_path="...",
36
32
  )
37
-
38
33
  prompt_builder = catalog.name
39
34
  ```
40
35
 
41
36
  # Example 3: Load from CSV
42
37
  ```python
43
38
  catalog = PromptBuilderCatalog.from_csv(csv_path="...")
44
-
45
39
  prompt_builder = catalog.name
46
40
  ```
47
41
 
48
42
  # Example 4: Load from records
49
43
  ```python
50
- catalog = PromptBuilderCatalog.from_records(
51
- records=[
52
- {
53
- "name": "summarize",
54
- "system": "You are an AI expert\\nSummarize the following context.\\n\\nContext:\\n```{context}```",
55
- "user": ""
56
- },
57
- {
58
- "name": "transform_query",
59
- "system": "",
60
- "user": "Transform the following query into a simpler form.\\n\\nQuery:\\n```{query}```"
61
- },
62
- {
63
- "name": "draft_document",
64
- "system": (
65
- "You are an AI expert.\\nDraft a document following the provided format and context.\\n\\n"
66
- "Format:\\n```{format}```\\n\\nContext:\\n```{context}```"
67
- ),
68
- "user": "User instruction:\\n{query}"
69
- },
70
- ]
71
- )
72
-
44
+ records=[
45
+ {
46
+ "name": "answer_question",
47
+ "system": (
48
+ "You are helpful assistant.\\n"
49
+ "Answer the following question based on the provided context.\\n"
50
+ "```{context}```"
51
+ ),
52
+ "user": "{query}",
53
+ "key_defaults": \'{"context": "<default context>"}\',
54
+ },
55
+ ]
56
+ catalog = PromptBuilderCatalog.from_records(records=records)
73
57
  prompt_builder = catalog.answer_question
74
58
  ```
75
59
 
@@ -80,18 +64,19 @@ class PromptBuilderCatalog(BaseCatalog[BasePromptBuilder | MultimodalPromptBuild
80
64
 
81
65
  # Example 2: CSV
82
66
  For an example of how a CSV file can be formatted to be loaded using PromptBuilderCatalog, see:
83
- https://drive.google.com/file/d/1CWijOk-g16ZglUn_K2bDPmbyyBDK2r0L/view?usp=drive_link
67
+ https://drive.google.com/file/d/1KQgddMdbcZBZmroQFtjSl-TKLohq84Fz/view?usp=drive_link
84
68
 
85
69
 
86
70
  Template explanation:
87
71
  The required columns are:
88
- 1. name (str): The name of the prompt builder.
89
- 2. system (str): The system template of the prompt builder.
90
- 3. user (str): The user template of the prompt builder.
72
+ 1. name (str): The name of the prompt builder.
73
+ 2. system (str): The system template of the prompt builder.
74
+ 3. user (str): The user template of the prompt builder.
75
+ 4. key_defaults (json_str): The default values for the prompt template keys.
91
76
 
92
77
  Important Notes:
93
- 1. At least one of the `system` and `user` columns must be filled.
94
-
95
- WARNING: The use of BasePromptBuilder | MultimodalPromptBuilder is deprecated and will be removed in version 0.5.0.
96
- Please use PromptBuilder instead.
78
+ 1. At least one of the `system` and `user` columns must be filled.
79
+ 2. `key_defaults` is optional. If filled, must be a dictionary containing the default values for the
80
+ prompt template keys. These default values will be applied when the corresponding keys are not provided
81
+ in the runtime input. If it is empty, the prompt template keys will not have default values.
97
82
  '''
@@ -1,10 +1,8 @@
1
1
  from _typeshed import Incomplete
2
2
 
3
- ALL_EXTENSIONS: str
4
3
  DEFAULT_AZURE_OPENAI_API_VERSION: str
5
4
  DOCUMENT_MIME_TYPES: Incomplete
6
5
  GOOGLE_SCOPES: Incomplete
6
+ INVOKER_DEFAULT_TIMEOUT: float
7
7
  HEX_REPR_LENGTH: int
8
- MESSAGE_TUPLE_LENGTH: int
9
- DEFAULT_CONTENT_PLACEHOLDER_TYPE: str
10
8
  HTTP_STATUS_CODE_PATTERNS: Incomplete
@@ -1,12 +1,9 @@
1
1
  from gllm_inference.em_invoker.azure_openai_em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker
2
2
  from gllm_inference.em_invoker.google_em_invoker import GoogleEMInvoker as GoogleEMInvoker
3
- from gllm_inference.em_invoker.google_generativeai_em_invoker import GoogleGenerativeAIEMInvoker as GoogleGenerativeAIEMInvoker
4
- from gllm_inference.em_invoker.google_vertexai_em_invoker import GoogleVertexAIEMInvoker as GoogleVertexAIEMInvoker
5
3
  from gllm_inference.em_invoker.langchain_em_invoker import LangChainEMInvoker as LangChainEMInvoker
6
4
  from gllm_inference.em_invoker.openai_compatible_em_invoker import OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker
7
5
  from gllm_inference.em_invoker.openai_em_invoker import OpenAIEMInvoker as OpenAIEMInvoker
8
- from gllm_inference.em_invoker.tei_em_invoker import TEIEMInvoker as TEIEMInvoker
9
6
  from gllm_inference.em_invoker.twelevelabs_em_invoker import TwelveLabsEMInvoker as TwelveLabsEMInvoker
10
7
  from gllm_inference.em_invoker.voyage_em_invoker import VoyageEMInvoker as VoyageEMInvoker
11
8
 
12
- __all__ = ['AzureOpenAIEMInvoker', 'GoogleEMInvoker', 'GoogleGenerativeAIEMInvoker', 'GoogleVertexAIEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TEIEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
9
+ __all__ = ['AzureOpenAIEMInvoker', 'GoogleEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
@@ -81,5 +81,5 @@ class AzureOpenAIEMInvoker(OpenAIEMInvoker):
81
81
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
82
82
  Defaults to None.
83
83
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
84
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
84
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
85
85
  """
@@ -2,14 +2,11 @@ import abc
2
2
  from _typeshed import Incomplete
3
3
  from abc import ABC
4
4
  from gllm_core.utils.retry import RetryConfig
5
- from gllm_inference.constants import ALL_EXTENSIONS as ALL_EXTENSIONS, DOCUMENT_MIME_TYPES as DOCUMENT_MIME_TYPES
5
+ from gllm_inference.constants import DOCUMENT_MIME_TYPES as DOCUMENT_MIME_TYPES, INVOKER_DEFAULT_TIMEOUT as INVOKER_DEFAULT_TIMEOUT
6
6
  from gllm_inference.exceptions import parse_error_message as parse_error_message
7
7
  from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, EMContent as EMContent, ModelId as ModelId, Vector as Vector
8
- from langchain_core.embeddings import Embeddings as Embeddings
9
8
  from typing import Any
10
9
 
11
- DEPRECATED_DETAILS: str
12
-
13
10
  class BaseEMInvoker(ABC, metaclass=abc.ABCMeta):
14
11
  """A base class for embedding model invokers used in Gen AI applications.
15
12
 
@@ -24,22 +21,18 @@ class BaseEMInvoker(ABC, metaclass=abc.ABCMeta):
24
21
  """
25
22
  default_hyperparameters: Incomplete
26
23
  retry_config: Incomplete
27
- def __init__(self, model_id: ModelId, default_hyperparameters: dict[str, Any] | None = None, valid_extensions_map: dict[str, set[str]] | None = None, retry_config: RetryConfig | None = None, langchain_kwargs: dict[str, Any] | None = None) -> None:
28
- '''Initializes a new instance of the BaseEMInvoker class.
24
+ def __init__(self, model_id: ModelId, default_hyperparameters: dict[str, Any] | None = None, supported_attachments: set[str] | None = None, retry_config: RetryConfig | None = None) -> None:
25
+ """Initializes a new instance of the BaseEMInvoker class.
29
26
 
30
27
  Args:
31
28
  model_id (ModelId): The model ID of the embedding model.
32
29
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the
33
30
  embedding model. Defaults to None, in which case an empty dictionary is used.
34
- valid_extensions_map (dict[str, set[str]] | None, optional): A dictionary mapping for validating the
35
- content type of the multimodal inputs. They keys are the mime types (e.g. "image") and the values are
36
- the set of valid file extensions for the corresponding mime type. Defaults to None, in which case an
37
- empty dictionary is used.
31
+ supported_attachments (set[str] | None, optional): A set of supported attachment types. Defaults to None,
32
+ in which case an empty set is used (indicating that no attachments are supported).
38
33
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
39
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
40
- langchain_kwargs (dict[str, Any] | None, optional): Additional keyword arguments to initiate the LangChain
41
- embedding model. Defaults to None.
42
- '''
34
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
35
+ """
43
36
  @property
44
37
  def model_id(self) -> str:
45
38
  """The model ID of the embedding model.
@@ -88,15 +81,3 @@ class BaseEMInvoker(ABC, metaclass=abc.ABCMeta):
88
81
  TimeoutError: If the invocation times out.
89
82
  ValueError: If the input content is invalid.
90
83
  """
91
- def to_langchain(self) -> Embeddings:
92
- """Converts the current embedding model invoker to an instance of LangChain `Embeddings` object.
93
-
94
- This method converts the EM invoker to an instance of LangChain's `Embeddings` object.
95
- This method requires the appropriate `langchain-<provider>` package to be installed.
96
-
97
- Returns:
98
- Embeddings: An instance of LangChain `Embeddings` object.
99
-
100
- Raises:
101
- ValueError: If `langchain_module_name` or `langchain_class_name` is missing.
102
- """
@@ -5,7 +5,7 @@ from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
5
5
  from gllm_inference.schema import ModelId as ModelId, ModelProvider as ModelProvider, Vector as Vector
6
6
  from typing import Any
7
7
 
8
- VALID_EXTENSIONS_MAP: Incomplete
8
+ SUPPORTED_ATTACHMENTS: Incomplete
9
9
 
10
10
  class GoogleEMInvoker(BaseEMInvoker):
11
11
  '''An embedding model invoker to interact with Google embedding models.
@@ -115,7 +115,7 @@ class GoogleEMInvoker(BaseEMInvoker):
115
115
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
116
116
  Defaults to None.
117
117
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
118
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
118
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
119
119
 
120
120
  Note:
121
121
  If neither `api_key` nor `credentials_path` is provided, Google Gen AI will be used by default.
@@ -1,4 +1,3 @@
1
1
  from gllm_inference.em_invoker.langchain.em_invoker_embeddings import EMInvokerEmbeddings as EMInvokerEmbeddings
2
- from gllm_inference.em_invoker.langchain.tei_embeddings import TEIEmbeddings as TEIEmbeddings
3
2
 
4
- __all__ = ['EMInvokerEmbeddings', 'TEIEmbeddings']
3
+ __all__ = ['EMInvokerEmbeddings']
@@ -6,7 +6,7 @@ from gllm_inference.utils import load_langchain_model as load_langchain_model, p
6
6
  from langchain_core.embeddings import Embeddings as Embeddings
7
7
  from typing import Any
8
8
 
9
- VALID_EXTENSIONS_MAP: Incomplete
9
+ SUPPORTED_ATTACHMENTS: Incomplete
10
10
 
11
11
  class LangChainEMInvoker(BaseEMInvoker):
12
12
  """A language model invoker to interact with LangChain's Embeddings.
@@ -19,7 +19,7 @@ class LangChainEMInvoker(BaseEMInvoker):
19
19
  retry_config (RetryConfig): The retry configuration for the embedding model.
20
20
  """
21
21
  model: Incomplete
22
- def __init__(self, model: Embeddings | None = None, model_class_path: str | None = None, model_name: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, em: Embeddings | None = None) -> None:
22
+ def __init__(self, model: Embeddings | None = None, model_class_path: str | None = None, model_name: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None) -> None:
23
23
  '''Initializes a new instance of the LangChainEMInvoker class.
24
24
 
25
25
  Args:
@@ -35,15 +35,5 @@ class LangChainEMInvoker(BaseEMInvoker):
35
35
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
36
36
  Defaults to None.
37
37
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
38
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
39
- em (Embeddings | None, optional): Deprecated parameter to pass the LangChain\'s Embeddings instance.
40
- Equivalent to the `model` parameter. Retained for backward compatibility. Defaults to None.
38
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
41
39
  '''
42
- def to_langchain(self) -> Embeddings:
43
- """Converts the current embedding model invoker to an instance of LangChain `Embeddings` object.
44
-
45
- This method converts the EM invoker to an instance of LangChain's `Embeddings` object.
46
-
47
- Returns:
48
- Embeddings: An instance of LangChain `Embeddings` object.
49
- """
@@ -86,5 +86,5 @@ class OpenAICompatibleEMInvoker(OpenAIEMInvoker):
86
86
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
87
87
  Defaults to None.
88
88
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
89
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
89
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
90
90
  """
@@ -4,7 +4,7 @@ from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
4
4
  from gllm_inference.schema import ModelId as ModelId, ModelProvider as ModelProvider, Vector as Vector
5
5
  from typing import Any
6
6
 
7
- VALID_EXTENSIONS_MAP: Incomplete
7
+ SUPPORTED_ATTACHMENTS: Incomplete
8
8
 
9
9
  class OpenAIEMInvoker(BaseEMInvoker):
10
10
  '''An embedding model invoker to interact with OpenAI embedding models.
@@ -80,5 +80,5 @@ class OpenAIEMInvoker(BaseEMInvoker):
80
80
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
81
81
  Defaults to None.
82
82
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
83
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
83
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
84
84
  """
@@ -3,10 +3,9 @@ from gllm_core.utils.retry import RetryConfig as RetryConfig
3
3
  from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
4
4
  from gllm_inference.em_invoker.schema.twelvelabs import InputType as InputType, Key as Key, OutputType as OutputType
5
5
  from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, EMContent as EMContent, ModelId as ModelId, ModelProvider as ModelProvider, Vector as Vector
6
- from langchain_core.embeddings import Embeddings as Embeddings
7
6
  from typing import Any
8
7
 
9
- VALID_EXTENSIONS_MAP: Incomplete
8
+ SUPPORTED_ATTACHMENTS: Incomplete
10
9
 
11
10
  class TwelveLabsEMInvoker(BaseEMInvoker):
12
11
  '''An embedding model invoker to interact with TwelveLabs embedding models.
@@ -20,10 +19,7 @@ class TwelveLabsEMInvoker(BaseEMInvoker):
20
19
  retry_config (RetryConfig): The retry configuration for the embedding model.
21
20
 
22
21
  Input types:
23
- The `TwelveLabsEMInvoker` supports the following input types:
24
- 1. Text.
25
- 2. Audio: ".mp3", ".wav", and ".flac".
26
- 3. Image: ".png", ".jpeg", and ".jpg".
22
+ The `TwelveLabsEMInvoker` supports the following input types: text, audio, and image.
27
23
  Non-text inputs must be passed as a `Attachment` object.
28
24
 
29
25
  Output format:
@@ -98,17 +94,5 @@ class TwelveLabsEMInvoker(BaseEMInvoker):
98
94
  default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
99
95
  Defaults to None.
100
96
  retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
101
- Defaults to None, in which case a default config with no retry and 30.0 seconds timeout is used.
102
- """
103
- def to_langchain(self) -> Embeddings:
104
- """Converts the current embedding model invoker to an instance of LangChain `Embeddings` object.
105
-
106
- This method converts the EM invoker to an instance of LangChain's `Embeddings` object.
107
- However, the TwelveLabsEMInvoker is not supported by LangChain.
108
-
109
- Returns:
110
- Embeddings: An instance of LangChain `Embeddings` object.
111
-
112
- Raises:
113
- NotImplementedError: The TwelveLabsEMInvoker is not supported by LangChain.
97
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
114
98
  """