opener synthesis
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-30 13:53:31 -05:00
parent c2ddc5818d
commit 524c37895b
8 changed files with 70 additions and 10 deletions

View File

@ -7,13 +7,7 @@ sitting in a tavern by a fireplace
Respond to "Hello" with "Hello. What is your name?"
- Multiple sentences in synthesizer
- Progressive goals while synthesizing (update goals after each synthesis)
- Multiple sentences per quote
- Move eval to being evaluation-per-sentence
- "Small Talk" conversation goal
- Bank of questions to ask in small talk evaluator

View File

@ -21,6 +21,11 @@ public class GoalData {
* Answer a question
*/
ANSWER,
/**
* Prompt a conversation-opening question
*/
OPENER,
}
/**

View File

@ -22,13 +22,19 @@ public class GoalEval {
//evaluate if goal should be to greet
if(!greetingData.getHaveGreeted().contains(conversation.getSelf())){
conversation.getGoalData().setGoal(ConversationGoal.GREET);
goalData.setGoal(ConversationGoal.GREET);
return;
}
//evaluate if goal should be to answer a question
if(queryData.getRecentQueries().size() > 0){
conversation.getGoalData().setGoal(ConversationGoal.ANSWER);
goalData.setGoal(ConversationGoal.ANSWER);
return;
}
//try to open a conversation with a question
if(SmallTalkEval.shouldPursueSmalltalk(goalData)){
goalData.setGoal(ConversationGoal.OPENER);
return;
}

View File

@ -0,0 +1,18 @@
package org.studiorailgun.conversation.evaluators.goal;
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
/**
* "Small talk" evaluation
*/
public class SmallTalkEval {
/**
* Checks if the agent should try to produce conversation openers
* @return true if should, false otherwise
*/
public static boolean shouldPursueSmalltalk(GoalData goalData){
return goalData.getGoal() != ConversationGoal.OPENER;
}
}

View File

@ -50,7 +50,7 @@ public class GreetingEval {
* @return The greeting
*/
public static Sentence constructGreeting(Conversation conversation){
Sentence response = new Sentence("Hello");
Sentence response = new Sentence("Hello.");
return response;
}

View File

@ -0,0 +1,32 @@
package org.studiorailgun.conversation.evaluators.opener;
import org.studiorailgun.conversation.evaluators.goal.GoalData;
import org.studiorailgun.conversation.tracking.Conversation;
import org.studiorailgun.conversation.tracking.Sentence;
/**
* Conversation opener synthesis evaluation
*/
public class OpenerSynthesis {
/**
* Synthesizes a conversation opener question
* @param conversation The conversation
* @return The quote
*/
public static Sentence synthesize(Conversation conversation){
Sentence response = null;
GoalData goalData = conversation.getGoalData();
switch(goalData.getGoal()){
case OPENER: {
response = new Sentence("What is your name?");
} break;
case ANSWER:
case GREET: {
throw new Error("Unsupported goal type for information transfer! " + goalData.getGoal());
}
}
return response;
}
}

View File

@ -1,6 +1,7 @@
package org.studiorailgun.conversation.evaluators.synthesis;
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
import org.studiorailgun.conversation.evaluators.opener.OpenerSynthesis;
import org.studiorailgun.conversation.evaluators.transfer.TransferEval;
import org.studiorailgun.conversation.tracking.Conversation;
import org.studiorailgun.conversation.tracking.Sentence;
@ -25,6 +26,9 @@ public class ResponseEval {
case ANSWER: {
response = TransferEval.synthesize(conversation);
} break;
case OPENER: {
response = OpenerSynthesis.synthesize(conversation);
} break;
default: {
throw new UnsupportedOperationException("Unsupported conversation goal! " + conversation.getGoalData().getGoal());
}

View File

@ -23,6 +23,7 @@ public class TransferEval {
Sentence questionToAnswer = goalData.getQueryData().getRecentQueries().remove(0);
response = AnswerSynthesis.evaluate(conversation, questionToAnswer.getParent(), questionToAnswer);
} break;
case OPENER:
case GREET: {
throw new Error("Unsupported goal type for information transfer! " + goalData.getGoal());
}