salesforce-data-customcode 6.0.2.dev1__py3-none-any.whl → 6.0.3.dev2__py3-none-any.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.
- datacustomcode/client.py +23 -21
- datacustomcode/llm_gateway/__init__.py +2 -0
- datacustomcode/llm_gateway/default.py +0 -2
- datacustomcode/llm_gateway/errors.py +36 -0
- datacustomcode/llm_gateway/spark_base.py +10 -3
- datacustomcode/llm_gateway/spark_default.py +81 -16
- datacustomcode/llm_gateway/types/generate_text_request.py +0 -7
- datacustomcode/llm_gateway/types/generate_text_request_builder.py +0 -6
- datacustomcode/templates/script/payload/entrypoint.py +5 -4
- {salesforce_data_customcode-6.0.2.dev1.dist-info → salesforce_data_customcode-6.0.3.dev2.dist-info}/METADATA +5 -3
- {salesforce_data_customcode-6.0.2.dev1.dist-info → salesforce_data_customcode-6.0.3.dev2.dist-info}/RECORD +14 -13
- {salesforce_data_customcode-6.0.2.dev1.dist-info → salesforce_data_customcode-6.0.3.dev2.dist-info}/WHEEL +0 -0
- {salesforce_data_customcode-6.0.2.dev1.dist-info → salesforce_data_customcode-6.0.3.dev2.dist-info}/entry_points.txt +0 -0
- {salesforce_data_customcode-6.0.2.dev1.dist-info → salesforce_data_customcode-6.0.3.dev2.dist-info}/licenses/LICENSE.txt +0 -0
datacustomcode/client.py
CHANGED
|
@@ -59,20 +59,26 @@ def llm_gateway_generate_text_col(
|
|
|
59
59
|
template: str,
|
|
60
60
|
values: Union[Dict[str, "Column"], "Column"],
|
|
61
61
|
model_id: Optional[str] = None,
|
|
62
|
-
max_tokens: Optional[int] = None,
|
|
63
62
|
) -> "Column":
|
|
64
63
|
"""Build a Spark Column that runs the LLM Gateway per row.
|
|
65
64
|
|
|
65
|
+
The returned Column yields a struct ``{status, response, error_code,
|
|
66
|
+
error_message}`` for each row. Use ``[...]`` (or ``getField``) to pick the
|
|
67
|
+
field you want, e.g. ``llm_gateway_generate_text_col(...)["response"]``.
|
|
68
|
+
Per-row failures populate ``status`` / ``error_code`` / ``error_message``
|
|
69
|
+
so a single bad row does not abort the whole Spark job.
|
|
70
|
+
|
|
66
71
|
Example:
|
|
67
72
|
|
|
68
|
-
>>>
|
|
69
|
-
... "
|
|
70
|
-
...
|
|
71
|
-
...
|
|
72
|
-
...
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
>>> result = llm_gateway_generate_text_col(
|
|
74
|
+
... "In one sentence, greet {name} from {city}.",
|
|
75
|
+
... {"name": col("name__c"), "city": col("homecity__c")},
|
|
76
|
+
... model_id="sfdc_ai__DefaultGPT4Omni",
|
|
77
|
+
... )
|
|
78
|
+
>>> df.withColumn("greeting__c", result["response"])
|
|
79
|
+
>>> # …or keep the struct around and inspect failures:
|
|
80
|
+
>>> df.withColumn("llm", result).select(
|
|
81
|
+
... "llm.status", "llm.response", "llm.error_message"
|
|
76
82
|
... )
|
|
77
83
|
|
|
78
84
|
Args:
|
|
@@ -81,15 +87,16 @@ def llm_gateway_generate_text_col(
|
|
|
81
87
|
values: Either a mapping from placeholder name to Spark ``Column``, or
|
|
82
88
|
a single ``Column`` whose value is already a struct.
|
|
83
89
|
model_id: LLM model id. Defaults to ``sfdc_ai__DefaultGPT4Omni``.
|
|
84
|
-
max_tokens: Maximum tokens to generate. Defaults to 200.
|
|
85
90
|
|
|
86
91
|
Returns:
|
|
87
|
-
A Spark ``Column``
|
|
92
|
+
A Spark ``Column`` of ``StructType`` with fields ``status``,
|
|
93
|
+
``response``, ``error_code``, and ``error_message`` (all nullable
|
|
94
|
+
strings). On success, ``status == "SUCCESS"`` and ``response`` holds
|
|
95
|
+
the generated text; on failure, ``status == "ERROR"`` and the
|
|
96
|
+
``error_*`` fields carry diagnostic detail.
|
|
88
97
|
"""
|
|
89
98
|
gateway = Client()._get_spark_llm_gateway()
|
|
90
|
-
return gateway.llm_gateway_generate_text_col(
|
|
91
|
-
template, values, model_id=model_id, max_tokens=max_tokens
|
|
92
|
-
)
|
|
99
|
+
return gateway.llm_gateway_generate_text_col(template, values, model_id=model_id)
|
|
93
100
|
|
|
94
101
|
|
|
95
102
|
class DataCloudObjectType(Enum):
|
|
@@ -150,9 +157,7 @@ class Client:
|
|
|
150
157
|
finder: Find a file path
|
|
151
158
|
reader: A custom reader to use for reading Data Cloud objects.
|
|
152
159
|
writer: A custom writer to use for writing Data Cloud objects.
|
|
153
|
-
spark_llm_gateway: Optional custom :class:`SparkLLMGateway`.
|
|
154
|
-
omitted, the gateway is lazily resolved from
|
|
155
|
-
``spark_llm_gateway_config``.
|
|
160
|
+
spark_llm_gateway: Optional custom :class:`SparkLLMGateway`.
|
|
156
161
|
|
|
157
162
|
Example:
|
|
158
163
|
>>> client = Client()
|
|
@@ -292,7 +297,6 @@ class Client:
|
|
|
292
297
|
self,
|
|
293
298
|
prompt: str,
|
|
294
299
|
model_id: Optional[str] = None,
|
|
295
|
-
max_tokens: Optional[int] = None,
|
|
296
300
|
) -> str:
|
|
297
301
|
"""Issue a one-shot LLM Gateway call. This is the scalar counterpart to
|
|
298
302
|
:func:`llm_gateway_generate_text_col`: it runs **once** — not per row.
|
|
@@ -310,15 +314,13 @@ class Client:
|
|
|
310
314
|
``{field}`` substitution is performed on this string.
|
|
311
315
|
model_id: LLM model id to target. Defaults to
|
|
312
316
|
``sfdc_ai__DefaultGPT4Omni`` when ``None``.
|
|
313
|
-
max_tokens: Hard upper bound on the number of tokens the model
|
|
314
|
-
may generate. Defaults to 200 when ``None``.
|
|
315
317
|
|
|
316
318
|
Returns:
|
|
317
319
|
The generated text as a plain Python ``str``; empty when the
|
|
318
320
|
gateway response carries no generated text.
|
|
319
321
|
"""
|
|
320
322
|
return self._get_spark_llm_gateway().llm_gateway_generate_text(
|
|
321
|
-
prompt, model_id=model_id
|
|
323
|
+
prompt, model_id=model_id
|
|
322
324
|
)
|
|
323
325
|
|
|
324
326
|
def _get_spark_llm_gateway(self) -> SparkLLMGateway:
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
from datacustomcode.llm_gateway.base import LLMGateway
|
|
17
17
|
from datacustomcode.llm_gateway.default import DefaultLLMGateway
|
|
18
|
+
from datacustomcode.llm_gateway.errors import LLMGatewayCallError
|
|
18
19
|
from datacustomcode.llm_gateway.spark_base import SparkLLMGateway
|
|
19
20
|
from datacustomcode.llm_gateway.spark_default import DefaultSparkLLMGateway
|
|
20
21
|
|
|
@@ -22,5 +23,6 @@ __all__ = [
|
|
|
22
23
|
"DefaultLLMGateway",
|
|
23
24
|
"DefaultSparkLLMGateway",
|
|
24
25
|
"LLMGateway",
|
|
26
|
+
"LLMGatewayCallError",
|
|
25
27
|
"SparkLLMGateway",
|
|
26
28
|
]
|
|
@@ -34,8 +34,6 @@ class DefaultLLMGateway(EinsteinPlatformClient, LLMGateway):
|
|
|
34
34
|
|
|
35
35
|
payload: Dict[str, Any] = {"prompt": request.prompt}
|
|
36
36
|
|
|
37
|
-
if request.max_tokens is not None:
|
|
38
|
-
payload["max_tokens"] = request.max_tokens
|
|
39
37
|
if request.localization:
|
|
40
38
|
payload["localization"] = request.localization
|
|
41
39
|
if request.tags:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) 2025, Salesforce, Inc.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
"""Exceptions raised by LLM Gateway implementations."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import Optional
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class LLMGatewayCallError(RuntimeError):
|
|
23
|
+
"""Raised when an LLM Gateway call returns an error."""
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
message: str,
|
|
28
|
+
*,
|
|
29
|
+
status: Optional[object] = None,
|
|
30
|
+
error_code: Optional[str] = None,
|
|
31
|
+
error_message: Optional[str] = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
super().__init__(message)
|
|
34
|
+
self.status = status
|
|
35
|
+
self.error_code = error_code
|
|
36
|
+
self.error_message = error_message
|
|
@@ -40,7 +40,6 @@ class SparkLLMGateway(ABC, UserExtendableNamedConfigMixin):
|
|
|
40
40
|
self,
|
|
41
41
|
prompt: str,
|
|
42
42
|
model_id: Optional[str] = None,
|
|
43
|
-
max_tokens: Optional[int] = None,
|
|
44
43
|
) -> str:
|
|
45
44
|
"""Issue a one-shot LLM Gateway call and return the generated text."""
|
|
46
45
|
|
|
@@ -50,6 +49,14 @@ class SparkLLMGateway(ABC, UserExtendableNamedConfigMixin):
|
|
|
50
49
|
template: str,
|
|
51
50
|
values: Union[Dict[str, "Column"], "Column"],
|
|
52
51
|
model_id: Optional[str] = None,
|
|
53
|
-
max_tokens: Optional[int] = None,
|
|
54
52
|
) -> "Column":
|
|
55
|
-
"""Build a Spark ``Column`` that invokes the LLM Gateway per row
|
|
53
|
+
"""Build a Spark ``Column`` that invokes the LLM Gateway per row and
|
|
54
|
+
yields a struct ``{status, response, error_code, error_message}``.
|
|
55
|
+
|
|
56
|
+
Select an individual field, e.g.
|
|
57
|
+
``llm_gateway_generate_text_col(...)["response"]``. Returning a struct
|
|
58
|
+
means a single failing row doesn't abort the Spark job.
|
|
59
|
+
Failing row leaves the rest of the DataFrame intact — callers can
|
|
60
|
+
inspect ``status`` / ``error_code`` per row instead of having the
|
|
61
|
+
Spark job abort.
|
|
62
|
+
"""
|
|
@@ -28,10 +28,15 @@ if TYPE_CHECKING:
|
|
|
28
28
|
from pyspark.sql import Column
|
|
29
29
|
|
|
30
30
|
from datacustomcode.llm_gateway.base import LLMGateway
|
|
31
|
+
from datacustomcode.llm_gateway.types.generate_text_response import (
|
|
32
|
+
GenerateTextResponse,
|
|
33
|
+
)
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
_DEFAULT_LLM_MODEL_ID = "sfdc_ai__DefaultGPT4Omni"
|
|
34
|
-
|
|
37
|
+
|
|
38
|
+
_STATUS_SUCCESS = "SUCCESS"
|
|
39
|
+
_STATUS_ERROR = "ERROR"
|
|
35
40
|
|
|
36
41
|
|
|
37
42
|
class DefaultSparkLLMGateway(SparkLLMGateway):
|
|
@@ -52,20 +57,26 @@ class DefaultSparkLLMGateway(SparkLLMGateway):
|
|
|
52
57
|
self,
|
|
53
58
|
prompt: str,
|
|
54
59
|
model_id: Optional[str] = None,
|
|
55
|
-
max_tokens: Optional[int] = None,
|
|
56
60
|
) -> str:
|
|
57
|
-
return _invoke_llm_gateway(self._llm_gateway, prompt, model_id
|
|
61
|
+
return _invoke_llm_gateway(self._llm_gateway, prompt, model_id)
|
|
58
62
|
|
|
59
63
|
def llm_gateway_generate_text_col(
|
|
60
64
|
self,
|
|
61
65
|
template: str,
|
|
62
66
|
values: Union[Dict[str, "Column"], "Column"],
|
|
63
67
|
model_id: Optional[str] = None,
|
|
64
|
-
max_tokens: Optional[int] = None,
|
|
65
68
|
) -> "Column":
|
|
66
|
-
|
|
69
|
+
"""Build a per-row UDF that returns a struct ``{status, response,
|
|
70
|
+
error_code, error_message}`` so per-row failures do not abort the
|
|
71
|
+
Spark job. Callers select the field they want, e.g.
|
|
72
|
+
``llm_gateway_generate_text_col(...)["response"]``.
|
|
73
|
+
"""
|
|
67
74
|
from pyspark.sql.functions import struct, udf
|
|
68
|
-
from pyspark.sql.types import
|
|
75
|
+
from pyspark.sql.types import (
|
|
76
|
+
StringType,
|
|
77
|
+
StructField,
|
|
78
|
+
StructType,
|
|
79
|
+
)
|
|
69
80
|
|
|
70
81
|
if isinstance(values, dict):
|
|
71
82
|
values_col = struct(*[v.alias(k) for k, v in values.items()])
|
|
@@ -73,19 +84,32 @@ class DefaultSparkLLMGateway(SparkLLMGateway):
|
|
|
73
84
|
values_col = values
|
|
74
85
|
|
|
75
86
|
gateway = self._llm_gateway
|
|
87
|
+
result_schema = StructType(
|
|
88
|
+
[
|
|
89
|
+
StructField("status", StringType(), True),
|
|
90
|
+
StructField("response", StringType(), True),
|
|
91
|
+
StructField("error_code", StringType(), True),
|
|
92
|
+
StructField("error_message", StringType(), True),
|
|
93
|
+
]
|
|
94
|
+
)
|
|
76
95
|
|
|
77
|
-
def _generate(values_row: Any) -> str:
|
|
96
|
+
def _generate(values_row: Any) -> Dict[str, Optional[str]]:
|
|
78
97
|
if values_row is None:
|
|
79
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
"status": _STATUS_ERROR,
|
|
100
|
+
"response": None,
|
|
101
|
+
"error_code": None,
|
|
102
|
+
"error_message": "values column was null for this row",
|
|
103
|
+
}
|
|
80
104
|
subs = (
|
|
81
105
|
values_row.asDict()
|
|
82
106
|
if hasattr(values_row, "asDict")
|
|
83
107
|
else dict(values_row)
|
|
84
108
|
)
|
|
85
109
|
prompt = template.format(**subs)
|
|
86
|
-
return
|
|
110
|
+
return _invoke_llm_gateway_as_struct(gateway, prompt, model_id)
|
|
87
111
|
|
|
88
|
-
return udf(_generate,
|
|
112
|
+
return udf(_generate, result_schema)(values_col)
|
|
89
113
|
|
|
90
114
|
|
|
91
115
|
def _build_underlying_gateway() -> "LLMGateway":
|
|
@@ -100,20 +124,61 @@ def _build_underlying_gateway() -> "LLMGateway":
|
|
|
100
124
|
return cfg.to_object()
|
|
101
125
|
|
|
102
126
|
|
|
103
|
-
def
|
|
127
|
+
def _call_llm_gateway(
|
|
104
128
|
gateway: "LLMGateway",
|
|
105
129
|
prompt: str,
|
|
106
130
|
model_id: Optional[str],
|
|
107
|
-
|
|
108
|
-
|
|
131
|
+
) -> "GenerateTextResponse":
|
|
132
|
+
"""Build the request and dispatch it to the underlying gateway."""
|
|
109
133
|
from datacustomcode.llm_gateway.types.generate_text_request_builder import (
|
|
110
134
|
GenerateTextRequestBuilder,
|
|
111
135
|
)
|
|
112
136
|
|
|
113
|
-
|
|
137
|
+
request = (
|
|
114
138
|
GenerateTextRequestBuilder()
|
|
115
139
|
.set_prompt(prompt)
|
|
116
140
|
.set_model(model_id or _DEFAULT_LLM_MODEL_ID)
|
|
117
|
-
.
|
|
141
|
+
.build()
|
|
118
142
|
)
|
|
119
|
-
return gateway.generate_text(
|
|
143
|
+
return gateway.generate_text(request)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _invoke_llm_gateway(
|
|
147
|
+
gateway: "LLMGateway",
|
|
148
|
+
prompt: str,
|
|
149
|
+
model_id: Optional[str],
|
|
150
|
+
) -> str:
|
|
151
|
+
from datacustomcode.llm_gateway.errors import LLMGatewayCallError
|
|
152
|
+
|
|
153
|
+
response = _call_llm_gateway(gateway, prompt, model_id)
|
|
154
|
+
if response.is_error:
|
|
155
|
+
raise LLMGatewayCallError(
|
|
156
|
+
f"LLM Gateway call failed: status_code={response.status_code}, "
|
|
157
|
+
f"error_code={response.error_code!r}, "
|
|
158
|
+
f"message={response.data!r}",
|
|
159
|
+
status=response.status_code,
|
|
160
|
+
error_code=response.error_code or None,
|
|
161
|
+
error_message=str(response.data) if response.data else None,
|
|
162
|
+
)
|
|
163
|
+
return response.text
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _invoke_llm_gateway_as_struct(
|
|
167
|
+
gateway: "LLMGateway",
|
|
168
|
+
prompt: str,
|
|
169
|
+
model_id: Optional[str],
|
|
170
|
+
) -> Dict[str, Optional[str]]:
|
|
171
|
+
response = _call_llm_gateway(gateway, prompt, model_id)
|
|
172
|
+
if response.is_error:
|
|
173
|
+
return {
|
|
174
|
+
"status": _STATUS_ERROR,
|
|
175
|
+
"response": None,
|
|
176
|
+
"error_code": response.error_code or None,
|
|
177
|
+
"error_message": str(response.data) if response.data else None,
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
"status": _STATUS_SUCCESS,
|
|
181
|
+
"response": response.text,
|
|
182
|
+
"error_code": None,
|
|
183
|
+
"error_message": None,
|
|
184
|
+
}
|
|
@@ -40,13 +40,6 @@ class GenerateTextRequest(BaseModel):
|
|
|
40
40
|
)
|
|
41
41
|
model_name: str = Field(..., min_length=1, description="Name of the model to use")
|
|
42
42
|
prompt: str = Field(..., description="Input prompt")
|
|
43
|
-
max_tokens: Optional[int] = Field(
|
|
44
|
-
default=None,
|
|
45
|
-
ge=1,
|
|
46
|
-
description=(
|
|
47
|
-
"Maximum number of tokens to generate. If None, server default applies."
|
|
48
|
-
),
|
|
49
|
-
)
|
|
50
43
|
localization: Optional[Dict[str, Any]] = Field(
|
|
51
44
|
default=None, description="Localization settings"
|
|
52
45
|
)
|
|
@@ -26,7 +26,6 @@ class GenerateTextRequestBuilder:
|
|
|
26
26
|
def __init__(self) -> None:
|
|
27
27
|
self._prompt = ""
|
|
28
28
|
self._model_name = ""
|
|
29
|
-
self._max_tokens: Optional[int] = None
|
|
30
29
|
self._localization: Optional[Dict[str, Any]] = None
|
|
31
30
|
self._tags: Optional[Dict[str, Any]] = None
|
|
32
31
|
|
|
@@ -38,10 +37,6 @@ class GenerateTextRequestBuilder:
|
|
|
38
37
|
self._model_name = model_name
|
|
39
38
|
return self
|
|
40
39
|
|
|
41
|
-
def set_max_tokens(self, max_tokens: int) -> "GenerateTextRequestBuilder":
|
|
42
|
-
self._max_tokens = max_tokens
|
|
43
|
-
return self
|
|
44
|
-
|
|
45
40
|
def set_localization(
|
|
46
41
|
self,
|
|
47
42
|
localization: Optional[Dict[str, Any]] = None,
|
|
@@ -80,7 +75,6 @@ class GenerateTextRequestBuilder:
|
|
|
80
75
|
request = GenerateTextRequest(
|
|
81
76
|
prompt=self._prompt,
|
|
82
77
|
model_name=self._model_name,
|
|
83
|
-
max_tokens=self._max_tokens,
|
|
84
78
|
localization=self._localization,
|
|
85
79
|
tags=self._tags,
|
|
86
80
|
)
|
|
@@ -16,7 +16,9 @@ def main():
|
|
|
16
16
|
You can use your AI models configured in Salesforce to generate column
|
|
17
17
|
values. See README.md for how to test locally before deploying to Data Cloud.
|
|
18
18
|
|
|
19
|
-
Example
|
|
19
|
+
Example (the per-row helper returns a struct
|
|
20
|
+
``{status, response, error_code, error_message}`` — pick the field you
|
|
21
|
+
want with ``[...]``):
|
|
20
22
|
|
|
21
23
|
>>> from datacustomcode.client import llm_gateway_generate_text_col
|
|
22
24
|
df_generated = df.withColumn(
|
|
@@ -25,8 +27,7 @@ def main():
|
|
|
25
27
|
... "In one sentence, greet {name} from {city}.",
|
|
26
28
|
... {"name": col("name__c"), "city": col("homecity__c")},
|
|
27
29
|
... model_id="sfdc_ai__DefaultGPT4Omni",
|
|
28
|
-
...
|
|
29
|
-
... ),
|
|
30
|
+
... )["response"],
|
|
30
31
|
... )
|
|
31
32
|
|
|
32
33
|
You can also invoke the LLM with a literal plain text prompt — no
|
|
@@ -35,7 +36,7 @@ def main():
|
|
|
35
36
|
Example:
|
|
36
37
|
|
|
37
38
|
>>> generated_text = client.llm_gateway_generate_text(
|
|
38
|
-
... prompt, model_id
|
|
39
|
+
... prompt, model_id
|
|
39
40
|
... )
|
|
40
41
|
"""
|
|
41
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: salesforce-data-customcode
|
|
3
|
-
Version: 6.0.
|
|
3
|
+
Version: 6.0.3.dev2
|
|
4
4
|
Summary: Data Cloud Custom Code SDK
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -341,14 +341,16 @@ from datacustomcode.client import Client, llm_gateway_generate_text_col
|
|
|
341
341
|
def main():
|
|
342
342
|
client = Client()
|
|
343
343
|
df = client.read_dlo("Input__dll")
|
|
344
|
+
# llm_gateway_generate_text_col returns a struct
|
|
345
|
+
# {status, response, error_code, error_message} per row, so per-row
|
|
346
|
+
# failures don't abort the Spark job. Pick the field you want with [].
|
|
344
347
|
df_generated = df.withColumn(
|
|
345
348
|
"greeting__c",
|
|
346
349
|
llm_gateway_generate_text_col(
|
|
347
350
|
"In one sentence, greet {name} from {city}.",
|
|
348
351
|
{"name": col("name__c"), "city": col("homecity__c")},
|
|
349
352
|
model_id="sfdc_ai__DefaultGPT4Omni", # An AI model in your org
|
|
350
|
-
|
|
351
|
-
),
|
|
353
|
+
)["response"],
|
|
352
354
|
)
|
|
353
355
|
|
|
354
356
|
dlo_name = "Output_dll"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
datacustomcode/__init__.py,sha256=qx-X3U9lU_791ZbAxhGqQeyDw6eqTi9-E9AbYnwJfxU,2071
|
|
2
2
|
datacustomcode/auth.py,sha256=fpSjhIBdv9trC8yq2vuljAix_Euu-4Ah7HDCGhYjOxI,8309
|
|
3
3
|
datacustomcode/cli.py,sha256=ObqhOasZSZ8ZNFP6pywV3FpsUOz45_KaZdMNT4BHOKs,13069
|
|
4
|
-
datacustomcode/client.py,sha256=
|
|
4
|
+
datacustomcode/client.py,sha256=eV_Bv-YfxXcayjgtAbu9tXb_UcHgcE2f3-L_3vvc0cI,13616
|
|
5
5
|
datacustomcode/cmd.py,sha256=ZMs46aydJw2EaU26JgCtZmnqESQFHvvaJz10hnjZTBk,3537
|
|
6
6
|
datacustomcode/common_config.py,sha256=SAUnxj3kqmOeWwPmFoYq4tuxokMgURVm4QwcGi-avL4,1928
|
|
7
7
|
datacustomcode/config.py,sha256=2Pk61ieQsEWSxKDxlS66_rliKE8iX0j-9LweEm0aaGo,4072
|
|
@@ -37,14 +37,15 @@ datacustomcode/io/writer/__init__.py,sha256=gamfOD1VnAtEslRBpqh-yKiVjkG_wYWYdSat
|
|
|
37
37
|
datacustomcode/io/writer/base.py,sha256=RHafJ-Xmh_TnYcN4QfSh0VdIZeIevKmz9sf05adMgxA,1540
|
|
38
38
|
datacustomcode/io/writer/csv.py,sha256=asty5teBpNQ1fMGHZ7wA3suLhq0sk0lVQPN5x7TOSRk,1555
|
|
39
39
|
datacustomcode/io/writer/print.py,sha256=0g2sP_1Wb95UIyEELWJt3dqM18Iv_CWhDW3mDxcIhns,5105
|
|
40
|
-
datacustomcode/llm_gateway/__init__.py,sha256=
|
|
40
|
+
datacustomcode/llm_gateway/__init__.py,sha256=rcoGpSkv36tZuAOcTxKkhNpM0qV03qgmer_ej07Vmfc,1088
|
|
41
41
|
datacustomcode/llm_gateway/base.py,sha256=CTUhZiZ0JFlmWj6kQpTR4_-mUvqkBKl_Fkdvv9VwxY8,1262
|
|
42
|
-
datacustomcode/llm_gateway/default.py,sha256=
|
|
43
|
-
datacustomcode/llm_gateway/
|
|
44
|
-
datacustomcode/llm_gateway/
|
|
42
|
+
datacustomcode/llm_gateway/default.py,sha256=QiwrDaUvrh00I-fYYhmogTtqC5r0fmm-JrXxNQLvTc0,1854
|
|
43
|
+
datacustomcode/llm_gateway/errors.py,sha256=ABjztpJwAYMBlmFX808CHHtu4nD6zA4ECelzNJQkJg0,1197
|
|
44
|
+
datacustomcode/llm_gateway/spark_base.py,sha256=caf-fHTOo9SMTkK5Ozhrt70b51Rz_6hDY0rwa6jKwuE,2000
|
|
45
|
+
datacustomcode/llm_gateway/spark_default.py,sha256=7yC8lSJ7DKXTqtm_i0JjFqxML8hkT65h6n3i1CID8Ds,5745
|
|
45
46
|
datacustomcode/llm_gateway/types/__init__.py,sha256=gamfOD1VnAtEslRBpqh-yKiVjkG_wYWYdSatGIfsN-w,621
|
|
46
|
-
datacustomcode/llm_gateway/types/generate_text_request.py,sha256=
|
|
47
|
-
datacustomcode/llm_gateway/types/generate_text_request_builder.py,sha256=
|
|
47
|
+
datacustomcode/llm_gateway/types/generate_text_request.py,sha256=ChxOCzp7St1EYgwl4tWiwfrPyVci4zPyBhnEjWc1Vfs,1448
|
|
48
|
+
datacustomcode/llm_gateway/types/generate_text_request_builder.py,sha256=R4hCgatMPSfWYqaOmeC1IMQj753iDgu7wU992c4tkmk,2565
|
|
48
49
|
datacustomcode/llm_gateway/types/generate_text_response.py,sha256=NSvj6nvzR4cZ0cVs2-PE9Ct3ZY-xL4MQYknJMd_xdDI,1912
|
|
49
50
|
datacustomcode/llm_gateway/types/generate_text_response_builder.py,sha256=6MV6JZuTyHUId3Slw9k7m0KBgjj-5S9HI4qtd94Jl2A,1272
|
|
50
51
|
datacustomcode/llm_gateway_config.py,sha256=ECm9CFqOFOaLHwenvVFAjiRSzG9Eg9fY4pb8nHbQ34c,3312
|
|
@@ -85,13 +86,13 @@ datacustomcode/templates/script/examples/employee_hierarchy/employee_data.csv,sh
|
|
|
85
86
|
datacustomcode/templates/script/examples/employee_hierarchy/entrypoint.py,sha256=Mfm3iQtEHTQRW6cmZTwRKdTh3IeGWR-teXrd6x-YLSY,2223
|
|
86
87
|
datacustomcode/templates/script/jupyterlab.sh,sha256=IHR3YQ8d_busuyvesByhJgzCKULIFPI-Hqogs0NPhCs,2432
|
|
87
88
|
datacustomcode/templates/script/payload/config.json,sha256=0d2mEMt4NHIeOUTsgiPMuRKdOLIQxmh-Wq-IfEqU-gc,28
|
|
88
|
-
datacustomcode/templates/script/payload/entrypoint.py,sha256=
|
|
89
|
+
datacustomcode/templates/script/payload/entrypoint.py,sha256=bLUhC4l03H-OQJKdMf11vGXmBnga6QitRXo-g9HibZg,1741
|
|
89
90
|
datacustomcode/templates/script/requirements-dev.txt,sha256=OWwuy1awesqOZOS3Zizmdd6BDnSePpGFN5bq5IrALvc,176
|
|
90
91
|
datacustomcode/templates/script/requirements.txt,sha256=qJbqzs5z0Hrx590U3T7dHq_m8UQEx2TdhgrJSz-QHIQ,40
|
|
91
92
|
datacustomcode/token_provider.py,sha256=KPj_ca6mcBmhXHaPmZjAI4it8QvOWdwKJL8yfqxfYwU,5446
|
|
92
93
|
datacustomcode/version.py,sha256=9LlbVrzwBvut1L308QbwNBgxdQk5CrghH39JARVSxms,989
|
|
93
|
-
salesforce_data_customcode-6.0.
|
|
94
|
-
salesforce_data_customcode-6.0.
|
|
95
|
-
salesforce_data_customcode-6.0.
|
|
96
|
-
salesforce_data_customcode-6.0.
|
|
97
|
-
salesforce_data_customcode-6.0.
|
|
94
|
+
salesforce_data_customcode-6.0.3.dev2.dist-info/METADATA,sha256=jplSGhHPtA0lYdotZM5jQLNH8WFhDRsE5yv5KRDFCYM,21930
|
|
95
|
+
salesforce_data_customcode-6.0.3.dev2.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
96
|
+
salesforce_data_customcode-6.0.3.dev2.dist-info/entry_points.txt,sha256=WpQ94UB7UuRCYGOLtJV3vAgm1tl7iVf43VYRWIuNu5Y,74
|
|
97
|
+
salesforce_data_customcode-6.0.3.dev2.dist-info/licenses/LICENSE.txt,sha256=iOi8EmQpfkFhMENi7VYtkl2EqS14pEOccoXHiW2dyPU,11443
|
|
98
|
+
salesforce_data_customcode-6.0.3.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|