Grt1228 / chatgpt-java

ChatGPT Java SDK支持流式输出、Gpt插件、联网。支持OpenAI官方所有接口。ChatGPT的Java客户端。OpenAI GPT-3.5-Turb GPT-4 Api Client for Java
https://chatgpt-java.unfbx.com
Apache License 2.0
3.3k stars 810 forks source link

插件模式下正常提问有问题 #209

Open AIchovy opened 11 months ago

AIchovy commented 11 months ago
  1. 代码:
    TimePlugin plugin = new TimePlugin(TimeReq.class);
        plugin.setName("当前时间");
        plugin.setFunction("getCurrentTime");
        plugin.setDescription("询问当前时间,方法将会获取当前时间。");
        PluginAbstract.Arg arg = new PluginAbstract.Arg();
        arg.setName("location");
        arg.setDescription("地区");
        arg.setType("string");
        arg.setRequired(false);
        plugin.setArgs(Collections.singletonList(arg));
        openaiClient.chatCompletionWithPlugin(chatCompletion, plugin);

    2.1 与插件无关的问题请求:

    {
    "model": "gpt-3.5-turbo",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "hello!"
        }
    ]
    }

    2.2 代码定位

    chatCompletion.setFunctions(Collections.singletonList(functions));
            ChatCompletionResponse functionCallChatCompletionResponse = this.chatCompletion(chatCompletion);
            ChatChoice chatChoice = (ChatChoice)functionCallChatCompletionResponse.getChoices().get(0);
            log.debug("构造的方法值:{}", chatChoice.getMessage().getFunctionCall());
            R realFunctionParam = (PluginParam)JSONUtil.toBean(chatChoice.getMessage().getFunctionCall().getArguments(), plugin.getR());
            T tq = plugin.func(realFunctionParam);
            FunctionCall functionCall = FunctionCall.builder().arguments(chatChoice.getMessage().getFunctionCall().getArguments()).name(plugin.getFunction()).build();
            messages.add(Message.builder().role(Role.ASSISTANT).content("function_call").functionCall(functionCall).build());
       R realFunctionParam = (PluginParam)JSONUtil.toBean(chatChoice.getMessage().getFunctionCall().getArguments(), plugin.getR()); 

    这行代码会有空指针问题,因为正常提问的返回没有func相关的信息。

Grt1228 commented 9 months ago

与插件无关的建议提出plugin参数使用

xiaoxyb commented 7 months ago

与插件无关的建议提出plugin参数使用

但插件的亮点就在于判断用户意图来自动调用

xiaoxyb commented 7 months ago

与插件无关的建议提出plugin参数使用

但插件的亮点就在于判断用户意图来自动调用

用新的模型和tools call就好了,function估计慢慢会弃用,不用也问题不大了

java-bex5 commented 2 months ago

与插件无关的建议提出plugin参数使用

但插件的亮点就在于判断用户意图来自动调用

用新的模型和tools call就好了,function估计慢慢会弃用,不用也问题不大了

哪些新模型支持,这个项目支持toolcall吗?