Class HuggingfaceAiClient
java.lang.Object
org.springframework.ai.huggingface.client.HuggingfaceAiClient
- All Implemented Interfaces:
AiClient
An implementation of
AiClient
that interfaces with HuggingFace Inference
Endpoints for text generation.- Author:
- Mark Pollack
-
Constructor Summary
ConstructorDescriptionHuggingfaceAiClient
(String apiToken, String basePath) Constructs a new HuggingfaceAiClient with the specified API token and base path. -
Method Summary
Modifier and TypeMethodDescriptionGenerate text based on the provided prompt.int
Gets the maximum number of new tokens to be generated.void
setMaxNewTokens
(int maxNewTokens) Sets the maximum number of new tokens to be generated.
-
Constructor Details
-
HuggingfaceAiClient
Constructs a new HuggingfaceAiClient with the specified API token and base path.- Parameters:
apiToken
- The API token for HuggingFace.basePath
- The base path for API requests.
-
-
Method Details
-
generate
Generate text based on the provided prompt. -
getMaxNewTokens
public int getMaxNewTokens()Gets the maximum number of new tokens to be generated.- Returns:
- The maximum number of new tokens.
-
setMaxNewTokens
public void setMaxNewTokens(int maxNewTokens) Sets the maximum number of new tokens to be generated.- Parameters:
maxNewTokens
- The maximum number of new tokens.
-