gllm-inference-binary 0.5.4__cp313-cp313-macosx_13_0_x86_64.whl → 0.5.6__cp313-cp313-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.
- gllm_inference/builder/build_lm_request_processor.pyi +7 -3
- gllm_inference/catalog/lm_request_processor_catalog.pyi +43 -31
- gllm_inference/catalog/prompt_builder_catalog.pyi +16 -19
- gllm_inference/prompt_builder/prompt_builder.pyi +8 -5
- gllm_inference.cpython-313-darwin.so +0 -0
- {gllm_inference_binary-0.5.4.dist-info → gllm_inference_binary-0.5.6.dist-info}/METADATA +1 -1
- {gllm_inference_binary-0.5.4.dist-info → gllm_inference_binary-0.5.6.dist-info}/RECORD +8 -8
- {gllm_inference_binary-0.5.4.dist-info → gllm_inference_binary-0.5.6.dist-info}/WHEEL +0 -0
|
@@ -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
|
|
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
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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/
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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.
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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": "
|
|
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
|
|
58
|
-
"
|
|
48
|
+
"You are helpful assistant.\\n"
|
|
49
|
+
"Answer the following question based on the provided context.\\n"
|
|
50
|
+
"```{context}```"
|
|
59
51
|
),
|
|
60
|
-
"user": "
|
|
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/
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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
|
'''
|
|
@@ -11,13 +11,13 @@ class PromptBuilder:
|
|
|
11
11
|
system_template (str): The system prompt template. May contain placeholders enclosed in curly braces `{}`.
|
|
12
12
|
user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
|
|
13
13
|
prompt_key_set (set[str]): A set of expected keys that must be present in the prompt templates.
|
|
14
|
-
|
|
14
|
+
key_defaults (dict[str, str]): Default values for the keys in the prompt templates.
|
|
15
15
|
"""
|
|
16
16
|
system_template: Incomplete
|
|
17
17
|
user_template: Incomplete
|
|
18
18
|
prompt_key_set: Incomplete
|
|
19
|
-
|
|
20
|
-
def __init__(self, system_template: str = '', user_template: str = '', ignore_extra_keys: bool =
|
|
19
|
+
key_defaults: Incomplete
|
|
20
|
+
def __init__(self, system_template: str = '', user_template: str = '', key_defaults: dict[str, str] | None = None, ignore_extra_keys: bool | None = None) -> None:
|
|
21
21
|
"""Initializes a new instance of the PromptBuilder class.
|
|
22
22
|
|
|
23
23
|
Args:
|
|
@@ -25,8 +25,11 @@ class PromptBuilder:
|
|
|
25
25
|
braces `{}`. Defaults to an empty string.
|
|
26
26
|
user_template (str, optional): The user prompt template. May contain placeholders enclosed in curly
|
|
27
27
|
braces `{}`. Defaults to an empty string.
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
key_defaults (dict[str, str] | None, optional): Default values for the keys in the prompt templates.
|
|
29
|
+
Applied when the corresponding keys are not provided in the runtime input.
|
|
30
|
+
Defaults to None, in which case no default values will be assigned to the keys.
|
|
31
|
+
ignore_extra_keys (bool | None, optional): Deprecated parameter. Will be removed in v0.6. Extra keys
|
|
32
|
+
will always raise a warning only instead of raising an error.
|
|
30
33
|
|
|
31
34
|
Raises:
|
|
32
35
|
ValueError: If both `system_template` and `user_template` are empty.
|
|
Binary file
|
|
@@ -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=
|
|
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=
|
|
10
|
-
gllm_inference/catalog/prompt_builder_catalog.pyi,sha256=
|
|
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
|
|
@@ -59,7 +59,7 @@ gllm_inference/output_parser/__init__.pyi,sha256=WQOOgsYnPk8vd-SOhFMMaVTzy4gkYrO
|
|
|
59
59
|
gllm_inference/output_parser/json_output_parser.pyi,sha256=uulh91uQLMSb4ZXZhHYi9W9w7zGnmrOweEkL6wdDJN8,2933
|
|
60
60
|
gllm_inference/output_parser/output_parser.pyi,sha256=Yzk7F26pH8Uc7FQZo4G6l67YkfppefUvaV9cNK-HyDs,948
|
|
61
61
|
gllm_inference/prompt_builder/__init__.pyi,sha256=kshfBMvwIwiIvjxiGG5BrJZNvpPa8rhtkbHo5FPifBg,117
|
|
62
|
-
gllm_inference/prompt_builder/prompt_builder.pyi,sha256=
|
|
62
|
+
gllm_inference/prompt_builder/prompt_builder.pyi,sha256=zDKN0JWn23DPM73sCe-qpXT4d32Izis94K5aNpzLaoM,3278
|
|
63
63
|
gllm_inference/prompt_formatter/__init__.pyi,sha256=rTsjfRsT-y00qH67fPewMNPMN1fAO2y7DM9scR1ccm0,740
|
|
64
64
|
gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi,sha256=c9mN4t8LXn79h8wq8DAeWYwMgmZGzXjP7EcjLpwfNZg,2018
|
|
65
65
|
gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi,sha256=AJ-D11HBhTKBA1B5s0km_K1R6o5HD1yvdbGoL7SpGhI,2729
|
|
@@ -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-313-darwin.so,sha256=
|
|
89
|
+
gllm_inference.cpython-313-darwin.so,sha256=vImQcO4lfcG6qH3qZVuYMk_8Mygci1j_R6Kc6qtuCec,3689152
|
|
90
90
|
gllm_inference.pyi,sha256=xOoh8lTQxXc6A4XYKBobWn8RJNszAlinAmbHPJyqi30,3315
|
|
91
|
-
gllm_inference_binary-0.5.
|
|
92
|
-
gllm_inference_binary-0.5.
|
|
93
|
-
gllm_inference_binary-0.5.
|
|
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=PCOZcL_jcbAVhuFR5ylE4Mr-7HPGHAcfJk9OpuMh7RQ,107
|
|
93
|
+
gllm_inference_binary-0.5.6.dist-info/RECORD,,
|
|
File without changes
|