Search in sources :

Example 1 with KoreAIResponseHandler

use of org.finos.symphony.toolkit.koreai.output.KoreAIResponseHandler in project spring-bot by finos.

the class KoreAIBridgeFactoryImpl method buildBridge.

@Override
public SymphonyStreamHandler buildBridge(KoreAIInstanceProperties props) {
    String email = "--no email--";
    try {
        // build KoreAI pipeline
        ApiInstance apiInstance = symphonyAPIInstance(props);
        email = apiInstance.getIdentity().getEmail();
        KoreAIResponseBuilder koreAIResponseBuilder = koreAIResponseBuilder();
        KoreAIResponseHandler koreAIResponseHandler = responseMessageAdapter(apiInstance, props);
        KoreAIRequester requester = koreAIRequester(props, koreAIResponseHandler, koreAIResponseBuilder);
        List<StreamEventConsumer> consumers = new ArrayList<StreamEventConsumer>();
        consumers.add(koreAIEventHandler(requester, apiInstance, props));
        if (props.isSendWelcomeMessage()) {
            consumers.add(new RoomWelcomeEventConsumer(apiInstance.getAgentApi(MessagesApi.class), apiInstance.getPodApi(UsersApi.class), apiInstance.getIdentity(), props.getWelcomeMessageML()));
        }
        // wire this up to a shared stream
        SymphonyStreamHandler out = sshf.createBean(apiInstance, consumers);
        return out;
    } catch (Exception e) {
        LOG.error("Couldn't construct Kore/Symphony bridge bean for " + email, e);
        return null;
    }
}
Also used : SymphonyStreamHandler(org.finos.symphony.toolkit.stream.handler.SymphonyStreamHandler) KoreAIResponseBuilder(org.finos.symphony.toolkit.koreai.response.KoreAIResponseBuilder) RoomWelcomeEventConsumer(org.finos.symphony.toolkit.stream.welcome.RoomWelcomeEventConsumer) ArrayList(java.util.ArrayList) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) KoreAIResponseHandler(org.finos.symphony.toolkit.koreai.output.KoreAIResponseHandler) StreamEventConsumer(org.finos.symphony.toolkit.stream.StreamEventConsumer) KoreAIRequester(org.finos.symphony.toolkit.koreai.request.KoreAIRequester) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 KoreAIResponseHandler (org.finos.symphony.toolkit.koreai.output.KoreAIResponseHandler)1 KoreAIRequester (org.finos.symphony.toolkit.koreai.request.KoreAIRequester)1 KoreAIResponseBuilder (org.finos.symphony.toolkit.koreai.response.KoreAIResponseBuilder)1 ApiInstance (org.finos.symphony.toolkit.spring.api.factories.ApiInstance)1 StreamEventConsumer (org.finos.symphony.toolkit.stream.StreamEventConsumer)1 SymphonyStreamHandler (org.finos.symphony.toolkit.stream.handler.SymphonyStreamHandler)1 RoomWelcomeEventConsumer (org.finos.symphony.toolkit.stream.welcome.RoomWelcomeEventConsumer)1