@n2u I was testing your approach to using the base model with function calling and have run into a snag.
I now have a lot of functions (see some below) and it’s easy to get the model to call any of them individually. My problem is if more than 1 function is required to answer the question–for example, “get me the last 3 readings for GNP and the last 3 readings for Personal Savings Rate (PSR)”. Right now it picks one and gives me back the data. I’ve tried to force the process below with no luck. I read this but it’s clear as mud. I’d like to try the approach @magalhas laid out but i really don’t understand it. has anyone written up a solution that is easier to comprehend?
$functions = [
[
"name" => "GetGNP",
"description" => "Fetch the Gross National Product Data.",
"parameters" => [...]
],
[
"name" => "GetPSR",
"description" => "Get the Personal Savings Rate data.",
"parameters" => [...]
],
[
"name" => "GetGDP",
"description" => "Get Gross Domestic Product Data.",
"parameters" => []
],
[... many more ...]
};
Process I tried with no luck:
$data = callModel()
{"role": "system", "content": "This is a finance model..."},
{"role": "user", "content": "get me the last 3 readings for GNP and the last 3 readings for Personal Savings Rate (PSR)"}
]
$functionData = callAppropriateFunction
callModelWithFunctionData($ai_model, $input, $functions, $data, $functionData)
{"role": "system", "content": "This is a finance model..."},
{"role": "user", "content": "get me the last 3 readings for GNP and the last 3 readings for Personal Savings Rate (PSR)"},
{"role": "assistant", "content": null, "function_call": {"name": "GetGNP", "arguments": {}}},
{"role": "function", "name": "GetGNP", "content": "{...GNP Data...}"}
]
$functionData = callAppropriateFunction
callModelWithFunctionData($ai_model, $input, $functions, $data, $functionData)
{"role": "system", "content": "This is a finance model..."},
{"role": "user", "content": "get me the last 3 readings for GNP and the last 3 readings for Personal Savings Rate (PSR)"},
{"role": "assistant", "content": null, "function_call": {"name": "GetGNP", "arguments": {}}},
{"role": "function", "name": "GetGNP", "content": "{...GNP Data...}"},
{"role": "assistant", "content": null, "function_call": {"name": "GetPSR", "arguments": {}}},
{"role": "function", "name": "GetPSR", "content": "{...PSR Data...}"}
]
$functionData = callAppropriateFunction
callModelWithFunctionData($ai_model, $input, $functions, $data, $functionData)
{"role": "system", "content": "This is a finance model..."},
{"role": "user", "content": "get me the last 3 readings for GNP and the last 3 readings for Personal Savings Rate (PSR)"},
{"role": "assistant", "content": null, "function_call": {"name": "GetGNP", "arguments": {}}},
{"role": "function", "name": "GetGNP", "content": "{...GNP Data...}"},
{"role": "assistant", "content": null, "function_call": {"name": "GetPSR", "arguments": {}}},
{"role": "function", "name": "GetPSR", "content": "{...PSR Data...}"},
{"role": "assistant", "content": "Here are the last 3 readings for GNP: ... and for PSR: ..."}
]