AugmentedResponseHandler

Bases: ResponseHandler

This Python class AugmentedResponseHandler extends ResponseHandler and implements methods for processing input and generating responses using a language model service.

Source code in llm_utils/aiweb_common/generate/AugmentedResponse.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class AugmentedResponseHandler(ResponseHandler):
    """
    This Python class `AugmentedResponseHandler` extends `ResponseHandler` and
    implements methods for processing input and generating responses using a
    language model service.
    """

    def __init__(self, llm_interface):
        super().__init__(llm_interface)

    def generate_response(self, assembled_prompt):
        """
        The function `generate_response` calls a language model to generate a response based
        on a given prompt.

        :param assembled_prompt: It looks like the `generate_response` method is designed to
        generate a response using a language model. The `assembled_prompt` parameter likely
        contains the input prompt or context that will be used to generate the response
        :return: The `generate_response` method returns the response generated by calling the
        `generate_langchain_response` method of the `aug_service` object with the
        `assembled_prompt` as an argument.
        """

        # Focus on the specifics of how to interact with the language model.
        # Implement the details of calling the LLM and handling the response.
        return self.aug_service.generate_langchain_response(assembled_prompt)

generate_response(assembled_prompt)

The function generate_response calls a language model to generate a response based on a given prompt.

:param assembled_prompt: It looks like the generate_response method is designed to generate a response using a language model. The assembled_prompt parameter likely contains the input prompt or context that will be used to generate the response :return: The generate_response method returns the response generated by calling the generate_langchain_response method of the aug_service object with the assembled_prompt as an argument.

Source code in llm_utils/aiweb_common/generate/AugmentedResponse.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def generate_response(self, assembled_prompt):
    """
    The function `generate_response` calls a language model to generate a response based
    on a given prompt.

    :param assembled_prompt: It looks like the `generate_response` method is designed to
    generate a response using a language model. The `assembled_prompt` parameter likely
    contains the input prompt or context that will be used to generate the response
    :return: The `generate_response` method returns the response generated by calling the
    `generate_langchain_response` method of the `aug_service` object with the
    `assembled_prompt` as an argument.
    """

    # Focus on the specifics of how to interact with the language model.
    # Implement the details of calling the LLM and handling the response.
    return self.aug_service.generate_langchain_response(assembled_prompt)

RAGResponseHandler

Bases: AugmentedResponseHandler

The RAGResponseHandler class extends AugmentedResponseHandler and initializes RAGServicer object with specified interfaces and a vector store.

Source code in llm_utils/aiweb_common/generate/AugmentedResponse.py
33
34
35
36
37
38
39
40
41
class RAGResponseHandler(AugmentedResponseHandler):
    """
    The `RAGResponseHandler` class extends `AugmentedResponseHandler` and
    initializes `RAGServicer` object with specified interfaces and a vector store.
    """

    def __init__(self, llm_interface, embedding_interface, vectorstore):
        self.aug_service = RAGServicer(llm_interface, embedding_interface, vectorstore)
        super().__init__(llm_interface)

SearchResponseHandler

Bases: AugmentedResponseHandler

The SearchResponseHandler class extends AugmentedResponseHandler and initializes a SearchServicer object for handling search responses.

Source code in llm_utils/aiweb_common/generate/AugmentedResponse.py
44
45
46
47
48
49
50
51
52
class SearchResponseHandler(AugmentedResponseHandler):
    """
    The `SearchResponseHandler` class extends `AugmentedResponseHandler` and initializes a
    `SearchServicer` object for handling search responses.
    """

    def __init__(self, llm_interface, searchable):
        self.aug_service = SearchServicer(llm_interface, searchable)
        super().__init__(llm_interface)