DEV Community

Cover image for Make the OpenAI Function Calling Work Better and Cheaper with a Two-Step Function Call šŸš€

Make the OpenAI Function Calling Work Better and Cheaper with a Two-Step Function Call šŸš€

KrisztiƔn Maurer on March 10, 2024

I tried using OpenAI's feature for running local functions in a project with many functions. It worked well, even with lots of functions, but the c...
Collapse
 
adamdcosta profile image
AdamDCosta

Interesting. Do you have any other thoughts about optimizing prompts/calls to LLMs?

Collapse
 
maurerkrisztian profile image
KrisztiƔn Maurer

Hi, another idea is to use embeddings as a way to choose the right tool. This involves comparing the prompt with descriptions of the tools to find the best match, but I haven't tried it yet.
platform.openai.com/docs/guides/em...

Collapse
 
maurerkrisztian profile image
KrisztiƔn Maurer

This method needs some testing. I ran into a problem where the OpenAI API tried to call a function because it recognized in the tool descriptor. I fixed it with a system message: "You need to request tools using the tool_descriptor tool before you can use them. IMPORTANT: Don't call tools that don't have a JSON description schema." However, it would be great if OpenAI could fine-tune this method into a model. I might try to improve this and fine-tune it into an open-source language model.