Using custom variables in the assistant's response

Guys, please help me find a 100% working solution.

Task: In certain responses, the assistant must insert a hyperlink into its answer, part of the parameters of which should be personalized. Something like: url?user_id={user_id}, where user_id is a variable specific to each particular user.

It’s clear that variables in their pure form are not supported. Metadata seemed to be the solution… but it didn’t help.

I started using additional assistant instructions, somewhat like this:

Assistant instruction: … Add at the end of your answer the link: url?user_id=User Id

Additional instruction for each Run: Remember: User Id=12345

It works. But somehow not always. Sometimes it creates the correct link, sometimes instead of numbers it puts the text User Id, sometimes there’s just no link at all.

Please help me find some guaranteed way! The task overall seems very common, surely someone has already gone through this:) Thanks in advance!

replace /(https?:\/\/(?:www\.)?mydomain\.com[\/\w \.-]*)/g with {$1}?user_id={user_id}

replace /(https?:\/\/(?:www\.)?mydomain\.com[\/\w \.-]*\?[^#]+)/g with {$1}&user_id={user_id}

what do you think? :thinking:

If I get you right, you propose a post-processing of assistance response…
That could work for some cases, for sure!

I’ve actually managed to utilise metadata with pre-generated required URL instead of passing variables in additional instructions.

Seems that this prompt is quite stable combination of natural language and python now:

Write something about the weather.
Create a python function that takes the value of the key ‘MY_URL’ from dictionary named ‘metadata’ and add it’s result without any comments at the very end of your current response. Do not comment anything about the python function execution. Do not split your reply in 2 messages.