File tree Expand file tree Collapse file tree 3 files changed +34
-5
lines changed
orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring
sample-code/spring-app/src
main/java/com/sap/ai/sdk/app/services
test/java/com/sap/ai/sdk/app/controllers Expand file tree Collapse file tree 3 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,10 @@ public <T extends ChatOptions> T copy() {
167167 .withLlmConfig (config .getLlmConfig ())
168168 .withMaskingConfig (config .getMaskingConfig ())
169169 .withGroundingConfig (config .getGroundingConfig ());
170- return (T ) new OrchestrationChatOptions (copyConfig );
170+ OrchestrationChatOptions result = new OrchestrationChatOptions (copyConfig );
171+ result .setToolCallbacks (toolCallbacks );
172+ result .setInternalToolExecutionEnabled (internalToolExecutionEnabled );
173+ return (T ) result ;
171174 }
172175
173176 @ SuppressWarnings ("unchecked" )
Original file line number Diff line number Diff line change 1212import lombok .val ;
1313import org .springframework .ai .chat .client .ChatClient ;
1414import org .springframework .ai .chat .client .advisor .MessageChatMemoryAdvisor ;
15- import org .springframework .ai .chat .memory .InMemoryChatMemory ;
15+ import org .springframework .ai .chat .memory .InMemoryChatMemoryRepository ;
16+ import org .springframework .ai .chat .memory .MessageWindowChatMemory ;
1617import org .springframework .ai .chat .model .ChatModel ;
1718import org .springframework .ai .chat .model .ChatResponse ;
1819import org .springframework .ai .chat .prompt .Prompt ;
19- import org .springframework .ai .tool .ToolCallbacks ;
20+ import org .springframework .ai .support .ToolCallbacks ;
2021import org .springframework .stereotype .Service ;
2122
2223/** Service class for the AgenticWorkflow service */
@@ -38,8 +39,9 @@ public class SpringAiAgenticWorkflowService {
3839 public ChatResponse runAgent (@ Nonnull final String userInput ) {
3940
4041 // Configure chat memory
41- val memory = new InMemoryChatMemory ();
42- val advisor = new MessageChatMemoryAdvisor (memory );
42+ val repository = new InMemoryChatMemoryRepository ();
43+ val memory = MessageWindowChatMemory .builder ().chatMemoryRepository (repository ).build ();
44+ val advisor = MessageChatMemoryAdvisor .builder (memory ).build ();
4345 val cl = ChatClient .builder (client ).defaultAdvisors (advisor ).build ();
4446
4547 // Add (mocked) tools
Original file line number Diff line number Diff line change 1+ package com .sap .ai .sdk .app .controllers ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import com .sap .ai .sdk .app .services .SpringAiAgenticWorkflowService ;
6+ import lombok .extern .slf4j .Slf4j ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ @ Slf4j
10+ public class SpringAiAgenticWorkflowTest {
11+
12+ SpringAiAgenticWorkflowService service = new SpringAiAgenticWorkflowService ();
13+
14+ @ Test
15+ void testCompletion () {
16+ var response = service .runAgent ("I want to visit Paris for a day. What can I do there?" );
17+ assertThat (response ).isNotNull ();
18+ assertThat (response .getResult ().getOutput ().getText ())
19+ .contains ("Le Comptoir du Relais" )
20+ .contains ("L'As du Fallafel" )
21+ .contains ("Breizh Café" )
22+ .contains ("1°C" );
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments