Package ai.chalk.client
Class GRPCClient
java.lang.Object
ai.chalk.client.GRPCClient
- All Implemented Interfaces:
ChalkClient,AutoCloseable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface ai.chalk.client.ChalkClient
ChalkClient.Builder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()onlineQuery(OnlineQueryParamsComplete params) OnlineQuery computes features values using online resolvers.voidPrints the current ChalkClient configuration and its sources to stdout.uploadFeatures(UploadFeaturesParams params) UploadFeatures synchronously persists feature values to the online store and offline store.
-
Constructor Details
-
GRPCClient
- Throws:
ChalkException
-
GRPCClient
- Throws:
ChalkException
-
-
Method Details
-
printConfig
public void printConfig()Description copied from interface:ChalkClientPrints the current ChalkClient configuration and its sources to stdout.- Specified by:
printConfigin interfaceChalkClient
-
onlineQuery
Description copied from interface:ChalkClientOnlineQuery computes features values using online resolvers.See
OnlineQueryParamsfor more details on the parameters.Example usage for bulk queries:
{@code OnlineQueryParamsComplete params = OnlineQueryParams.builder() .withInput("user.id", Arrays.asList(1, 2, 3)) .withOutputs("user.email", "user.transactions") .build(); try (OnlineQueryResult result = client.onlineQuery(params)) { // do something with the result } </pre> </p> <p> Example usage for single-row queries using SingleRowInput: <pre> {@code var singleRow = new OnlineQueryParams.SingleRowInput() .withInput("user.id", 123) .withInput("user.email", "test@example.com") .withInput("user.favorite_foods", Arrays.asList("pizza", "pasta")); OnlineQueryParamsComplete params = OnlineQueryParams.builder() .withInput(singleRow) .withOutputs("user.credit_score", "user.transactions") .build(); try (OnlineQueryResult result = client.onlineQuery(params)) { // do something with the result } </pre> </p> @return {@link OnlineQueryResult } @throws ChalkException @see <a href="https://docs.chalk.ai/docs/query-basics">query basics</a>- Specified by:
onlineQueryin interfaceChalkClient- Throws:
ChalkException
-
uploadFeatures
Description copied from interface:ChalkClientUploadFeatures synchronously persists feature values to the online store and offline store.See
UploadFeaturesParamsfor more details on the parameters.Example usage:
{@code var userIds = Arrays.asList("777", "888", "999"); var scoreList = Arrays.asList(600, 700, 800); UploadFeaturesParams params = UploadFeaturesParams.builder() .withInputs(Map.of("user.id", userIds,"user.credit_score", scoreList)) .withInput(Features.user.email, List.of("user1@email.com", "user2@email.com", "user3@email.com")) .build(); UploadFeaturesResult res = client.uploadFeatures(params); if (client.uploadFeatures(params).getErrors().size() > 0) { throw new Exception("upload failed"); } </pre> </p>- Specified by:
uploadFeaturesin interfaceChalkClient- Throws:
ChalkException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-