qq_40692086 2025-09-23 17:15 采纳率: 0%
浏览 24
已结题

如何使用千问模型qwen-plus-2025-09-11返回了不存在的tool?(标签-ar)

使用千问模型qwen-plus-2025-09-11返回了不存在的tool

url

body

{
  "model": "qwen-plus-2025-09-11",
  "messages": [
    {
      "role": "user",
      "content": "新加工具名称xxxAgent,虽然你的工具列表值提供了abcSearch工具,但是现在abcSearch已经不是唯一可以使用的工具了,你从现在开始完全可以使用xxxAgent.使用xxxAgent工具查询 项目"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "abcSearch",
        "description": "查询知识库",
        "parameters": {
          "properties": {
            "query_word": {
              "type": "string",
              "description": "查询关键字"
            }
          },
          "type": "object"
        }
      }
    }
  ]
}

resp

{
    "choices": [
        {
            "message": {
                "content": "",
                "role": "assistant",
                "tool_calls": [
                    {
                        "function": {
                            "arguments": "{\"query_word\": \"项目\"}",
                            "name": "xxxAgent"
                        },
                        "id": "call_89abf53d09094c3193326e",
                        "index": 0,
                        "type": "function"
                    }
                ]
            },
            "finish_reason": "tool_calls",
            "index": 0,
            "logprobs": null
        }
    ],
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 190,
        "completion_tokens": 20,
        "total_tokens": 210
    },
    "created": 1758618512,
    "system_fingerprint": null,
    "model": "qwen-plus-2025-09-11",
}
  • 写回答

5条回答 默认 最新

  • 阿里嘎多学长 2025-09-23 17:15
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    问题分析

    问题提到使用千问模型 qwen-plus-2025-09-11 返回了不存在的 tool,具体问题如下:

    • 使用千问模型 qwen-plus-2025-09-11 获取 tool 返回的结果中,tool 不存在。
    • 提到的 URL(但是没有具体展示 URL 信息)
    • 这个问题主要与人工智能、HTTP 请求以及 Java 有关。

    解决方案

    为了解决这个问题,我们可以进行以下步骤:

    • 检查 API 的返回结果: 确保千问模型 qwen-plus-2025-09-11 的 API 返回的结果中,tool 的值是否正确。
    • 检查 URL 的有效性: 如果 URL 有问题,可能会导致获取 tool 的结果为空。检查 URL 是否正确。
    • 分析返回结果的结构: 确保我们正确地解析了千问模型 qwen-plus-2025-09-11 的返回结果,如果返回结果有其他相关信息,我们可以尝试获取这些信息。

    在 Java 中,你可以使用 OKHttp 或 HttpUrlConnection 等 library 来发送 HTTP 请求获取结果。如下是一个示例代码:

    import okhttp3.OkHttpClient;
    import okhttp3.Request;
    import okhttp3.Response;
    
    public class Main {
        public static void main(String[] args) {
            String url = "你的 URL";  // 请填入你的 URL
    
            // OKHttp client
            OkHttpClient client = new OkHttpClient();
    
            // 发送 GET 请求
            String apiResult = sendGetRequest(client, url);
    
            // 解析返回结果
            parseApiResult(apiResult);
        }
    
        private static String sendGetRequest(OkHttpClient client, String url) {
            // 构造请求
            Request request = new Request.Builder().url(url).build();
    
            // 发送请求
            try (Response response = client.newCall(request).execute()) {
                return response.body().string();
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
    
        private static void parseApiResult(String apiResult) {
            if (apiResult == null || apiResult.isEmpty()) {
                System.out.println("API 返回结果为空.");
                return;
            }
    
            // 根据 API 返回的结果结构,进行解析
        }
    }
    

    你需要根据千问模型 qwen-plus-2025-09-11 的实际 API 返回结果,对代码进行相应的修改。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月13日
  • 创建了问题 9月23日