Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CometZ35 opened this issue Feb 2, 2024 · 1 comment
Labels
1.x 1.x版本 2.x 2.x版本 enhancement New feature or request

Comments

@CometZ35
Copy link

CometZ35 commented Feb 2, 2024

首先要函数式调用,使用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,多谢大佬。

@egmsia01
Copy link
Owner

egmsia01 commented Feb 2, 2024

这个地方的确有遗漏了字段,此外,这一部分官方文档后续也有一些更新。并且function call这一部分设计上的确存在一些不合理的地方,这一块会在下个版本进行更改。

@egmsia01 egmsia01 added enhancement New feature or request 1.x 1.x版本 2.x 2.x版本 labels Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.x版本 2.x 2.x版本 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants