Package edu.tufts.hrilab.llm.hf
Class HFClient
java.lang.Object
edu.tufts.hrilab.llm.hf.HFClient
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionllamaHFChatCompletion(Symbol userPrompt) Generates a chat completion using the LLaMA HuggingFace Inference Endpoint and a prompt string.llamaHFChatCompletion(Symbol userPrompt, Symbol systemPrompt) llamaHFChatCompletion(Symbol userPrompt, Symbol systemPrompt, String model) llamaHFChatCompletion(Chat chat) Performs a chat completion using LLaMA with the set model and the given chat messages.llamaHFChatCompletion(Chat chat, Symbol model) llamaHFChatCompletion(Chat chat, String model) llamaHFChatCompletion(LlamaHFCompletionRequestBody requestBody) llamaHFChatCompletion(LlamaHFCompletionRequestBody requestBody, String model) llamaHFChatCompletion(String userPrompt) llamaHFChatCompletion(String userPrompt, String systemPrompt) llamaHFChatCompletion(String userPrompt, String systemPrompt, String model) llamaHFChatCompletion(List<Message> messages) voidsetMaxNewTokens(int maxNewTokens) Sets the max number of tokens included in the response (Not including the provided prompt)voidvoidsetTemperature(float temperatureFloat) Sets the temperature of the model.t5BaseCompletion(T5BaseCompletionRequestBody requestBody) t5BaseCompletion(T5BaseCompletionRequestBody requestBody, String model) Sends a Llama completion request with the given model and request body, and returns the completion response.t5BaseCompletion(String prompt) t5BaseCompletion(String prompt, String model)
-
Field Details
-
service
-
model
-
-
Constructor Details
-
HFClient
public HFClient()
-
-
Method Details
-
setModel
-
t5BaseCompletion
-
t5BaseCompletion
-
t5BaseCompletion
-
t5BaseCompletion
public T5BaseCompletionResponse t5BaseCompletion(T5BaseCompletionRequestBody requestBody, String model) Sends a Llama completion request with the given model and request body, and returns the completion response. https://github.com/ggerganov/llama.cpp/tree/master/examples/server- Parameters:
requestBody- the request body containing the prompt and other parameters for the completion request- Returns:
- the completion response from the TextSynth API
-
setTemperature
public void setTemperature(float temperatureFloat) Sets the temperature of the model.- Parameters:
temperatureFloat- - The temperature value to set
-
setMaxNewTokens
public void setMaxNewTokens(int maxNewTokens) Sets the max number of tokens included in the response (Not including the provided prompt)- Parameters:
maxNewTokens- - The number of tokens to set
-
llamaHFChatCompletion
Generates a chat completion using the LLaMA HuggingFace Inference Endpoint and a prompt string.- Parameters:
userPrompt- the prompt string provided by the user- Returns:
- the LlamaHFChatCompletionResponse containing the completed chat.
-
llamaHFChatCompletion
-
llamaHFChatCompletion
public LlamaHFChatCompletionResponse llamaHFChatCompletion(Symbol userPrompt, Symbol systemPrompt, String model) -
llamaHFChatCompletion
-
llamaHFChatCompletion
-
llamaHFChatCompletion
public LlamaHFChatCompletionResponse llamaHFChatCompletion(String userPrompt, String systemPrompt, String model) -
llamaHFChatCompletion
-
llamaHFChatCompletion
Performs a chat completion using LLaMA with the set model and the given chat messages.- Parameters:
chat- the chat containing the messages to use for the completion- Returns:
- an LlamaHFChatCompletionResponse object representing the response from LLaMA
-
llamaHFChatCompletion
-
llamaHFChatCompletion
-
llamaHFChatCompletion
public LlamaHFChatCompletionResponse llamaHFChatCompletion(LlamaHFCompletionRequestBody requestBody) -
llamaHFChatCompletion
public LlamaHFChatCompletionResponse llamaHFChatCompletion(LlamaHFCompletionRequestBody requestBody, String model)
-