gllm-inference-binary 0.5.5__cp312-cp312-macosx_13_0_x86_64.whl → 0.5.6__cp312-cp312-macosx_13_0_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.

@@ -8,7 +8,7 @@ from typing import Any
8
8
 
9
9
  logger: Incomplete
10
10
 
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 = '', output_parser_type: str = '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:
12
12
  '''Build a language model invoker based on the provided configurations.
13
13
 
14
14
  Args:
@@ -29,6 +29,9 @@ def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[
29
29
  Defaults to an empty string.
30
30
  user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
31
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.
32
35
  output_parser_type (str, optional): The type of output parser to use. Supports "json" and "none".
33
36
  Defaults to "none".
34
37
 
@@ -63,13 +66,14 @@ def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[
63
66
  )
64
67
  ```
65
68
 
66
- # With system template
69
+ # With custom prompt builder configuration
67
70
  ```python
68
71
  lm_request_processor = build_lm_request_processor(
69
72
  model_id="openai/gpt-4o-mini",
70
73
  credentials="sk-...",
71
- system_template="Talk like a pirate.",
74
+ system_template="Talk like a {role}.",
72
75
  user_template="{query}",
76
+ key_defaults={"role": "pirate"},
73
77
  )
74
78
  ```
75
79
 
@@ -6,6 +6,7 @@ from gllm_inference.request_processor import LMRequestProcessor as LMRequestProc
6
6
  MODEL_ID_ENV_VAR_REGEX_PATTERN: str
7
7
  LM_REQUEST_PROCESSOR_REQUIRED_COLUMNS: Incomplete
8
8
  CONFIG_SCHEMA_MAP: Incomplete
9
+ logger: Incomplete
9
10
 
10
11
  class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
11
12
  '''Loads multiple LM request processors from certain sources.
@@ -46,17 +47,24 @@ class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
46
47
 
47
48
  # Example 4: Load from record
48
49
  ```python
49
- catalog = LMRequestProcessorCatalog.from_records(
50
- name="...",
51
- system_template="...",
52
- user_template="...",
53
- model_id="...",
54
- credentials="...",
55
- config="...",
56
- output_parser_type="...",
57
- )
58
-
59
- 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
60
68
  ```
61
69
 
62
70
  Template Format Example:
@@ -66,35 +74,39 @@ class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
66
74
 
67
75
  # Example 2: CSV
68
76
  For an example of how a CSV file can be formatted to be loaded using LMRequestProcessorCatalog, see:
69
- https://drive.google.com/file/d/10nYKn_r9SVnTkaik-caMqUjX6prUZ62M/view?usp=drive_link
77
+ https://drive.google.com/file/d/1_2rSoxh3CR2KZxIyUmpowMrt0Lm0YqAb/view?usp=drive_link
70
78
 
71
79
  Template Explanation:
72
80
  The required columns are:
73
- 1. name (str): The name of the LM request processor.
74
- 2. system_template (str): The system template of the prompt builder.
75
- 3. user_template (str): The user template of the prompt builder.
76
- 4. model_id (str): The model ID of the LM invoker.
77
- 5. credentials (str | json_str): The credentials of the LM invoker.
78
- 6. config (json_str): The additional configuration of the LM invoker.
79
- 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.
80
89
 
81
90
  Important Notes:
82
91
  1. At least one of `system_template` or `user_template` must be filled.
83
- 2. The `model_id`:
84
- 2.1. Must be filled with the model ID of the LM invoker, e.g. "openai/gpt-4.1-nano".
85
- 2.2. Can be partially loaded from the environment variable using the "${ENV_VAR_KEY}" syntax,
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,
86
98
  e.g. "azure-openai/${AZURE_ENDPOINT}/${AZURE_DEPLOYMENT}".
87
- 2.3. For the available model ID formats, see: https://gdplabs.gitbook.io/sdk/resources/supported-models
88
- 3. `credentials` is optional. If it is filled, it can either be:
89
- 3.1. An environment variable name containing the API key (e.g. OPENAI_API_KEY).
90
- 3.2. An environment variable name containing the path to a credentials JSON file
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
91
103
  (e.g. GOOGLE_CREDENTIALS_FILE_PATH). Currently only supported for Google Vertex AI.
