File search: variables in text documents

Is it possible to insert variables in the files that will be used with file_search? For example, I have a multilingual site and the e-mail address changes depending on the language

Hi!

I think the simplest and most straightforward suggestion would be to handle this during post-processing. If your goal is to replace individual variables, you can look them up and modify them as needed before returning the result to the user.

but must it be done within the assistant’s instructions? could you give me an example? thank you

It doesn’t have to be done using the Assistant’s instructions. After the run is completed, take the model’s reply and adjust it as needed. In the next step, present the result to the user to continue the conversation.

I suggest you take a look at the cookbook example. The relevant part will be the ‘Messages’ section when the run has completed.

Hope this helps!

1 Like

OK, but every time I have to run a new run to do this. It seems counterproductive in terms of speed of execution for something so simple.

1 Like

Compared to the time it takes for the assistant to complete a run, this is negligible in terms of time. It’s also cheaper since you don’t have to pay for additional model usage, and it becomes a more robust and reliable solution once you figure out how to identify the variables and target values.

It’s a very common, if not best, practice.