FunctionCalling: Automatically wrap FunctionCall in a Part when present in a Parts array
Description of the feature request:
When sending FunctionResponse in a multi-turn messages array, I have to wrap it in glm.Part manually:
s = Struct()
s.update({'result': result})
function_response = glm.Part(
function_response=glm.FunctionResponse(name='named_function', response=s))
messages = [
...
{'role':'user',
'parts': [function_response]}
]
Ideally the SDK should automatically wrap with Part like other types, allowing for
{'role':'user',
'parts': [glm.FunctionResponse(name='named_function', response=s)]
}
What problem are you trying to solve with this feature?
Simplify SDK usage
Any other information you'd like to share?
No response
Description of the feature request:
When sending
FunctionResponsein a multi-turn messages array, I have to wrap it inglm.Partmanually:s = Struct() s.update({'result': result}) function_response = glm.Part( function_response=glm.FunctionResponse(name='named_function', response=s)) messages = [ ... {'role':'user', 'parts': [function_response]} ]Ideally the SDK should automatically wrap with Part like other types, allowing for
{'role':'user', 'parts': [glm.FunctionResponse(name='named_function', response=s)] }What problem are you trying to solve with this feature?
Simplify SDK usage
Any other information you'd like to share?
No response
Not sure if they fixed this but i tried your solution but didnt work. Im using a JSON chat history to record everthing and that format is not acceptable. I am using this format just in case someone wants to try something different : First i am looking for function call on the response like this :
for part in response.candidates[0].content.parts:
if part.function_call and part.function_call.name:
Then im passing "part" to build "part.function_call.name" finally im doing the append to "historial" to save it later to a JSON .
function_response = {
"role": "tool",
"parts": [
{
"function_response": {
"name": part.function_call.name,
"response": {"result": resultado}
}
}
]
}
historial.append(function_response)
With this you can use
response = modelo.generate_content(
historial)
directly and avoid using the " Low level access" code . and keep it simple.