92
- 3.3. A dictionary of credentials, with each value being an environment variable name corresponding to the
104
+ 4.3. A dictionary of credentials, with each value being an environment variable name corresponding to the
93
105
  credential (e.g. {"api_key": "OPENAI_API_KEY"}). Currently supported for Bedrock and LangChain.
94
106
  If it is empty, the LM invoker will use the default credentials loaded from the environment variables.
95
- 4. `config` is optional. If filled, must be a dictionary containing the configuration for the LM invoker.
107
+ 5. `config` is optional. If filled, must be a dictionary containing the configuration for the LM invoker.
96
108
  If it is empty, the LM invoker will use the default configuration.
97
- 5. `output_parser_type` can either be:
98
- 5.1. none: No output parser will be used.
99
- 5.2. json: The JSONOutputParser will be used.
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.
100
112
  '''
@@ -3,6 +3,7 @@ from gllm_inference.catalog.catalog import BaseCatalog as BaseCatalog
3
3
  from gllm_inference.prompt_builder.prompt_builder import PromptBuilder as PromptBuilder
4
4
 
5
5
  PROMPT_BUILDER_REQUIRED_COLUMNS: Incomplete
6
+ logger: Incomplete
6
7
 
7
8
  class PromptBuilderCatalog(BaseCatalog[PromptBuilder]):
8
9
  '''Loads multiple prompt builders from certain sources.
