How to fix the chatgpt `function calling` calling the wrong functions with wrong parameters?

Iam using gpt-3.5-turbo-0125 and using function calling, I have a functions,

  1. getCurrentValueOfInvestment (symbol, initial investement, start date)
  2. getCurrentValueOfInvestmentGivenQty (symbol, qty, start date)

if I ask the question, "If I have invested 50k in Tesla on 2022, what is the current value ",

Naturally, I am expecting the Gpt to call getCurrentValueOfInvestment with parameters tesla, 50000, 2022-01-01

But Gpt is calling the function, getCurrentValueOfInvestmentGivenQty with 50k as quantity as Tesla, 50000, 2022-01-01,

Im wondering how come this happend, this is basics and do I need to fix this with instruction on what?

Please help me on this.

Hi @gopichandar,

It seems like there might be a misunderstanding in the way you’re providing the input to GPT-3.5-turbo-0125. The model doesn’t inherently understand programming syntax or function calls in the way a human programmer would. It operates based on patterns it has learned from the text data it was trained on.

In your prompt, when you say “invested 50k in Tesla on 2022,” the model may not necessarily interpret this as a function call to getCurrentValueOfInvestment. Instead, it might see it as a statement about investing a certain amount of money in a certain company at a certain time.

To guide the model to use the correct function, you could try providing more explicit instructions or formatting in your prompt. For example:

  1. Explicit Function Call:

    Call getCurrentValueOfInvestment function with parameters: symbol=tesla, initial investment=50000, start date=2022-01-01
  2. Structured Input:

    Function: getCurrentValueOfInvestment
    Symbol: Tesla
    Initial Investment: $50,000
    Start Date: 2022-01-01

By providing clearer instructions or structuring your input in a way that resembles function calls or structured data, you can improve the chances of the model understanding your intent correctly.

Thank You!