You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the design pattern used for llm gateway generate text (PR #105),
add Einstein predict support to the public SDK Script API in two flavors:
1. One-shot scalar method: Client.einstein_predict(...) returns the
prediction response payload as a dict.
2. Per-row column method: einstein_predict_col(...) builds a Spark Column
that invokes predict per row and yields a struct
{status, response, error_code, error_message}, so a single failing row
does not abort the Spark job. response carries the prediction payload as
a JSON string.
Both wrap the existing DefaultEinsteinPredictions resource, which calls
SFAP over HTTP/REST when testing outside Data Cloud.
- Add SparkEinsteinPredictions base + DefaultSparkEinsteinPredictions impl
- Add EinsteinPredictionsCallError
- Add SparkEinsteinPredictionsConfig + config.yaml wiring
- Wire Client scalar/column methods and top-level exports
- Update README and script template with usage examples
- Add unit tests
# One-shot scalar prediction returns the response payload as a dict
407
+
prediction = client.einstein_predict(
408
+
"my_regression_model",
409
+
PredictionType.REGRESSION,
410
+
{"square_feet": 1800, "beds": 3},
411
+
)
412
+
413
+
if __name__ == "__main__":
414
+
main()
415
+
```
416
+
417
+
Testing this code locally uses the same External Client App setup described in
418
+
[Testing LLM Gateway](#testing-llm-gateway). Once your `myorg` alias is set up,
419
+
run:
420
+
```
421
+
datacustomcode run ./payload/entrypoint.py --sf-cli-org myorg
422
+
```
423
+
424
+
375
425
## Docker usage
376
426
377
427
The SDK provides Docker-based development options that allow you to test your code in an environment that closely resembles Data Cloud's execution environment.
0 commit comments