返回下面的 json,LightPlugin 的 ChangeState
方法却没有执行,请问如何解决?
{
"id": "39c54775-a5ea-480e-bfa1-6a39768be395",
"object": "chat.completion",
"created": 1708304708,
"model": "qwen",
"choices": [
{
"message": {
"role": "assistant",
"tool_calls": [
{
"id": "b8eae479-1bca-46ad-8ffc-5f4a07436837",
"function": {
"name": "LightPlugin-ChangeState",
"arguments": "{\u0022newState\u0022:true}"
},
"type": "function"
}
]
},
"finish_reason": "function_call",
"index": 0
}
]
}
LightPlugin 的实现代码
public class LightPlugin
{
public bool IsOn { get; set; } = false;
[KernelFunction]
[Description("帮看一下灯是开是关")]
public string GetState() => IsOn ? "on" : "off";
[KernelFunction]
[Description("开灯或者关灯")]
public string ChangeState(bool newState)
{
IsOn = newState;
var state = GetState();
Console.WriteLine(state == "on" ? $"[灯开啦]" : "[灯关咯]");
return state;
}
}
json 是对的,LightPlugin 的 ChangeState 方法执行了,是我弄错了输出