How could we control the user's request

In an agent that retrieves data from Excel files, the returned data depends on the user’s request and the filters they want to apply.

To handle this, I use mapping files for both column names and stored values.

The first file contains the exact column names along with a list of keywords and synonyms associated with each column. This allows the agent to map user-provided terms in natural language to the correct Excel columns.

The second file contains the stored values and their corresponding business terms or synonyms. This enables the agent to translate user inputs into the exact values stored in the Excel data.

These mapping files help control and standardize natural language inputs, ensuring that user requests are correctly interpreted and converted into accurate filters for data retrieval.

The problem is that the agent must always use these mapping files to correctly interpret the user’s request. However, consulting these files for every query takes a significant amount of time and impacts the overall response performance.

Since the agent needs to map both column names and stored values from natural language inputs, it cannot easily skip this step without risking incorrect results.

What do you think about this approach? Do you see a better way to maintain accuracy while improving performance?

@Sal23

I would suggest using Context Grounding for this. Store your excel files into Storage bucket if the data is not very frequent changes and if too dynamic, store it over OneDrive or any other integration service. Create the context grounding index and update your Agent’s System Prompt to use context grounding Index to apply filters based on user request.

hy,

actually that’s what I’m doing,
I put the files in the context grounding, but to control the demand of the user, I always need mappings the values, and to return the exact value,

for example, the user can demand the list of people with french nationality,
the agent should understand that the exact name of column is ClietnNationality

@Sal23

Ok then in that case you will have to play around the system prompt and evolve it by modifying the prompt, test, and check output.

Rather than giving synonyms for columns, on the mapping file add one more column as description. Provide a description about what type of data that column contains. With this, when the user query with natural language, the agent looks up mapping file, with the help of column description it should be able to map the right columns user is querying about and return back.

Hi @Sal23,

If you’re reading the mapping files for every query, that is likely causing the slowdown. Instead, read both files once when the Agent starts and store them in memory for the current session. This way, the Agent can reuse the mappings without reading the files again.

You can also update the prompt somthing like:

You are a data retrieval agent. Use the mapping files loaded in memory to interpret user input before applying filters.

Thanks