1313import com .embabel .agent .rag .EntitySearch ;
1414import com .embabel .agent .rag .HyDE ;
1515import com .embabel .agent .rag .pipeline .event .RagPipelineEvent ;
16+ import com .embabel .agent .rag .tools .DualShotConfig ;
1617import com .embabel .chat .AssistantMessage ;
1718import com .embabel .chat .Chatbot ;
1819import com .embabel .chat .Conversation ;
1920import com .embabel .chat .UserMessage ;
2021import com .embabel .chat .agent .AgentProcessChatbot ;
2122import org .springframework .context .annotation .Bean ;
2223import org .springframework .context .annotation .Configuration ;
24+ import org .springframework .lang .NonNull ;
2325import org .springframework .lang .Nullable ;
2426
25- import javax .validation .constraints .Null ;
2627import java .time .Duration ;
2728import java .util .Collections ;
2829import java .util .Set ;
2930
30- record ConversationOver (String why ) {
31+ record ConversationOver (@ NonNull String why ) {
3132}
3233
33- // TODO should go into common
3434record ChatbotReturn (
3535 @ Nullable AssistantMessage assistantMessage ,
36- @ Null ConversationOver termination
36+ @ Nullable ConversationOver termination
3737) implements SomeOf {
3838}
3939
@@ -61,22 +61,24 @@ ChatbotReturn respond(
6161 ActionContext context ) {
6262 var assistantMessage = context
6363 .ai ()
64- .withLlm (guideData .guideConfig ().llm ())
65- .withReferences (guideData .references ( ))
64+ .withLlm (guideData .config ().llm ())
65+ .withReferences (guideData .referencesForUser ( context . user () ))
6666 .withTools (CoreToolGroups .WEB )
67- .withRag (guideData .ragOptions ()
68- .withHyDE (new HyDE (40 ))
69- .withContentElementSearch (ContentElementSearch .CHUNKS_ONLY )
70- .withEntitySearch (new EntitySearch (Set .of (
71- "Concept" , "Example"
72- ), false ))
73- .withDesiredMaxLatency (Duration .ofMinutes (10 ))
74- // .withDualShot(new DualShotConfig(100))
75- .withListener (e -> {
76- if (e instanceof RagPipelineEvent rpe ) {
77- context .updateProgress (rpe .getDescription ());
78- }
79- }))
67+ .withRag (
68+ guideData
69+ .ragOptions ()
70+ .withHyDE (new HyDE (40 ))
71+ .withContentElementSearch (ContentElementSearch .CHUNKS_ONLY )
72+ .withEntitySearch (new EntitySearch (Set .of (
73+ "Concept" , "Example"
74+ ), false ))
75+ .withDesiredMaxLatency (Duration .ofMinutes (10 ))
76+ .withDualShot (new DualShotConfig (100 ))
77+ .withListener (e -> {
78+ if (e instanceof RagPipelineEvent rpe ) {
79+ context .updateProgress (rpe .getDescription ());
80+ }
81+ }))
8082 .withTemplate ("guide_system" )
8183 .respondWithSystemPrompt (conversation ,
8284 guideData .templateModel (Collections .singletonMap ("user" ,
@@ -89,7 +91,7 @@ ChatbotReturn respond(
8991
9092 @ AchievesGoal (description = "Conversation completed" )
9193 @ Action
92- ConversationOver respondAndMaybeTerminate (
94+ ConversationOver respondAndTerminate (
9395 ConversationOver conversationOver ,
9496 Conversation conversation ,
9597 ActionContext context ) {
0 commit comments