package dev.langchain4j.quarkus.workshop.deepchat;

import io.quarkus.websockets.next.OnOpen;
import io.quarkus.websockets.next.OnTextMessage;
import io.quarkus.websockets.next.WebSocket;
import io.smallrye.mutiny.Multi;
import jakarta.inject.Inject;

@WebSocket(path = "/deep-chat-support-agent")
public class DeepChatSupportAgentWebSocket {

	private final DeepChatSupportAgent deepChatSupportAgent;
	@Inject
	public DeepChatSupportAgentWebSocket(DeepChatSupportAgent deepChatSupportAgent) {
		this.deepChatSupportAgent = deepChatSupportAgent;
	}
	@OnOpen
	public DeepChatTextResponse onOpen() {
		return new DeepChatTextResponse("Willkommen beim Vacme Support! Wie kann ich Ihnen Heute helfen?", false);
	}

	@OnTextMessage
	public Multi<DeepChatTextResponse> onTextMessage(String message) {
		return deepChatSupportAgent.chat(message).map(text -> new DeepChatTextResponse(text, false));

	}

}