@@ -42,22 +43,14 @@ class PromptBuilderCatalog(BaseCatalog[PromptBuilder]):
42
43
  ```python
43
44
  records=[
44
45
  {
45
- "name": "summarize",
46
- "system": "You are an AI expert\\nSummarize the following context.\\n\\nContext:\\n```{context}```",
47
- "user": ""
48
- },
49
- {
50
- "name": "transform_query",
51
- "system": "",
52
- "user": "Transform the following query into a simpler form.\\n\\nQuery:\\n```{query}```"
53
- },
54
- {
55
- "name": "draft_document",
46
+ "name": "answer_question",
56
47
  "system": (
57
- "You are an AI expert.\\nDraft a document following the provided format and context.\\n\\n"
58
- "Format:\\n```{format}```\\n\\nContext:\\n```{context}```"
48
+ "You are helpful assistant.\\n"
49
+ "Answer the following question based on the provided context.\\n"
50
+ "```{context}```"
59
51
  ),
60
- "user": "User instruction:\\n{query}"
52
+ "user": "{query}",
53
+ "key_defaults": \'{"context": "<default context>"}\',
61
54
  },
62
55
  ]
63
56
  catalog = PromptBuilderCatalog.from_records(records=records)
@@ -71,15 +64,19 @@ class PromptBuilderCatalog(BaseCatalog[PromptBuilder]):
71
64
 
72
65
  # Example 2: CSV
73
66
  For an example of how a CSV file can be formatted to be loaded using PromptBuilderCatalog, see:
74
- 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
75
68
 
76
69
 
77
70
  Template explanation:
78
71
  The required columns are:
79
- 1. name (str): The name of the prompt builder.
80
- 2. system (str): The system template of the prompt builder.
81
- 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.
82
76
 
83
77
  Important Notes:
84
- 1. At least one of the `system` and `user` columns must be filled.
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.
85
82
  '''
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gllm-inference-binary
3
- Version: 0.5.5
3
+ Version: 0.5.6
4
4
  Summary: A library containing components related to model inferences in Gen AI applications.
5
5
  Author: Henry Wicaksono
6
6
  Author-email: henry.wicaksono@gdplabs.id
@@ -2,12 +2,12 @@ gllm_inference/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  gllm_inference/builder/__init__.pyi,sha256=usz2lvfwO4Yk-ZGKXbCWG1cEr3nlQXxMNDNC-2yc1NM,500
3
3
  gllm_inference/builder/build_em_invoker.pyi,sha256=YL71GriZEXn4uxmXBJHWC200QdWRPwUJY_G0kKi5-dk,5352
4
4
  gllm_inference/builder/build_lm_invoker.pyi,sha256=aXdNU1gUBUz-4jZ-P791tlkmjOOInLYyeiveEJFlYZo,6468
5
- gllm_inference/builder/build_lm_request_processor.pyi,sha256=Mi0U3zga29FneTzzLeb_R0k4MM--LrNsl7xU4jd_12Y,4094
5
+ gllm_inference/builder/build_lm_request_processor.pyi,sha256=33Gi3onftl-V2e_mkJios5zmXRKSoAVPX3UK7YBExjk,4491
6
6
  gllm_inference/builder/build_output_parser.pyi,sha256=_Lrq-bh1oPsb_Nwkkr_zyEUwIOMysRFZkvEtEM29LZM,936
7
7
  gllm_inference/catalog/__init__.pyi,sha256=JBkPGTyiiZ30GECzJBW-mW8LekWyY2qyzal3eW7ynaM,287
8
8
  gllm_inference/catalog/catalog.pyi,sha256=a4RNG1lKv51GxQpOqh47tz-PAROMPaeP2o5XNLBSZaU,4790
9
- gllm_inference/catalog/lm_request_processor_catalog.pyi,sha256=wjzufPEqey-byBU3hPWwEawT9c182WwjzSWOJ2bnqIs,4599
10
- gllm_inference/catalog/prompt_builder_catalog.pyi,sha256=o4JSzISjlStBataofZ2MB2_t3wnGTkkFJ3Dm_NSm5qo,3159
9
+ gllm_inference/catalog/lm_request_processor_catalog.pyi,sha256=ranHMbG9--DZj9FJRhIUa6U8e-L-Tm-_hSBpzJ6DDs4,5428
10
+ gllm_inference/catalog/prompt_builder_catalog.pyi,sha256=OU8k_4HbqjZEzHZlzSM3uzGQZJmM2uGD76Csqom0CEQ,3197
11
11
  gllm_inference/constants.pyi,sha256=A16iMdS6QLnDx7ToiVuu1rSxvEwcr0OMrghPUGQL0L4,220
12
12
  gllm_inference/em_invoker/__init__.pyi,sha256=XESsrYo1PZeeHe7AMRyuzKoV7XDD5oN89ZTH01zRf4k,873
13
13
  gllm_inference/em_invoker/azure_openai_em_invoker.pyi,sha256=1HgCMcw7Hqv2ah4v9ma1Ioa-PpI-v2g7MfuKxxk2ZPU,4473
@@ -86,8 +86,8 @@ gllm_inference/utils/__init__.pyi,sha256=npmBmmlBv7cPHMg1hdL3S2_RelD6vk_LhCsGELh
86
86
  gllm_inference/utils/langchain.pyi,sha256=VluQiHkGigDdqLUbhB6vnXiISCP5hHqV0qokYY6dC1A,1164
87
87
  gllm_inference/utils/validation.pyi,sha256=toxBtRp-VItC_X7sNi-GDd7sjibBdWMrR0q01OI2D7k,385
88
88
  gllm_inference.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
89
- gllm_inference.cpython-312-darwin.so,sha256=frgNqx_2cIOpFFhMv3UBtO3q1de-Tpn9Xko0y45SSSE,3639760
89
+ gllm_inference.cpython-312-darwin.so,sha256=t64YIwOySSrA0_iq8ttGJaXzXgZjScxONlebC5jXPHk,3656776
90
90
  gllm_inference.pyi,sha256=VEcscbPCJ-6lXU4jV3YYXwwumk9kWxpCAsS84ssKG6o,3295
91
- gllm_inference_binary-0.5.5.dist-info/METADATA,sha256=S9vLvAj1-yAb0qsT4OWsW2J6gHgJxgoIejXF_lRnoEU,4531
92
- gllm_inference_binary-0.5.5.dist-info/WHEEL,sha256=eE2zhpXf8mNi4Sj7Wo77hQIVjvfcPTxg9pdEi0RABeA,107
93
- gllm_inference_binary-0.5.5.dist-info/RECORD,,
91
+ gllm_inference_binary-0.5.6.dist-info/METADATA,sha256=Rzc4b-cVAWQIdy5NxgwiGmWpvvjzKOILPUdeKZEFtQ8,4531
92
+ gllm_inference_binary-0.5.6.dist-info/WHEEL,sha256=eE2zhpXf8mNi4Sj7Wo77hQIVjvfcPTxg9pdEi0RABeA,107
93
+ gllm_inference_binary-0.5.6.dist-info/RECORD,,