Skip to content

关于查看消息列表API #45

Description

@humphreygao

下面代码附近需要给total、hasMore赋值:


还有lastID到底啥意思啊?比如我ListMessageReq设置为顺序(order = Sort.ASC.getValue()),经过执行,返回的lastID为与智能体会话的第一条消息的ID,然后我拿到第一条消息的ID没有用啊(比如我想知道的是下50条消息、是最后一条消息的follow_up用户问题建议),干嘛不如实返回first_id和last_id。

另,如下代码经过测试,与 https://www.coze.cn/open/playground/conversation_message_list 返回的数据是不对应的:

    String token = "xxx";
    TokenAuth authCli = new TokenAuth(token);

    // Init the Coze client through the access_token.
    CozeAPI coze =
        new CozeAPI.Builder()
            .baseURL("https://api.coze.cn")
            .auth(authCli)
            .readTimeout(10000)
            .build();

    String conversationID = "xxx";
    Integer limit = 2;
    ListMessageReq req =
            ListMessageReq.builder()
            .conversationID(conversationID)
            .order(Sort.ASC.getValue())
            .afterID("xxx")
            .limit(limit)
            .build();

    //  you can use iterator to automatically retrieve next page
    PageResp<Message> messages = coze.conversations().messages().list(req);
    messages.getItems().forEach(t -> System.out.println(t.getId()));

删除如下行代码,发现结果就对了:

req.setAfterID(request.getPageToken()); // 设置 lastID

下面代码,是不是应该把20改成50:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions