Package edu.tufts.hrilab.llm.hf
Class LLMServiceProvider
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.llm.hf.LLMServiceProvider
- All Implemented Interfaces:
NLGInterface
- Direct Known Subclasses:
SpotPickAndPlaceLLMServiceProvider
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidendLLMChatContext(org.apache.commons.lang3.tuple.Pair<Symbol, Symbol> members) voidendLLMConversation(Symbol speaker, Symbol agentTeam) End shared dialogue history between a user and an AgentTeamvoidendLLMConversation(Set<Symbol> members) End shared dialogue history between a set of entitiesvoidendLLMConversation(Set<Symbol> members, Integer id) voidendLLMConversation(Set<Symbol> speakers, Set<Symbol> agentTeams) End a shared dialogue history between a set of users and a set of AgentTeamsprotected voidThis is where any code that needs to be called repeatedly in a dedicated thread should live.protected abstract ChatgenerateNLGChat(Utterance utterance, List<Utterance> conversationHistory) Generate a Chat object to call LLM's chatCompletion service with for the generation task.protected abstract ChatgenerateNLUChat(Utterance utterance, Chat currentChat, List<Utterance> conversationHistory) Generate a Chat object to call LLM's chatCompletion service with for the parsing task.getDescendants(Symbol agentTeam) protected Symbolprotected voidinit()Perform any component initialization.llmGenerationService(Utterance utterance) protected abstract UtteranceparseNLGCompletionResponse(Utterance outgoingUtterance, Completion llmResponse) Postprocessing of LLM's chatCompletion return value for the NLG task.protected abstract UtteranceparseNLUCompletionResponse(Utterance incomingUtterance, Completion llmResponse) Postprocessing of LLM's chatCompletion return value for the NLU task.parseUtterance(Utterance utterance) voidstartLLMConversation(Symbol speaker, Symbol agentTeam) Start shared dialogue history between a user and an AgentTeamstartLLMConversation(Set<Symbol> members) Start shared dialogue history between a set of entitiesstartLLMConversation(Set<Symbol> speakers, Set<Symbol> agentTeams) Start a shared dialogue history between a set of users and a set of AgentTeamsvoidvoidupdateLLMConversationHistory(Utterance utterance) Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
additionalUsageInfo, attachShutdownHook, createInstance, createInstance, createInstance, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, parseArgs, postRegistrationInit, shutdown, shutdownComponent
-
Constructor Details
-
LLMServiceProvider
public LLMServiceProvider()
-
-
Method Details
-
generateNLGChat
Generate a Chat object to call LLM's chatCompletion service with for the generation task. Practically entails generating a system and user message for an NLG request of the supplied utterance.- Parameters:
utterance- outgoing utterance to perform NLG forconversationHistory- Relevant dialogue history leading up to this outgoing utterance which may provide context.- Returns:
- Fully updated Chat object to pass to an LLM's chatCompletion service for NLG
-
generateNLUChat
protected abstract Chat generateNLUChat(Utterance utterance, Chat currentChat, List<Utterance> conversationHistory) Generate a Chat object to call LLM's chatCompletion service with for the parsing task. Practically entails creating a new or updating an existing Chat object to contain the proper system, user, and assistant messages to come up with a proper parse of the supplied utterance.- Parameters:
utterance- incoming utterance to be parsedcurrentChat- Chat object containing prior requests and responses between the LLM for this current parse attempt. Null if this is the first interaction.conversationHistory- Relevant dialogue history leading up to this incoming utterance which may provide context.- Returns:
- Fully updated Chat object to pass to an LLM's chatCompletion service for parsing
-
parseNLUCompletionResponse
protected abstract Utterance parseNLUCompletionResponse(Utterance incomingUtterance, Completion llmResponse) Postprocessing of LLM's chatCompletion return value for the NLU task.- Returns:
- The fully populated Utterance to return from parseUtterance
-
parseNLGCompletionResponse
protected abstract Utterance parseNLGCompletionResponse(Utterance outgoingUtterance, Completion llmResponse) Postprocessing of LLM's chatCompletion return value for the NLG task.- Returns:
- The fully populated Utterance to return convertSemanticsToText.
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
executionLoop
protected void executionLoop()Description copied from class:DiarcComponentThis is where any code that needs to be called repeatedly in a dedicated thread should live. It is not called by default and you must set shouldRunExecutionLoop to true in your constructor.- Overrides:
executionLoopin classDiarcComponent
-
convertSemanticsToText
- Specified by:
convertSemanticsToTextin interfaceNLGInterface
-
parseUtterance
-
llmGenerationService
-
updateLLMConversationHistory
-
startLLMConversation
Start shared dialogue history between a user and an AgentTeam -
startLLMConversation
Start a shared dialogue history between a set of users and a set of AgentTeams -
startLLMConversation
Start shared dialogue history between a set of entities -
endLLMConversation
End shared dialogue history between a user and an AgentTeam -
endLLMConversation
End a shared dialogue history between a set of users and a set of AgentTeams -
endLLMConversation
End shared dialogue history between a set of entities -
endLLMConversation
-
startLLMChatContext
-
endLLMChatContext
-
getDescendants
-
getUntypedSymbol
-
clearConversationHistory
public void clearConversationHistory() -
toggleLLMNLG
public void toggleLLMNLG()
-