Skip to content

关于函数式调用,FunctionParameters和官方文档上好像不是很一致,有点疑问。 #27

@CometZ35

Description

@CometZ35

首先要函数式调用,使用ChatErnieRequest类

public class ChatErnieRequest extends ChatBaseRequest {
    private static final Logger log = LoggerFactory.getLogger(ChatErnieRequest.class);
    private Float temperature;
    private Float topP;
    private Float penaltyScore;
    private List<FunctionInfo> functions;
   ......
}

FunctionInfo结构如下:

public class FunctionInfo {
    private String name;
    private String description;
    private FunctionParameters parameters;
    private FunctionResponses responses;
    private List<Example> examples;
}
官网的结构如下:
{
    "messages":[
        {
            "role":"user",
            "content":"上海市今天的天气"
        }
    ],
    "functions":[
        {
            "name":"get_current_weather",
            "description":"获得指定地点的天气",
            "parameters":{
                "type":"object",
                "properties":Object{...},
                "required":["location"]
            }
        },
        Object{...}
    ],
    "stream":true,
    "tool_choice":Object{...}
}

对应到parameters字段的FunctionParameters类,结构是:

public class FunctionParameters {
    private String name;
    private String description;
    private Map<String, Map<String, String>> properties;
}

官网上的parameters参数中有一个type字段,值是object,首先是type字段,应该是默认给了object,那required字段怎么填写呢?
请问是遗漏了还是有其他的调用方式?谢谢

另外能否在示例中写一下函数式调用的demo,多谢大佬。

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.x1.x版本2.x2.x版本enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions