File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
e2e-test/integration-test/src/main/java/org/apache/flink/agents/integration/test Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 3030import org .apache .flink .agents .api .chat .messages .MessageRole ;
3131import org .apache .flink .agents .api .chat .model .BaseChatModelSetup ;
3232import org .apache .flink .agents .api .context .RunnerContext ;
33+ import org .apache .flink .agents .api .event .ChatRequestEvent ;
34+ import org .apache .flink .agents .api .event .ChatResponseEvent ;
3335import org .apache .flink .agents .api .resource .ResourceDescriptor ;
3436import org .apache .flink .agents .api .resource .ResourceType ;
3537import org .apache .flink .agents .integrations .chatmodels .ollama .OllamaChatModelConnection ;
@@ -126,10 +128,15 @@ public static double createRandomNumber() {
126128 public static void process (InputEvent event , RunnerContext ctx ) throws Exception {
127129 BaseChatModelSetup chatModel =
128130 (BaseChatModelSetup ) ctx .getResource ("ollamaChatModel" , ResourceType .CHAT_MODEL );
129- ChatMessage response =
130- chatModel .chat (
131+ ctx .sendEvent (
132+ new ChatRequestEvent (
133+ "ollamaChatModel" ,
131134 Collections .singletonList (
132- new ChatMessage (MessageRole .USER , (String ) event .getInput ())));
133- ctx .sendEvent (new OutputEvent (response .getContent ()));
135+ new ChatMessage (MessageRole .USER , (String ) event .getInput ()))));
136+ }
137+
138+ @ Action (listenEvents = {ChatResponseEvent .class })
139+ public static void processChatResponse (ChatResponseEvent event , RunnerContext ctx ) {
140+ ctx .sendEvent (new OutputEvent (event .getResponse ().getContent ()));
134141 }
135142}
You can’t perform that action at this time.
0 commit comments