response synthesis

This commit is contained in:
austin 2024-12-29 12:16:23 -05:00
parent a9f72dbb19
commit 0b951b3ef6
10 changed files with 62 additions and 10 deletions

View File

@ -12,10 +12,10 @@ public class AI {
* Simulates a frame of the ai
* @param input The raw input text
*/
public static void simFrame(String input){
public static Quote simFrame(String input){
Quote playerQuote = new Quote(input);
//handle ai statement
EvaluationTree.evaluate(Globals.conversation, playerQuote);
return EvaluationTree.evaluate(Globals.conversation, playerQuote);
}
}

View File

@ -3,7 +3,7 @@ package org.studiorailgun;
import java.io.File;
import org.studiorailgun.conversation.Conversation;
import org.studiorailgun.conversation.evaluators.GreetingEval;
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
import org.studiorailgun.knowledge.KnowledgeWeb;
/**

View File

@ -35,7 +35,8 @@ public class AgentLoop {
if(CommandParser.parseCommands(prompt)){
continue;
}
AI.simFrame(prompt);
Quote response = AI.simFrame(prompt);
System.out.println(response.getRaw());
}
}
}

View File

@ -1,7 +1,7 @@
package org.studiorailgun.conversation;
import org.studiorailgun.conversation.evaluators.GreetingData;
import org.studiorailgun.conversation.evaluators.goal.GoalData;
import org.studiorailgun.conversation.evaluators.greet.GreetingData;
import org.studiorailgun.knowledge.KnowledgeWeb;
import org.studiorailgun.knowledge.Node;

View File

@ -4,6 +4,8 @@ import org.studiorailgun.conversation.Conversation;
import org.studiorailgun.conversation.Quote;
import org.studiorailgun.conversation.categorization.SentenceFunctionCategorizor;
import org.studiorailgun.conversation.evaluators.goal.GoalEval;
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
import org.studiorailgun.conversation.evaluators.synthesis.ResponseEval;
/**
* Evaluates a sentence based on data about the sentence
@ -14,7 +16,7 @@ public class EvaluationTree {
* Evaluates a quote
* @param quote The quote
*/
public static void evaluate(Conversation conversation, Quote quote){
public static Quote evaluate(Conversation conversation, Quote quote){
//parse data about the quote
SentenceFunctionCategorizor.categorize(quote);
@ -32,7 +34,9 @@ public class EvaluationTree {
GoalEval.evaluate(conversation);
//synthesize language based on the results of the actions performed
//TODO
Quote response = ResponseEval.evaluate(conversation);
return response;
}
}

View File

@ -2,8 +2,8 @@ package org.studiorailgun.conversation.evaluators.goal;
import org.studiorailgun.conversation.ConvParticipant;
import org.studiorailgun.conversation.Conversation;
import org.studiorailgun.conversation.evaluators.GreetingData;
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
import org.studiorailgun.conversation.evaluators.greet.GreetingData;
/**
* Evaluates the AI's goal in the conversation

View File

@ -1,4 +1,4 @@
package org.studiorailgun.conversation.evaluators;
package org.studiorailgun.conversation.evaluators.greet;
import java.util.LinkedList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package org.studiorailgun.conversation.evaluators;
package org.studiorailgun.conversation.evaluators.greet;
import java.io.File;
import java.io.IOException;
@ -43,4 +43,14 @@ public class GreetingEval {
}
}
/**
* Constructs a greeting for the other participant
* @param conversation The conversation
* @return The greeting
*/
public static Quote constructGreeting(Conversation conversation){
Quote response = new Quote("Hello");
return response;
}
}

View File

@ -0,0 +1,27 @@
package org.studiorailgun.conversation.evaluators.synthesis;
import org.studiorailgun.conversation.Conversation;
import org.studiorailgun.conversation.Quote;
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
/**
* Evaluates any response the ai might want to construct
*/
public class ResponseEval {
/**
* Evaluates whether the ai wants to respond or not
* @param conversation The conversation
* @return The quote encapsulating the AI's response
*/
public static Quote evaluate(Conversation conversation){
Quote response = null;
switch(conversation.getGoalData().getGoal()){
case GREET: {
response = GreetingEval.constructGreeting(conversation);
} break;
}
return response;
}
}

View File

@ -3,6 +3,7 @@ package org.studiorailgun;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.studiorailgun.conversation.Quote;
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
/**
@ -28,4 +29,13 @@ public class GreetingTests {
assertEquals(Globals.conversation.getGoalData().getGoal(), ConversationGoal.GREET);
}
@Test
public void testResponse(){
Globals.init("./data/test/webs/web.json");
Quote response = AI.simFrame("Hello");
assertNotEquals(response, null);
}
}