salesforce-data-customcode 5.0.0.dev1__py3-none-any.whl → 6.0.0__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/einstein_platform_client.py +27 -4
- datacustomcode/einstein_predictions/impl/default.py +1 -1
- datacustomcode/io/writer/base.py +11 -1
- datacustomcode/llm_gateway/default.py +1 -1
- datacustomcode/templates/function/.devcontainer/devcontainer.json +1 -1
- datacustomcode/templates/script/.devcontainer/devcontainer.json +1 -1
- {salesforce_data_customcode-5.0.0.dev1.dist-info → salesforce_data_customcode-6.0.0.dist-info}/METADATA +7 -1
- {salesforce_data_customcode-5.0.0.dev1.dist-info → salesforce_data_customcode-6.0.0.dist-info}/RECORD +11 -11
- {salesforce_data_customcode-5.0.0.dev1.dist-info → salesforce_data_customcode-6.0.0.dist-info}/WHEEL +0 -0
- {salesforce_data_customcode-5.0.0.dev1.dist-info → salesforce_data_customcode-6.0.0.dist-info}/entry_points.txt +0 -0
- {salesforce_data_customcode-5.0.0.dev1.dist-info → salesforce_data_customcode-6.0.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
import os
|
|
16
17
|
from typing import (
|
|
17
18
|
Any,
|
|
18
19
|
Dict,
|
|
@@ -30,10 +31,6 @@ from datacustomcode.token_provider import (
|
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
class EinsteinPlatformClient:
|
|
33
|
-
EINSTEIN_PLATFORM_MODELS_URL = (
|
|
34
|
-
"https://api.salesforce.com/einstein/platform/v1/models"
|
|
35
|
-
)
|
|
36
|
-
|
|
37
34
|
def __init__(
|
|
38
35
|
self,
|
|
39
36
|
credentials_profile: Optional[str] = None,
|
|
@@ -48,8 +45,34 @@ class EinsteinPlatformClient:
|
|
|
48
45
|
self._token_provider = CredentialsTokenProvider(profile)
|
|
49
46
|
logger.debug(f"Using credentials token provider with profile: {profile}")
|
|
50
47
|
self.token_response = None
|
|
48
|
+
self._einstein_url_cache: Optional[str] = None
|
|
51
49
|
super().__init__(**kwargs)
|
|
52
50
|
|
|
51
|
+
def _get_einstein_platform_url(self) -> str:
|
|
52
|
+
if self._einstein_url_cache is not None:
|
|
53
|
+
return self._einstein_url_cache
|
|
54
|
+
|
|
55
|
+
env = os.environ.get("SFDC_EINSTEIN_API_ENV", "prod").lower()
|
|
56
|
+
if env not in ("dev", "test", "stage", "prod"):
|
|
57
|
+
logger.warning(
|
|
58
|
+
f"Unknown SFDC_EINSTEIN_API_ENV value '{env}', defaulting to prod"
|
|
59
|
+
)
|
|
60
|
+
env = "prod"
|
|
61
|
+
|
|
62
|
+
base_url = self._get_base_url_for_env(env)
|
|
63
|
+
logger.info(f"Using Einstein Platform API endpoint: {base_url} (env={env})")
|
|
64
|
+
self._einstein_url_cache = f"{base_url}/einstein/platform/v1/models"
|
|
65
|
+
return self._einstein_url_cache
|
|
66
|
+
|
|
67
|
+
def _get_base_url_for_env(self, env: str) -> str:
|
|
68
|
+
env_map = {
|
|
69
|
+
"dev": "https://dev.api.salesforce.com",
|
|
70
|
+
"test": "https://test.api.salesforce.com",
|
|
71
|
+
"stage": "https://stage.api.salesforce.com",
|
|
72
|
+
"prod": "https://api.salesforce.com",
|
|
73
|
+
}
|
|
74
|
+
return env_map.get(env, "https://api.salesforce.com")
|
|
75
|
+
|
|
53
76
|
def _get_headers(self):
|
|
54
77
|
if self.token_response is None:
|
|
55
78
|
self.token_response = self._token_provider.get_token()
|
|
@@ -48,7 +48,7 @@ class DefaultEinsteinPredictions(EinsteinPlatformClient, EinsteinPredictions):
|
|
|
48
48
|
)
|
|
49
49
|
|
|
50
50
|
api_url = (
|
|
51
|
-
f"{self.
|
|
51
|
+
f"{self._get_einstein_platform_url()}/{request.model_api_name}/{endpoint}"
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
prediction_columns: List[Dict[str, Any]] = []
|
datacustomcode/io/writer/base.py
CHANGED
|
@@ -27,11 +27,21 @@ if TYPE_CHECKING:
|
|
|
27
27
|
class WriteMode(str, Enum):
|
|
28
28
|
APPEND = "append"
|
|
29
29
|
OVERWRITE = "overwrite"
|
|
30
|
-
OVERWRITE_PARTITIONS = "overwrite_partitions"
|
|
30
|
+
OVERWRITE_PARTITIONS = "overwrite_partitions" # Deprecated: raises error if used
|
|
31
31
|
MERGE = "merge"
|
|
32
32
|
MERGE_UPSERT_DELETE = "merge_upsert_delete"
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
class MergeRecordType(str, Enum):
|
|
36
|
+
"""Values for the _merge_record_type column used by MERGE_UPSERT_DELETE."""
|
|
37
|
+
|
|
38
|
+
UPSERT = "UPSERT"
|
|
39
|
+
DELETE = "DELETE"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
MERGE_RECORD_TYPE_COLUMN = "_merge_record_type"
|
|
43
|
+
|
|
44
|
+
|
|
35
45
|
class BaseDataCloudWriter(BaseDataAccessLayer):
|
|
36
46
|
"""Base class for Data Cloud writers."""
|
|
37
47
|
|
|
@@ -29,7 +29,7 @@ class DefaultLLMGateway(EinsteinPlatformClient, LLMGateway):
|
|
|
29
29
|
|
|
30
30
|
def generate_text(self, request: GenerateTextRequest) -> GenerateTextResponse:
|
|
31
31
|
api_url = (
|
|
32
|
-
f"{self.
|
|
32
|
+
f"{self._get_einstein_platform_url()}/{request.model_name}/generations"
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
payload: Dict[str, Any] = {"prompt": request.prompt}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: salesforce-data-customcode
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: Data Cloud Custom Code SDK
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -254,12 +254,18 @@ Instead of using `datacustomcode configure`, you can also set credentials via en
|
|
|
254
254
|
| `SFDC_REFRESH_TOKEN` | OAuth refresh token |
|
|
255
255
|
| `SFDC_ACCESS_TOKEN` | (Optional) OAuth core/access token |
|
|
256
256
|
|
|
257
|
+
**Einstein Platform API Environment (Optional):**
|
|
258
|
+
| Variable | Description |
|
|
259
|
+
|----------|-------------|
|
|
260
|
+
| `SFDC_EINSTEIN_API_ENV` | Einstein Platform API environment: `dev`, `test`, `stage`, or `prod`. If not set, automatically inferred from login URL. Set this explicitly if auto-detection fails. |
|
|
261
|
+
|
|
257
262
|
Example usage:
|
|
258
263
|
```bash
|
|
259
264
|
export SFDC_LOGIN_URL="https://login.salesforce.com"
|
|
260
265
|
export SFDC_CLIENT_ID="your_client_id"
|
|
261
266
|
export SFDC_CLIENT_SECRET="your_client_secret"
|
|
262
267
|
export SFDC_REFRESH_TOKEN="your_refresh_token"
|
|
268
|
+
export SFDC_EINSTEIN_API_ENV="test" # optional
|
|
263
269
|
|
|
264
270
|
datacustomcode run ./payload/entrypoint.py
|
|
265
271
|
```
|
|
@@ -9,11 +9,11 @@ datacustomcode/config.yaml,sha256=iMs3HPMLHwnesJ9KRD0-CpJqtHRehQvq2w2od9uE0aU,77
|
|
|
9
9
|
datacustomcode/constants.py,sha256=SskQpUPnQE7LjKh4Z3AdZ2p191_0Kf73jV8gdBXDPLU,1436
|
|
10
10
|
datacustomcode/credentials.py,sha256=D-7Zd3Nh_wStdj8_wUy5cnC8M_mdbfBijhIAi-2EbXs,9467
|
|
11
11
|
datacustomcode/deploy.py,sha256=9yaekNew5ha6bd6rIFERknFROomOeIfikrKXN6jCoq4,18811
|
|
12
|
-
datacustomcode/einstein_platform_client.py,sha256=
|
|
12
|
+
datacustomcode/einstein_platform_client.py,sha256=ON2B_m--vdbCVVMVcLc81T-BRZ5-UuxVCer8E6OEQPA,4083
|
|
13
13
|
datacustomcode/einstein_platform_config.py,sha256=EYnAKz0z1hNN9A8GHtaYm-Ek4GqUi68iYrJ1TSR-J9w,1416
|
|
14
14
|
datacustomcode/einstein_predictions/__init__.py,sha256=o-iask36phwGA7hGi_sxJpwbITO6h_STDe0J92qD2_M,859
|
|
15
15
|
datacustomcode/einstein_predictions/base.py,sha256=OBV445dpZRtCF5cpdHH49w_6RU_jZY1A-e7VtHTQCFU,1061
|
|
16
|
-
datacustomcode/einstein_predictions/impl/default.py,sha256=
|
|
16
|
+
datacustomcode/einstein_predictions/impl/default.py,sha256=fEFhrosozhG0yT87w4Gu8wbe1NgHxBqdAduwWHdWGN4,3011
|
|
17
17
|
datacustomcode/einstein_predictions/types.py,sha256=W7H3sFzm_NdBtnia7O576w0OvM7jwzfGVQmFiZTO8Og,6098
|
|
18
18
|
datacustomcode/einstein_predictions_config.py,sha256=dwY3Q5MFBHm60lL27m-Srt5BpcURc_PuKpaW-ALOqw4,2131
|
|
19
19
|
datacustomcode/file/__init__.py,sha256=gamfOD1VnAtEslRBpqh-yKiVjkG_wYWYdSatGIfsN-w,621
|
|
@@ -34,12 +34,12 @@ datacustomcode/io/reader/query_api.py,sha256=eVrohrcnTnhSMsGfPRHu5XltjFtGG0hyHt1
|
|
|
34
34
|
datacustomcode/io/reader/sf_cli.py,sha256=x5QacVqRZaZSyph1_wwxo67s8r29wsOcUsOaiF9cDWE,6324
|
|
35
35
|
datacustomcode/io/reader/utils.py,sha256=HlHhPZoHfmWA3mF8kTnd3m4Nd2exaz4NsOJJfQY7Pew,1656
|
|
36
36
|
datacustomcode/io/writer/__init__.py,sha256=gamfOD1VnAtEslRBpqh-yKiVjkG_wYWYdSatGIfsN-w,621
|
|
37
|
-
datacustomcode/io/writer/base.py,sha256=
|
|
37
|
+
datacustomcode/io/writer/base.py,sha256=6e2Yszb6BiuN1zCV2rjvZ5CQ0YikQdUgdYAkutoy9pE,1787
|
|
38
38
|
datacustomcode/io/writer/csv.py,sha256=asty5teBpNQ1fMGHZ7wA3suLhq0sk0lVQPN5x7TOSRk,1555
|
|
39
39
|
datacustomcode/io/writer/print.py,sha256=0g2sP_1Wb95UIyEELWJt3dqM18Iv_CWhDW3mDxcIhns,5105
|
|
40
40
|
datacustomcode/llm_gateway/__init__.py,sha256=xT7J9qZByD80WWk-835JcJSvQx8_NiX6qsBPhq7mU6k,800
|
|
41
41
|
datacustomcode/llm_gateway/base.py,sha256=CTUhZiZ0JFlmWj6kQpTR4_-mUvqkBKl_Fkdvv9VwxY8,1262
|
|
42
|
-
datacustomcode/llm_gateway/default.py,sha256=
|
|
42
|
+
datacustomcode/llm_gateway/default.py,sha256=QiwrDaUvrh00I-fYYhmogTtqC5r0fmm-JrXxNQLvTc0,1854
|
|
43
43
|
datacustomcode/llm_gateway/types/__init__.py,sha256=gamfOD1VnAtEslRBpqh-yKiVjkG_wYWYdSatGIfsN-w,621
|
|
44
44
|
datacustomcode/llm_gateway/types/generate_text_request.py,sha256=ChxOCzp7St1EYgwl4tWiwfrPyVci4zPyBhnEjWc1Vfs,1448
|
|
45
45
|
datacustomcode/llm_gateway/types/generate_text_request_builder.py,sha256=R4hCgatMPSfWYqaOmeC1IMQj753iDgu7wU992c4tkmk,2565
|
|
@@ -59,7 +59,7 @@ datacustomcode/spark/base.py,sha256=tlGqM4LxuLoDa7OxJF5nVeb7phO5uvD1DHBQeH7NMMs,
|
|
|
59
59
|
datacustomcode/spark/default.py,sha256=aMB8CaTPYwHbQE_7XqBLQUZPGRdDJcRL72qTVh0aG7M,1433
|
|
60
60
|
datacustomcode/template.py,sha256=FNNi8YPfd-JB-hUt1DDWSFK5AqwKnTnRSy_KpqYluaU,3282
|
|
61
61
|
datacustomcode/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
62
|
-
datacustomcode/templates/function/.devcontainer/devcontainer.json,sha256=
|
|
62
|
+
datacustomcode/templates/function/.devcontainer/devcontainer.json,sha256=21RNTadhC-rynON2-VOtr5U174Hxnr_MA4RQ4592rsg,166
|
|
63
63
|
datacustomcode/templates/function/Dockerfile.dependencies,sha256=AfHRddm5l3ujv4vdrf0d-SMB-qxPCOa0XQm6ptP2Euw,174
|
|
64
64
|
datacustomcode/templates/function/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
65
65
|
datacustomcode/templates/function/build_native_dependencies.sh,sha256=dk9vhzlObdsFAO5BtxP7ioOGDBM8JVwJHp_W0712Nlk,222
|
|
@@ -77,7 +77,7 @@ datacustomcode/templates/function/payload/config.json,sha256=RBNvo1WzZ4oRRq0W9-h
|
|
|
77
77
|
datacustomcode/templates/function/payload/entrypoint.py,sha256=DrH73aAkU_ua6IHBRYr9SkMtX5pEFvNJYew8zXQL5TQ,5705
|
|
78
78
|
datacustomcode/templates/function/requirements-dev.txt,sha256=qT2-m2FOgiYPTvqaNy0yRzIAXqHgR5b8stccYXsXVi8,88
|
|
79
79
|
datacustomcode/templates/function/requirements.txt,sha256=qJbqzs5z0Hrx590U3T7dHq_m8UQEx2TdhgrJSz-QHIQ,40
|
|
80
|
-
datacustomcode/templates/script/.devcontainer/devcontainer.json,sha256=
|
|
80
|
+
datacustomcode/templates/script/.devcontainer/devcontainer.json,sha256=21RNTadhC-rynON2-VOtr5U174Hxnr_MA4RQ4592rsg,166
|
|
81
81
|
datacustomcode/templates/script/Dockerfile,sha256=l8HEy5X7BsW9Gi7rBYM6G2czwk-1832RRIos7xyFzpI,463
|
|
82
82
|
datacustomcode/templates/script/Dockerfile.dependencies,sha256=vBbTfgcBkVQVCnrJZE_QEx89ddTQrLZGeyVTZXU8TI8,206
|
|
83
83
|
datacustomcode/templates/script/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -92,8 +92,8 @@ datacustomcode/templates/script/requirements-dev.txt,sha256=OWwuy1awesqOZOS3Zizm
|
|
|
92
92
|
datacustomcode/templates/script/requirements.txt,sha256=qJbqzs5z0Hrx590U3T7dHq_m8UQEx2TdhgrJSz-QHIQ,40
|
|
93
93
|
datacustomcode/token_provider.py,sha256=KPj_ca6mcBmhXHaPmZjAI4it8QvOWdwKJL8yfqxfYwU,5446
|
|
94
94
|
datacustomcode/version.py,sha256=9LlbVrzwBvut1L308QbwNBgxdQk5CrghH39JARVSxms,989
|
|
95
|
-
salesforce_data_customcode-
|
|
96
|
-
salesforce_data_customcode-
|
|
97
|
-
salesforce_data_customcode-
|
|
98
|
-
salesforce_data_customcode-
|
|
99
|
-
salesforce_data_customcode-
|
|
95
|
+
salesforce_data_customcode-6.0.0.dist-info/METADATA,sha256=9NC9AsBkRbD3T_cvBKgC5jAf1RHCzPvnwmbTlshJdzE,20162
|
|
96
|
+
salesforce_data_customcode-6.0.0.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
97
|
+
salesforce_data_customcode-6.0.0.dist-info/entry_points.txt,sha256=WpQ94UB7UuRCYGOLtJV3vAgm1tl7iVf43VYRWIuNu5Y,74
|
|
98
|
+
salesforce_data_customcode-6.0.0.dist-info/licenses/LICENSE.txt,sha256=iOi8EmQpfkFhMENi7VYtkl2EqS14pEOccoXHiW2dyPU,11443
|
|
99
|
+
salesforce_data_customcode-6.0.0.dist-info/RECORD,,
|
{salesforce_data_customcode-5.0.0.dev1.dist-info → salesforce_data_customcode-6.0.0.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|