首页 新闻 会员 周边

Semantic Kernel Plugin 没有执行 function calling

0
悬赏园豆:30 [已解决问题] 解决于 2024-02-19 11:29

返回下面的 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;
    }
}
dudu的主页 dudu | 高人七级 | 园豆:31048
提问于:2024-02-19 09:09
< >
分享
最佳答案
0

json 是对的,LightPlugin 的 ChangeState 方法执行了,是我弄错了输出

dudu | 高人七级 |园豆:31048 | 2024-02-19 11:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册