Claude2-SDK JAVA版本 它来啦!!!!!!!!

🤖 Claude2 Java API

Claude2-SDK JAVA版本 它来啦!!!!!!!!

地址:Claude2-SDK

各位小伙伴,快把它接入你们的app中吧!!

🎉介绍

一个使用java实现Claude2 创建会话、聊天、发送附件、获取历史会话,清理历史记录等功能的api接口,可以对接第三方系统作为二次开发使用,且性能优越

🎉需要环境

需要jdk 9+ 最好jdk17

🎉使用说明

结合easyHttp 高效请求,高度封装,使得使用非常简单

java 复制代码
// 综合测试代码
        Claude2Model claude2Model = new Claude2Model();
        claude2Model.setCookie("411230a; intercom-123123NXd701157665-0-ATr88VFiZgSTZqcMq2FbEaqGS3vXMUjkBpTdeKGFKO1RkZQAg8="); // cookie
        claude2Model.setOrganizationId("123456"); // 组织号
        claude2Model.setConversationId("345678"); // 会话号
        claude2Model.setProxy(true);
        claude2Model.setProxyHost("xx");
        claude2Model.setProxyPort(1111);
🎉查看历史会话
java 复制代码
     Claude2Api.list_all_conversations(claude2Model);
🎉删除某个会话
java 复制代码
        Claude2Api.delete_chat(claude2Model);
🎉重命名某个会话
java 复制代码
        Claude2Api.rename_chat(claude2Model,"~~~我是一朵花儿~~~");
🎉查看某个会话的对话
java 复制代码
              Claude2Api.chat_conversation_history(claude2Model);
🎉创建新会话
java 复制代码
        Claude2Api.new_chat(claude2Model);
🎉发送消息(可带多附件)(不带files为null即可)
java 复制代码
        Claude2Api.append_message(claude2Model,files,"~~~叽里呱啦叽里呱啦~~~");
java 复制代码
        Claude2Api.append_message(claude2Model,null,"~~~叽里呱啦叽里呱啦~~~");
🎉sdk的model

model在com.mqxb.common.xxxx下

注意:如果使用gson没有自带的转化类,如 LocalTimeDate 则需要写序列化/反序列化转化器 否则会报错

反序列化都写在com.mqxb.common.jsonDeserializer下,如果你新增,会自动读取

java 复制代码
package com.mqxb.common.jsonDeserializer;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;

import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import com.google.gson.JsonParseException;

/**
 * LocalDateTime 转化器
 * @Author: Herche Jane
 * @Date: 2023/11/29
 */
public class LocalDateTimeDeserializer implements JsonDeserializer<LocalDateTime> {
    @Override
    public LocalDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        return LocalDateTime.parse(json.getAsString(), DateTimeFormatter.ISO_DATE_TIME);
    }
}

序列化都写在com.mqxb.common.jsonSerializer下,如果你新增,会自动读取

java 复制代码
package com.mqxb.common.jsonSerializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * LocalDateTime 序列化器
 */
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
    @Override
    public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.format(DateTimeFormatter.ISO_DATE_TIME));
    }
}

🎉🎉🎉🎉🎉🎉🎉🎉后续更新方向

后续会接入钉钉,企业微信,还有slack ,群组中只需 @小八 就可以出来为你服务!

如果你喜欢这个项目,不妨点一个star小星星吧! 如果你想加入我,

相关推荐
IT_Octopus1 小时前
【零基础入门 LLM 开发 · Day 13】:LangChain 的对话记忆——Message 对象版
人工智能·python·langchain
哦虎!1 小时前
【JavaEE】网络初识
java
2603_965148111 小时前
社区与学习资源:从入门到精通的API选品学习路径
数据库·人工智能·python·学习·数据挖掘
for_ever_love__1 小时前
MySQL ORDER BY 排序优化:从 Using filesort 到索引有序扫描(含双路 / 单路排序原理)
java·mysql·优化·存储·by·order·filesort
程序猿追2 小时前
kotlin-retry 接入鸿蒙后,怎样确认它真的会停止重试
开发语言·kotlin·harmonyos
我是人✓2 小时前
Java文件上传三方式对比:从传统到SpringBoot
java·开发语言
智能直播2 小时前
网络RTMP拉流不卡顿、声音不同步,一文讲透缓冲区、时间戳
开发语言·ffmpeg·php·音视频·视频编解码
欣栀♡2 小时前
JVM 频繁 Full GC 先看日志括号里的 cause,jstat 的 FGC 在 JDK 8 上会骗人
java·jvm
CCblandy3 小时前
令牌桶在 0.9 倍负载超发 19%、固定窗口边界放行 20 个:四种限流算法同构实测
后端·python·算法·性能优化·架构
IT研究室3 小时前
最新计算机毕业设计选题推荐-基于spring boot的葡萄酒文化宣传网站-网站-文档指导-Java-springboot
java·spring boot·课程设计