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

相关推荐
CAE虚拟与现实5 分钟前
docker desktop中的build功能是要build什么
java·docker·容器
PHP实战开发录1 小时前
PHP脚本手动能跑定时任务却失败
开发语言·php·开发
郝学胜-神的一滴2 小时前
Effective Python 条款 10 :海象运算符_=
开发语言·python·程序人生·开源
wuyk5552 小时前
Python零基础入门第十四章:异常处理(try-except)
开发语言·python
2601_962078192 小时前
Appium+Python+pytest自动化测试框架详解
自动化测试·python·appium·pytest·移动应用
wuyk5552 小时前
【Socket 进阶之路】第 3 章 TCP 三次握手 & 四次挥手深度剖析|连接建立、断开、状态机、TIME_WAIT 核心工程问题
服务器·开发语言·网络·物联网·网络协议·tcp/ip
allnlei2 小时前
s6-overlay - 装在 Docker 容器里的轻量级管家
java·docker·容器
卷无止境6 小时前
智能体开发环境ADE浅析,编程工具的下一次范式跃迁
后端·python
彧azz8 小时前
图的存储结构详解:邻接矩阵的原理、实现与应用
开发语言·数据结构·学习·php
IT_Octopus8 小时前
IntelliJ 本地日志路径自定义:`-DLOG_PATH=./logs` 为什么总“不听话“
java·log4j·intellij-idea