ConversationMemoryStore.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:EDDI 作者:
@Override
public String storeConversationMemorySnapshot(ConversationMemorySnapshot snapshot) throws IResourceStore.ResourceStoreException {
    try {
        String json = documentBuilder.toString(snapshot);
        Document document = Document.parse(json);

        document.remove("id");

        if (snapshot.getId() != null) {
            document.put("_id", new ObjectId(snapshot.getId()));
            conversationCollection.updateOne(new Document("_id", new ObjectId(snapshot.getId())),
                    new Document("$set", document),
                    new UpdateOptions().upsert(true));
        } else {
            conversationCollection.insertOne(document);
        }

        return document.get("_id").toString();
    } catch (IOException e) {
        throw new IResourceStore.ResourceStoreException(e.getLocalizedMessage(), e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号