Class OpenAiAssistantGenerator

java.lang.Object
ai.yda.framework.rag.generator.assistant.openai.OpenAiAssistantGenerator
All Implemented Interfaces:
ai.yda.framework.rag.core.generator.Generator<ai.yda.framework.rag.core.model.RagRequest,ai.yda.framework.rag.core.model.RagResponse>

public class OpenAiAssistantGenerator extends Object implements ai.yda.framework.rag.core.generator.Generator<ai.yda.framework.rag.core.model.RagRequest,ai.yda.framework.rag.core.model.RagResponse>
Generates responses to the User Request by sending queries to the Assistant Service. The class relies on the AzureOpenAiAssistantService for communicating with the Assistant, and uses a assistantId field to identify the Assistant being used.
Since:
0.1.0
See Also:
  • AzureOpenAiAssistantService
  • Constructor Details

    • OpenAiAssistantGenerator

      public OpenAiAssistantGenerator(String apiKey, String assistantId, ai.yda.framework.session.core.SessionProvider sessionProvider)
      Constructs a new OpenAiAssistantGenerator instance with the specified apiKey, assistantId, sessionProvider.
      Parameters:
      apiKey - the API key used to authenticate with the Azure OpenAI Service.
      assistantId - the unique identifier for the Assistant that will be used to interact with the Azure OpenAI Service. This ID is required to specify which Assistant to use when making requests.
      sessionProvider - the SessionProvider instance responsible for providing and managing Sessions. It is used to manage User Sessions and maintain context between interactions with the Assistant.
  • Method Details

    • generate

      public ai.yda.framework.rag.core.model.RagResponse generate(ai.yda.framework.rag.core.model.RagRequest request, String context)
      Generates a Response for a given Request using the OpenAI Assistant Service. This involves either retrieving an existing Thread ID from the Session Provider or creating a new Thread, sending the Request query to the Assistant, and obtaining the Response.
      Specified by:
      generate in interface ai.yda.framework.rag.core.generator.Generator<ai.yda.framework.rag.core.model.RagRequest,ai.yda.framework.rag.core.model.RagResponse>
      Parameters:
      request - the RagRequest object containing the query from the User.
      context - the Context to be included in the Request to the Assistant.
      Returns:
      a RagResponse containing the result of the Assistant's Response.