gllm-inference-binary 0.5.33__cp312-cp312-macosx_13_0_x86_64.whl → 0.5.35__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.
- gllm_inference/builder/build_em_invoker.pyi +10 -13
- gllm_inference/builder/build_lm_invoker.pyi +30 -17
- gllm_inference/builder/build_lm_request_processor.pyi +2 -7
- gllm_inference/catalog/lm_request_processor_catalog.pyi +2 -2
- gllm_inference/constants.pyi +1 -0
- gllm_inference/em_invoker/openai_compatible_em_invoker.pyi +5 -60
- gllm_inference/em_invoker/openai_em_invoker.pyi +34 -6
- gllm_inference/lm_invoker/__init__.pyi +2 -1
- gllm_inference/lm_invoker/langchain_lm_invoker.pyi +3 -3
- gllm_inference/lm_invoker/litellm_lm_invoker.pyi +1 -1
- gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +278 -0
- gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +9 -226
- gllm_inference/lm_invoker/openai_lm_invoker.pyi +30 -6
- gllm_inference/lm_invoker/schema/{openai_compatible.pyi → openai_chat_completions.pyi} +2 -2
- gllm_inference/schema/__init__.pyi +3 -1
- gllm_inference/schema/activity.pyi +9 -0
- gllm_inference/schema/events.pyi +40 -0
- gllm_inference/schema/model_id.pyi +30 -25
- gllm_inference.cpython-312-darwin.so +0 -0
- gllm_inference.pyi +1 -0
- {gllm_inference_binary-0.5.33.dist-info → gllm_inference_binary-0.5.35.dist-info}/METADATA +35 -15
- {gllm_inference_binary-0.5.33.dist-info → gllm_inference_binary-0.5.35.dist-info}/RECORD +24 -21
- {gllm_inference_binary-0.5.33.dist-info → gllm_inference_binary-0.5.35.dist-info}/WHEEL +0 -0
- {gllm_inference_binary-0.5.33.dist-info → gllm_inference_binary-0.5.35.dist-info}/top_level.txt +0 -0
|
@@ -24,11 +24,8 @@ def build_em_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
24
24
|
'''Build an embedding model invoker based on the provided configurations.
|
|
25
25
|
|
|
26
26
|
Args:
|
|
27
|
-
model_id (str | ModelId): The model id, can either be a ModelId instance or a string in
|
|
28
|
-
|
|
29
|
-
2. For `openai-compatible` provider: `openai-compatible/base-url:model-name`.
|
|
30
|
-
3. For `langchain` provider: `langchain/<package>.<class>:model-name`.
|
|
31
|
-
4. For other providers: `provider/model-name`.
|
|
27
|
+
model_id (str | ModelId): The model id, can either be a ModelId instance or a string in a format defined
|
|
28
|
+
in the following page: https://gdplabs.gitbook.io/sdk/resources/supported-models#embedding-models-ems
|
|
32
29
|
credentials (str | dict[str, Any] | None, optional): The credentials for the language model. Can either be:
|
|
33
30
|
1. An API key.
|
|
34
31
|
2. A path to a credentials JSON file, currently only supported for Google Vertex AI.
|
|
@@ -83,23 +80,23 @@ def build_em_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
83
80
|
```
|
|
84
81
|
The credentials can also be provided through the `OPENAI_API_KEY` environment variable.
|
|
85
82
|
|
|
86
|
-
# Using
|
|
83
|
+
# Using OpenAI Embeddings API-compatible endpoints (e.g. vLLM)
|
|
87
84
|
```python
|
|
88
85
|
em_invoker = build_em_invoker(
|
|
89
|
-
model_id="
|
|
90
|
-
credentials="
|
|
86
|
+
model_id="openai/https://my-vllm-url:8000/v1:my-model-name",
|
|
87
|
+
credentials="sk-..."
|
|
91
88
|
)
|
|
92
89
|
```
|
|
93
|
-
The credentials can also be provided through the `
|
|
90
|
+
The credentials can also be provided through the `OPENAI_API_KEY` environment variable.
|
|
94
91
|
|
|
95
|
-
# Using OpenAI
|
|
92
|
+
# Using Azure OpenAI
|
|
96
93
|
```python
|
|
97
94
|
em_invoker = build_em_invoker(
|
|
98
|
-
model_id="openai
|
|
99
|
-
credentials="
|
|
95
|
+
model_id="azure-openai/https://my-resource.openai.azure.com/openai/v1:my-deployment",
|
|
96
|
+
credentials="azure-api-key"
|
|
100
97
|
)
|
|
101
98
|
```
|
|
102
|
-
The credentials can also be provided through the `
|
|
99
|
+
The credentials can also be provided through the `AZURE_OPENAI_API_KEY` environment variable.
|
|
103
100
|
|
|
104
101
|
# Using TwelveLabs
|
|
105
102
|
```python
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from gllm_inference.lm_invoker import AnthropicLMInvoker as AnthropicLMInvoker, AzureOpenAILMInvoker as AzureOpenAILMInvoker, BedrockLMInvoker as BedrockLMInvoker, DatasaurLMInvoker as DatasaurLMInvoker, GoogleLMInvoker as GoogleLMInvoker, LangChainLMInvoker as LangChainLMInvoker, LiteLLMLMInvoker as LiteLLMLMInvoker, OpenAICompatibleLMInvoker as OpenAICompatibleLMInvoker, OpenAILMInvoker as OpenAILMInvoker, XAILMInvoker as XAILMInvoker
|
|
2
|
+
from gllm_inference.lm_invoker import AnthropicLMInvoker as AnthropicLMInvoker, AzureOpenAILMInvoker as AzureOpenAILMInvoker, BedrockLMInvoker as BedrockLMInvoker, DatasaurLMInvoker as DatasaurLMInvoker, GoogleLMInvoker as GoogleLMInvoker, LangChainLMInvoker as LangChainLMInvoker, LiteLLMLMInvoker as LiteLLMLMInvoker, OpenAIChatCompletionsLMInvoker as OpenAIChatCompletionsLMInvoker, OpenAICompatibleLMInvoker as OpenAICompatibleLMInvoker, OpenAILMInvoker as OpenAILMInvoker, XAILMInvoker as XAILMInvoker
|
|
3
3
|
from gllm_inference.lm_invoker.lm_invoker import BaseLMInvoker as BaseLMInvoker
|
|
4
4
|
from gllm_inference.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider
|
|
5
5
|
from typing import Any
|
|
@@ -25,13 +25,8 @@ def build_lm_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
25
25
|
'''Build a language model invoker based on the provided configurations.
|
|
26
26
|
|
|
27
27
|
Args:
|
|
28
|
-
model_id (str | ModelId): The model id, can either be a ModelId instance or a string in
|
|
29
|
-
|
|
30
|
-
2. For `openai-compatible` provider: `openai-compatible/base-url:model-name`.
|
|
31
|
-
3. For `langchain` provider: `langchain/<package>.<class>:model-name`.
|
|
32
|
-
4. For `litellm` provider: `litellm/provider/model-name`.
|
|
33
|
-
5. For `datasaur` provider: `datasaur/deployment-id:model-name`.
|
|
34
|
-
6. For other providers: `provider/model-name`.
|
|
28
|
+
model_id (str | ModelId): The model id, can either be a ModelId instance or a string in a format defined
|
|
29
|
+
in the following page: https://gdplabs.gitbook.io/sdk/resources/supported-models#language-models-lms
|
|
35
30
|
credentials (str | dict[str, Any] | None, optional): The credentials for the language model. Can either be:
|
|
36
31
|
1. An API key.
|
|
37
32
|
2. A path to a credentials JSON file, currently only supported for Google Vertex AI.
|
|
@@ -80,7 +75,7 @@ def build_lm_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
80
75
|
# Using Google Gen AI (via API key)
|
|
81
76
|
```python
|
|
82
77
|
lm_invoker = build_lm_invoker(
|
|
83
|
-
model_id="google/gemini-
|
|
78
|
+
model_id="google/gemini-2.5-flash-lite",
|
|
84
79
|
credentials="AIzaSyD..."
|
|
85
80
|
)
|
|
86
81
|
```
|
|
@@ -89,7 +84,7 @@ def build_lm_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
89
84
|
# Using Google Vertex AI (via service account)
|
|
90
85
|
```python
|
|
91
86
|
lm_invoker = build_lm_invoker(
|
|
92
|
-
model_id="google/gemini-
|
|
87
|
+
model_id="google/gemini-2.5-flash-lite",
|
|
93
88
|
credentials="/path/to/google-credentials.json"
|
|
94
89
|
)
|
|
95
90
|
```
|
|
@@ -98,30 +93,48 @@ def build_lm_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
98
93
|
# Using OpenAI
|
|
99
94
|
```python
|
|
100
95
|
lm_invoker = build_lm_invoker(
|
|
101
|
-
model_id="openai/gpt-
|
|
96
|
+
model_id="openai/gpt-5-nano",
|
|
102
97
|
credentials="sk-..."
|
|
103
98
|
)
|
|
104
99
|
```
|
|
105
100
|
The credentials can also be provided through the `OPENAI_API_KEY` environment variable.
|
|
106
101
|
|
|
107
|
-
# Using
|
|
102
|
+
# Using OpenAI with Chat Completions API
|
|
108
103
|
```python
|
|
109
104
|
lm_invoker = build_lm_invoker(
|
|
110
|
-
model_id="
|
|
111
|
-
credentials="
|
|
105
|
+
model_id="openai-chat-completions/gpt-5-nano",
|
|
106
|
+
credentials="sk-..."
|
|
112
107
|
)
|
|
113
108
|
```
|
|
114
|
-
The credentials can also be provided through the `
|
|
109
|
+
The credentials can also be provided through the `OPENAI_API_KEY` environment variable.
|
|
110
|
+
|
|
111
|
+
# Using OpenAI Responses API-compatible endpoints (e.g. SGLang)
|
|
112
|
+
```python
|
|
113
|
+
lm_invoker = build_lm_invoker(
|
|
114
|
+
model_id="openai/https://my-sglang-url:8000/v1:my-model-name",
|
|
115
|
+
credentials="sk-..."
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
The credentials can also be provided through the `OPENAI_API_KEY` environment variable.
|
|
115
119
|
|
|
116
|
-
# Using OpenAI
|
|
120
|
+
# Using OpenAI Chat Completions API-compatible endpoints (e.g. Groq)
|
|
117
121
|
```python
|
|
118
122
|
lm_invoker = build_lm_invoker(
|
|
119
|
-
model_id="openai-
|
|
123
|
+
model_id="openai-chat-completions/https://api.groq.com/openai/v1:llama3-8b-8192",
|
|
120
124
|
credentials="gsk_..."
|
|
121
125
|
)
|
|
122
126
|
```
|
|
123
127
|
The credentials can also be provided through the `OPENAI_API_KEY` environment variable.
|
|
124
128
|
|
|
129
|
+
# Using Azure OpenAI
|
|
130
|
+
```python
|
|
131
|
+
lm_invoker = build_lm_invoker(
|
|
132
|
+
model_id="azure-openai/https://my-resource.openai.azure.com/openai/v1:my-deployment",
|
|
133
|
+
credentials="azure-api-key"
|
|
134
|
+
)
|
|
135
|
+
```
|
|
136
|
+
The credentials can also be provided through the `AZURE_OPENAI_API_KEY` environment variable.
|
|
137
|
+
|
|
125
138
|
# Using LangChain
|
|
126
139
|
```python
|
|
127
140
|
lm_invoker = build_lm_invoker(
|
|
@@ -12,13 +12,8 @@ def build_lm_request_processor(model_id: str | ModelId, credentials: str | dict[
|
|
|
12
12
|
'''Build a language model invoker based on the provided configurations.
|
|
13
13
|
|
|
14
14
|
Args:
|
|
15
|
-
model_id (str | ModelId): The model id, can either be a ModelId instance or a string in
|
|
16
|
-
|
|
17
|
-
2. For `openai-compatible` provider: `openai-compatible/base-url:model-name`.
|
|
18
|
-
3. For `langchain` provider: `langchain/<package>.<class>:model-name`.
|
|
19
|
-
4. For `litellm` provider: `litellm/provider/model-name`.
|
|
20
|
-
5. For `datasaur` provider: `datasaur/base-url`.
|
|
21
|
-
6. For other providers: `provider/model-name`.
|
|
15
|
+
model_id (str | ModelId): The model id, can either be a ModelId instance or a string in a format defined
|
|
16
|
+
in the following page: https://gdplabs.gitbook.io/sdk/resources/supported-models#language-models-lms
|
|
22
17
|
credentials (str | dict[str, Any] | None, optional): The credentials for the language model. Can either be:
|
|
23
18
|
1. An API key.
|
|
24
19
|
2. A path to a credentials JSON file, currently only supported for Google Vertex AI.
|
|
@@ -57,7 +57,7 @@ class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
|
|
|
57
57
|
),
|
|
58
58
|
"user_template": "{query}",
|
|
59
59
|
"key_defaults": \'{"context": "<default context>"}\',
|
|
60
|
-
"model_id": "openai/gpt-
|
|
60
|
+
"model_id": "openai/gpt-5-nano",
|
|
61
61
|
"credentials": "OPENAI_API_KEY",
|
|
62
62
|
"config": "",
|
|
63
63
|
"output_parser_type": "none",
|
|
@@ -93,7 +93,7 @@ class LMRequestProcessorCatalog(BaseCatalog[LMRequestProcessor]):
|
|
|
93
93
|
prompt template keys. These default values will be applied when the corresponding keys are not provided
|
|
94
94
|
in the runtime input. If it is empty, the prompt template keys will not have default values.
|
|
95
95
|
3. The `model_id`:
|
|
96
|
-
3.1. Must be filled with the model ID of the LM invoker, e.g. "openai/gpt-
|
|
96
|
+
3.1. Must be filled with the model ID of the LM invoker, e.g. "openai/gpt-5-nano".
|
|
97
97
|
3.2. Can be partially loaded from the environment variable using the "${ENV_VAR_KEY}" syntax,
|
|
98
98
|
e.g. "azure-openai/${AZURE_ENDPOINT}/${AZURE_DEPLOYMENT}".
|
|
99
99
|
3.3. For the available model ID formats, see: https://gdplabs.gitbook.io/sdk/resources/supported-models
|
gllm_inference/constants.pyi
CHANGED
|
@@ -6,8 +6,10 @@ from gllm_inference.em_invoker.schema.openai_compatible import Key as Key
|
|
|
6
6
|
from gllm_inference.schema import ModelId as ModelId, ModelProvider as ModelProvider, TruncationConfig as TruncationConfig
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
+
DEPRECATION_MESSAGE: str
|
|
10
|
+
|
|
9
11
|
class OpenAICompatibleEMInvoker(OpenAIEMInvoker):
|
|
10
|
-
|
|
12
|
+
"""An embedding model invoker to interact with endpoints compatible with OpenAI's embedding API contract.
|
|
11
13
|
|
|
12
14
|
Attributes:
|
|
13
15
|
model_id (str): The model ID of the embedding model.
|
|
@@ -18,65 +20,8 @@ class OpenAICompatibleEMInvoker(OpenAIEMInvoker):
|
|
|
18
20
|
retry_config (RetryConfig): The retry configuration for the embedding model.
|
|
19
21
|
truncation_config (TruncationConfig | None): The truncation configuration for the embedding model.
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
The `OpenAICompatibleEMInvoker` is designed to interact with endpoints that are compatible with OpenAI\'s
|
|
24
|
-
embedding API contract. This includes but are not limited to:
|
|
25
|
-
1. Text Embeddings Inference (https://github.com/huggingface/text-embeddings-inference)
|
|
26
|
-
2. vLLM (https://vllm.ai/)
|
|
27
|
-
When using this invoker, please note that the supported features and capabilities may vary between different
|
|
28
|
-
endpoints and language models. Using features that are not supported by the endpoint will result in an error.
|
|
29
|
-
|
|
30
|
-
Input types:
|
|
31
|
-
The `OpenAICompatibleEMInvoker` only supports text inputs.
|
|
32
|
-
|
|
33
|
-
Output format:
|
|
34
|
-
The `OpenAICompatibleEMInvoker` can embed either:
|
|
35
|
-
1. A single content.
|
|
36
|
-
1. A single content is a single text.
|
|
37
|
-
2. The output will be a `Vector`, representing the embedding of the content.
|
|
38
|
-
|
|
39
|
-
# Example 1: Embedding a text content.
|
|
40
|
-
```python
|
|
41
|
-
text = "This is a text"
|
|
42
|
-
result = await em_invoker.invoke(text)
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
The above examples will return a `Vector` with a size of (embedding_size,).
|
|
46
|
-
|
|
47
|
-
2. A list of contents.
|
|
48
|
-
1. A list of contents is a list of texts.
|
|
49
|
-
2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
|
|
50
|
-
embedding of each single content.
|
|
51
|
-
|
|
52
|
-
# Example: Embedding a list of contents.
|
|
53
|
-
```python
|
|
54
|
-
text1 = "This is a text"
|
|
55
|
-
text2 = "This is another text"
|
|
56
|
-
text3 = "This is yet another text"
|
|
57
|
-
result = await em_invoker.invoke([text1, text2, text3])
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
The above examples will return a `list[Vector]` with a size of (3, embedding_size).
|
|
61
|
-
|
|
62
|
-
Retry and timeout:
|
|
63
|
-
The `OpenAICompatibleEMInvoker` supports retry and timeout configuration.
|
|
64
|
-
By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
|
|
65
|
-
They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
|
|
66
|
-
|
|
67
|
-
Retry config examples:
|
|
68
|
-
```python
|
|
69
|
-
retry_config = RetryConfig(max_retries=0, timeout=0.0) # No retry, no timeout
|
|
70
|
-
retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
|
|
71
|
-
retry_config = RetryConfig(max_retries=5, timeout=0.0) # 5 max retries, no timeout
|
|
72
|
-
retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Usage example:
|
|
76
|
-
```python
|
|
77
|
-
em_invoker = OpenAICompatibleEMInvoker(..., retry_config=retry_config)
|
|
78
|
-
```
|
|
79
|
-
'''
|
|
23
|
+
This class is deprecated and will be removed in v0.6. Please use the `OpenAIEMInvoker` class instead.
|
|
24
|
+
"""
|
|
80
25
|
client: Incomplete
|
|
81
26
|
def __init__(self, model_name: str, base_url: str, api_key: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, truncation_config: TruncationConfig | None = None) -> None:
|
|
82
27
|
"""Initializes a new instance of the OpenAICompatibleEMInvoker class.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
2
|
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
-
from gllm_inference.constants import INVOKER_PROPAGATED_MAX_RETRIES as INVOKER_PROPAGATED_MAX_RETRIES
|
|
3
|
+
from gllm_inference.constants import INVOKER_PROPAGATED_MAX_RETRIES as INVOKER_PROPAGATED_MAX_RETRIES, OPENAI_DEFAULT_URL as OPENAI_DEFAULT_URL
|
|
4
4
|
from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
|
|
5
5
|
from gllm_inference.em_invoker.schema.openai import Key as Key
|
|
6
6
|
from gllm_inference.schema import ModelId as ModelId, ModelProvider as ModelProvider, Vector as Vector
|
|
@@ -21,6 +21,31 @@ class OpenAIEMInvoker(BaseEMInvoker):
|
|
|
21
21
|
retry_config (RetryConfig): The retry configuration for the embedding model.
|
|
22
22
|
truncation_config (TruncationConfig | None): The truncation configuration for the embedding model.
|
|
23
23
|
|
|
24
|
+
Basic usage:
|
|
25
|
+
The `OpenAIEMInvoker` can be used as follows:
|
|
26
|
+
```python
|
|
27
|
+
em_invoker = OpenAIEMInvoker(model_name="text-embedding-3-small")
|
|
28
|
+
result = await em_invoker.invoke("Hi there!")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
OpenAI compatible endpoints:
|
|
32
|
+
The `OpenAIEMInvoker` can also be used to interact with endpoints that are compatible with
|
|
33
|
+
OpenAI\'s Embeddings API schema. This includes but are not limited to:
|
|
34
|
+
1. Text Embeddings Inference (https://github.com/huggingface/text-embeddings-inference)
|
|
35
|
+
2. vLLM (https://vllm.ai/)
|
|
36
|
+
Please note that the supported features and capabilities may vary between different endpoints and
|
|
37
|
+
language models. Using features that are not supported by the endpoint will result in an error.
|
|
38
|
+
|
|
39
|
+
This customization can be done by setting the `base_url` parameter to the base URL of the endpoint:
|
|
40
|
+
```python
|
|
41
|
+
em_invoker = OpenAIEMInvoker(
|
|
42
|
+
model_name="<model-name>",
|
|
43
|
+
api_key="<your-api-key>",
|
|
44
|
+
base_url="<https://base-url>",
|
|
45
|
+
)
|
|
46
|
+
result = await em_invoker.invoke("Hi there!")
|
|
47
|
+
```
|
|
48
|
+
|
|
24
49
|
Input types:
|
|
25
50
|
The `OpenAIEMInvoker` only supports text inputs.
|
|
26
51
|
|
|
@@ -72,13 +97,16 @@ class OpenAIEMInvoker(BaseEMInvoker):
|
|
|
72
97
|
```
|
|
73
98
|
'''
|
|
74
99
|
client: Incomplete
|
|
75
|
-
def __init__(self, model_name: str, api_key: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, truncation_config: TruncationConfig | None = None) -> None:
|
|
76
|
-
|
|
100
|
+
def __init__(self, model_name: str, api_key: str | None = None, base_url: str = ..., model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, truncation_config: TruncationConfig | None = None) -> None:
|
|
101
|
+
'''Initializes a new instance of the OpenAIEMInvoker class.
|
|
77
102
|
|
|
78
103
|
Args:
|
|
79
104
|
model_name (str): The name of the OpenAI embedding model to be used.
|
|
80
|
-
api_key (str | None, optional): The API key for
|
|
81
|
-
case the `OPENAI_API_KEY` environment variable will be used.
|
|
105
|
+
api_key (str | None, optional): The API key for authenticating with OpenAI. Defaults to None, in which
|
|
106
|
+
case the `OPENAI_API_KEY` environment variable will be used. If the endpoint does not require an
|
|
107
|
+
API key, a dummy value can be passed (e.g. "<empty>").
|
|
108
|
+
base_url (str, optional): The base URL of a custom endpoint that is compatible with OpenAI\'s
|
|
109
|
+
Embeddings API schema. Defaults to OpenAI\'s default URL.
|
|
82
110
|
model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the OpenAI client.
|
|
83
111
|
Defaults to None.
|
|
84
112
|
default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
|
|
@@ -87,4 +115,4 @@ class OpenAIEMInvoker(BaseEMInvoker):
|
|
|
87
115
|
Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
|
|
88
116
|
truncation_config (TruncationConfig | None, optional): Configuration for text truncation behavior.
|
|
89
117
|
Defaults to None, in which case no truncation is applied.
|
|
90
|
-
|
|
118
|
+
'''
|
|
@@ -5,8 +5,9 @@ from gllm_inference.lm_invoker.datasaur_lm_invoker import DatasaurLMInvoker as D
|
|
|
5
5
|
from gllm_inference.lm_invoker.google_lm_invoker import GoogleLMInvoker as GoogleLMInvoker
|
|
6
6
|
from gllm_inference.lm_invoker.langchain_lm_invoker import LangChainLMInvoker as LangChainLMInvoker
|
|
7
7
|
from gllm_inference.lm_invoker.litellm_lm_invoker import LiteLLMLMInvoker as LiteLLMLMInvoker
|
|
8
|
+
from gllm_inference.lm_invoker.openai_chat_completions_lm_invoker import OpenAIChatCompletionsLMInvoker as OpenAIChatCompletionsLMInvoker
|
|
8
9
|
from gllm_inference.lm_invoker.openai_compatible_lm_invoker import OpenAICompatibleLMInvoker as OpenAICompatibleLMInvoker
|
|
9
10
|
from gllm_inference.lm_invoker.openai_lm_invoker import OpenAILMInvoker as OpenAILMInvoker
|
|
10
11
|
from gllm_inference.lm_invoker.xai_lm_invoker import XAILMInvoker as XAILMInvoker
|
|
11
12
|
|
|
12
|
-
__all__ = ['AnthropicLMInvoker', 'AzureOpenAILMInvoker', 'BedrockLMInvoker', 'DatasaurLMInvoker', 'GoogleLMInvoker', 'LangChainLMInvoker', 'LiteLLMLMInvoker', 'OpenAICompatibleLMInvoker', 'OpenAILMInvoker', 'XAILMInvoker']
|
|
13
|
+
__all__ = ['AnthropicLMInvoker', 'AzureOpenAILMInvoker', 'BedrockLMInvoker', 'DatasaurLMInvoker', 'GoogleLMInvoker', 'LangChainLMInvoker', 'LiteLLMLMInvoker', 'OpenAIChatCompletionsLMInvoker', 'OpenAICompatibleLMInvoker', 'OpenAILMInvoker', 'XAILMInvoker']
|
|
@@ -37,7 +37,7 @@ class LangChainLMInvoker(BaseLMInvoker):
|
|
|
37
37
|
```python
|
|
38
38
|
lm_invoker = LangChainLMInvoker(
|
|
39
39
|
model_class_path="langchain_openai.ChatOpenAI",
|
|
40
|
-
model_name="gpt-
|
|
40
|
+
model_name="gpt-5-nano",
|
|
41
41
|
)
|
|
42
42
|
result = await lm_invoker.invoke("Hi there!")
|
|
43
43
|
```
|
|
@@ -50,7 +50,7 @@ class LangChainLMInvoker(BaseLMInvoker):
|
|
|
50
50
|
```python
|
|
51
51
|
from langchain_openai import ChatOpenAI
|
|
52
52
|
|
|
53
|
-
model = ChatOpenAI(model="gpt-
|
|
53
|
+
model = ChatOpenAI(model="gpt-5-nano", api_key="your_api_key")
|
|
54
54
|
lm_invoker = LangChainLMInvoker(model=model)
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ class LangChainLMInvoker(BaseLMInvoker):
|
|
|
59
59
|
```python
|
|
60
60
|
lm_invoker = LangChainLMInvoker(
|
|
61
61
|
model_class_path="langchain_openai.ChatOpenAI",
|
|
62
|
-
model_name="gpt-
|
|
62
|
+
model_name="gpt-5-nano",
|
|
63
63
|
model_kwargs={"api_key": "your_api_key"}
|
|
64
64
|
)
|
|
65
65
|
```
|
|
@@ -27,7 +27,7 @@ class LiteLLMLMInvoker(OpenAICompatibleLMInvoker):
|
|
|
27
27
|
Basic usage:
|
|
28
28
|
The `LiteLLMLMInvoker` can be used as follows:
|
|
29
29
|
```python
|
|
30
|
-
lm_invoker = LiteLLMLMInvoker(model_id="openai/gpt-
|
|
30
|
+
lm_invoker = LiteLLMLMInvoker(model_id="openai/gpt-5-nano")
|
|
31
31
|
result = await lm_invoker.invoke("Hi there!")
|
|
32
32
|
```
|
|
33
33
|
|