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小星星吧! 如果你想加入我,

相关推荐
belldeep18 分钟前
python:reportlab 将多个图片合并成一个PDF文件
python·pdf·reportlab
ok!ko2 小时前
设计模式之原型模式(通俗易懂--代码辅助理解【Java版】)
java·设计模式·原型模式
2402_857589362 小时前
“衣依”服装销售平台:Spring Boot框架的设计与实现
java·spring boot·后端
吾爱星辰3 小时前
Kotlin 处理字符串和正则表达式(二十一)
java·开发语言·jvm·正则表达式·kotlin
ChinaDragonDreamer3 小时前
Kotlin:2.0.20 的新特性
android·开发语言·kotlin
FreakStudio3 小时前
全网最适合入门的面向对象编程教程:56 Python字符串与序列化-正则表达式和re模块应用
python·单片机·嵌入式·面向对象·电子diy
IT良3 小时前
c#增删改查 (数据操作的基础)
开发语言·c#
丶21363 小时前
【CUDA】【PyTorch】安装 PyTorch 与 CUDA 11.7 的详细步骤
人工智能·pytorch·python
哎呦没3 小时前
大学生就业招聘:Spring Boot系统的架构分析
java·spring boot·后端
Kalika0-04 小时前
猴子吃桃-C语言
c语言·开发语言·数据结构·算法