Learning from Help Documents

User or applications can provide help documents to the AppAgent to reinforce its capabilities. The AppAgent can retrieve knowledge from these documents to improve its understanding of the task, generate high-quality plans, and interact more efficiently with the application. You can find how to provide help documents to the AppAgent in the Help Document Provision section.

Mechanism

The help documents are provided in a format of task-solution pairs. Upon receiving a request, the AppAgent retrieves the relevant help documents by matching the request with the task descriptions in the help documents and generates a plan based on the retrieved solutions.

Note

Since the retrieved help documents may not be relevant to the request, the AppAgent will only take them as references to generate the plan.

Activate the Learning from Help Documents

Follow the steps below to activate the learning from help documents:

Step 1: Provide Help Documents

Please follow the steps in the Help Document Provision document to provide help documents to the AppAgent.

Step 2: Configure the AppAgent

Configure the following parameters in the config.yaml file to activate the learning from help documents:

Configuration Option Description Type Default Value
RAG_OFFLINE_DOCS Whether to use the offline RAG Boolean False
RAG_OFFLINE_DOCS_RETRIEVED_TOPK The topk for the offline retrieved documents Integer 1

Reference

Bases: Retriever

Class to create offline retrievers.

Create a new OfflineDocRetriever. :appname: The name of the application.

Source code in rag/retriever.py
77
78
79
80
81
82
83
84
def __init__(self, app_name: str) -> None:
    """
    Create a new OfflineDocRetriever.
    :appname: The name of the application.
    """
    self.app_name = app_name
    indexer_path = self.get_offline_indexer_path()
    self.indexer = self.get_indexer(indexer_path)

get_indexer(path)

Load the retriever.

Parameters:
  • path (str) –

    The path to load the retriever from.

Returns:
  • The loaded retriever.

Source code in rag/retriever.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
def get_indexer(self, path: str):
    """
    Load the retriever.
    :param path: The path to load the retriever from.
    :return: The loaded retriever.
    """

    if path:
        print_with_color(
            "Loading offline indexer from {path}...".format(path=path), "cyan"
        )
    else:
        return None

    try:
        db = FAISS.load_local(path, get_hugginface_embedding())
        return db
    except:
        print_with_color(
            "Warning: Failed to load offline indexer from {path}.".format(
                path=path
            ),
            "yellow",
        )
        return None

get_offline_indexer_path()

Get the path to the offline indexer.

Returns:
  • The path to the offline indexer.

Source code in rag/retriever.py
86
87
88
89
90
91
92
93
94
95
96
def get_offline_indexer_path(self):
    """
    Get the path to the offline indexer.
    :return: The path to the offline indexer.
    """
    offline_records = get_offline_learner_indexer_config()
    for key in offline_records:
        if key.lower() in self.app_name.lower():
            return offline_records[key]

    return None