Function calling using arguments generated by an assistant

Hi,

I want to create an assistant that will generate elements by itself, and then I want to check these elements using a function. Sounds like basic function calling, but it is different because the assistant should call the function on the arguments that it has generated, not the arguments provided by the user. Example:

Let’s say I have a function: def get_real_time_price(ticker): return price. Assistant instructions look like this: “You are a stock market expert. Your role is to provide 10 stock companies and their tickers, based on data provided by the user.” And an example prompt: “technological stocks with a price below 25$.”

So, the assistant starts to generate 10 stocks and tickers; it generates the first one, calls the function, rejects it if the price is higher than 25$, and comes up with the next one, until there are 10 stocks with a price below 25$.

I guess it is impossible with function calling, but do you have any ideas on how to get around it? My ideas:
Use the same prompt without function calling: it will provide me with stocks and their tickers that were priced below 25$ in the past, so there is a higher chance that their current price is also 25$. Then extract tickers from the response and call the get_real_time_price(ticker) function by myself. If only 6 of 10 stocks are priced below 25$, prompt it again with (“10 more with the same criteria”), repeat until I get 10. It doesn’t seem to be a very good solution because of time and costs (multiple messages).

Another solution is to change instructions from 10 stocks to, for example, 30, and then check them manually until I get 10, but it will take longer.

So If anyone has a better solution, please share, thanks :slight_smile:

why not just pass a list of likely candidates, and filter the results with code interpreter?

that said, I don’t think this is the best job for an LLM, because if it responds it will make a guess around its knowledge from the start of the year.

so the best option would likely to fetch an exhaustive list and parse it, whether with code interpreter or on your back end.


but your question was how to handle a wide variety of cases.

well, IMO the best way is to give the AI all the tools and information it needs to answer the potential queries. if you give it all the data and hints on what it could do with it, you should get decent results.

that said, I don’t think assistants are a magic pill. you still have a scope around the product you want to provide, and you need to be aware of everything that happens within that envelope - much like with classical programming, but with less code.