chore: initialize qiming workspace repository
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<artifactId>app-platform-log</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>app-platform-log-sdk</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xspaceagi.log.sdk.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SearchField {
|
||||
|
||||
/**
|
||||
* 是否索引字段
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean index() default true;
|
||||
|
||||
/**
|
||||
* 是否为keyword字段
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean keyword() default false;
|
||||
|
||||
/**
|
||||
* 是否存储字段
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean store() default false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xspaceagi.log.sdk.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SearchIndex {
|
||||
|
||||
/**
|
||||
* 索引名称,默认类名
|
||||
*/
|
||||
String indexName() default "";
|
||||
|
||||
/**
|
||||
* 分片数量
|
||||
*/
|
||||
int shards() default 3;
|
||||
|
||||
/**
|
||||
* 副本数量
|
||||
*/
|
||||
int replicas() default 1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.xspaceagi.log.sdk.reponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 智能体调试大模型的日志结构定义
|
||||
* 对应 Rust 的 AgentLogEntry 结构
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AgentLogModelResponse {
|
||||
|
||||
/**
|
||||
* 请求ID,唯一标识一次请求(必填)
|
||||
*/
|
||||
@Schema(description = "请求ID,唯一标识一次请求(必填)")
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 消息ID,(必填)
|
||||
*/
|
||||
@Schema(description = "消息ID,(必填)")
|
||||
private String messageId;
|
||||
|
||||
/**
|
||||
* 智能体ID
|
||||
*/
|
||||
@Schema(description = "智能体ID")
|
||||
private String agentId;
|
||||
|
||||
/**
|
||||
* 会话ID(必填)
|
||||
*/
|
||||
@Schema(description = "会话ID(必填)")
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 用户UID(必填)
|
||||
*/
|
||||
@Schema(description = "用户UID(必填)")
|
||||
private String userUid;
|
||||
|
||||
/**
|
||||
* 租户ID,用于租户隔离(必填)
|
||||
*/
|
||||
@Schema(description = "租户ID,用于租户隔离(必填)")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 空间ID,用户可以有多个空间
|
||||
*/
|
||||
@Schema(description = "空间ID,用户可以有多个空间")
|
||||
private String spaceId;
|
||||
|
||||
/**
|
||||
* 用户输入的内容
|
||||
*/
|
||||
@Schema(description = "用户输入的内容")
|
||||
private String userInput;
|
||||
|
||||
/**
|
||||
* 系统输出的内容
|
||||
*/
|
||||
@Schema(description = "系统输出的内容")
|
||||
private String output;
|
||||
|
||||
/**
|
||||
* 执行结果,扩展字段,字段类型存储的是json文本
|
||||
*/
|
||||
@Schema(description = "执行结果,扩展字段,字段类型存储的是json文本")
|
||||
private String executeResult;
|
||||
|
||||
/**
|
||||
* 输入token数量
|
||||
*/
|
||||
@Schema(description = "输入token数量")
|
||||
private Integer inputToken;
|
||||
|
||||
/**
|
||||
* 输出token数量
|
||||
*/
|
||||
@Schema(description = "输出token数量")
|
||||
private Integer outputToken;
|
||||
|
||||
/**
|
||||
* 请求开始时间
|
||||
*/
|
||||
@Schema(description = "请求开始时间")
|
||||
private LocalDateTime requestStartTime;
|
||||
|
||||
/**
|
||||
* 请求结束时间
|
||||
*/
|
||||
@Schema(description = "请求结束时间")
|
||||
private LocalDateTime requestEndTime;
|
||||
|
||||
/**
|
||||
* 耗时(毫秒)
|
||||
*/
|
||||
@Schema(description = "耗时(毫秒)")
|
||||
private Long elapsedTimeMs;
|
||||
|
||||
/**
|
||||
* 节点类型
|
||||
*/
|
||||
@Schema(description = "节点类型")
|
||||
private String nodeType;
|
||||
|
||||
/**
|
||||
* 节点状态
|
||||
*/
|
||||
@Schema(description = "节点状态")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
@Schema(description = "节点名称")
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@Schema(description = "用户名称")
|
||||
private String userName;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xspaceagi.log.sdk.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 日志搜索请求参数
|
||||
* 对应 Rust 的 AgentLogSearchParams 结构
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AgentLogDetailParamsRequest {
|
||||
|
||||
/**
|
||||
* 请求ID
|
||||
*/
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 智能体ID
|
||||
*/
|
||||
private String agentId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.xspaceagi.log.sdk.request;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 智能体调试大模型的日志结构定义
|
||||
* 对应 Rust 的 AgentLogEntry 结构
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AgentLogEntryRequest {
|
||||
|
||||
/**
|
||||
* 请求ID,唯一标识一次请求(必填)
|
||||
*/
|
||||
@Schema(description = "请求ID,唯一标识一次请求(必填)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "requestId is required")
|
||||
private String requestId;
|
||||
/**
|
||||
* 消息ID,(必填)
|
||||
*/
|
||||
private String messageId;
|
||||
|
||||
/**
|
||||
* 会话ID(必填)
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 智能体ID
|
||||
*/
|
||||
private String agentId;
|
||||
|
||||
/**
|
||||
* 用户UID(必填)
|
||||
*/
|
||||
private String userUid;
|
||||
|
||||
/**
|
||||
* 租户ID,用于租户隔离(必填)
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 空间ID,用户可以有多个空间
|
||||
*/
|
||||
private String spaceId;
|
||||
|
||||
/**
|
||||
* 用户输入的内容
|
||||
*/
|
||||
private String userInput;
|
||||
|
||||
/**
|
||||
* 系统输出的内容
|
||||
*/
|
||||
private String output;
|
||||
/**
|
||||
* 执行结果,扩展字段,字段类型存储的是json文本
|
||||
*/
|
||||
private String executeResult;
|
||||
|
||||
/**
|
||||
* 输入token数量
|
||||
*/
|
||||
private Integer inputToken;
|
||||
|
||||
/**
|
||||
* 输出token数量
|
||||
*/
|
||||
private Integer outputToken;
|
||||
|
||||
/**
|
||||
* 请求开始时间
|
||||
*/
|
||||
private LocalDateTime requestStartTime;
|
||||
|
||||
/**
|
||||
* 请求结束时间
|
||||
*/
|
||||
private LocalDateTime requestEndTime;
|
||||
|
||||
/**
|
||||
* 耗时(毫秒)
|
||||
*/
|
||||
private Long elapsedTimeMs;
|
||||
|
||||
/**
|
||||
* 节点类型
|
||||
*/
|
||||
private String nodeType;
|
||||
|
||||
/**
|
||||
* 节点状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.xspaceagi.log.sdk.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志搜索请求参数
|
||||
* 对应 Rust 的 AgentLogSearchParams 结构
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AgentLogSearchParamsRequest {
|
||||
|
||||
/**
|
||||
* 请求ID
|
||||
*/
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 会话ID
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 消息ID
|
||||
*/
|
||||
private String messageId;
|
||||
/**
|
||||
* 智能体ID
|
||||
*/
|
||||
private String agentId;
|
||||
|
||||
/**
|
||||
* 用户UID
|
||||
*/
|
||||
private String userUid;
|
||||
|
||||
/**
|
||||
* 用户输入,需要支持全文检索,支持多个关键字(AND关系)
|
||||
*/
|
||||
private List<String> userInput;
|
||||
|
||||
/**
|
||||
* 系统输出,需要支持全文检索,支持多个关键字(AND关系)
|
||||
*/
|
||||
private List<String> output;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 租户ID,用于租户隔离,确保只查询特定租户的日志
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 空间ID,可选,用于查询特定空间的日志,支持多个ID(OR关系)
|
||||
*/
|
||||
private List<String> spaceId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xspaceagi.log.sdk.request;
|
||||
|
||||
import com.xspaceagi.log.sdk.vo.SearchDocument;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DocumentSearchRequest implements Serializable {
|
||||
|
||||
@Schema(description = "搜索文档类", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Class<? extends SearchDocument> searchDocumentClazz;
|
||||
|
||||
@Schema(description = "搜索字段", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<String> searchFields;
|
||||
|
||||
@Schema(description = "搜索关键字", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "过滤字段,全匹配", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<Map<String, Object>> filterFieldsAndValues;
|
||||
|
||||
//排序
|
||||
@Schema(description = "排序字段", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Map<String, Object> sortFieldsAndValues;
|
||||
|
||||
@Schema(description = "分页起始位置", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Integer from;
|
||||
|
||||
@Schema(description = "分页大小", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Integer size;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xspaceagi.log.sdk.service;
|
||||
|
||||
import com.xspaceagi.log.sdk.request.DocumentSearchRequest;
|
||||
import com.xspaceagi.log.sdk.vo.LogDocument;
|
||||
import com.xspaceagi.log.sdk.vo.SearchResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ILogRpcService {
|
||||
|
||||
void bulkIndex(List<LogDocument> list);
|
||||
|
||||
void pushTraceLog(Object traceContext);
|
||||
|
||||
void deleteLogDocument(String id);
|
||||
|
||||
SearchResult search(DocumentSearchRequest documentSearchRequest);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xspaceagi.log.sdk.service;
|
||||
|
||||
import com.xspaceagi.log.sdk.request.DocumentSearchRequest;
|
||||
import com.xspaceagi.log.sdk.vo.SearchDocument;
|
||||
import com.xspaceagi.log.sdk.vo.SearchResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISearchRpcService {
|
||||
|
||||
void bulkIndex(List<SearchDocument> list);
|
||||
|
||||
void deleteDocument(Class<? extends SearchDocument> searchDocumentClazz, String id);
|
||||
|
||||
SearchResult search(DocumentSearchRequest documentSearchRequest);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xspaceagi.log.sdk.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.xspaceagi.log.sdk.reponse.AgentLogModelResponse;
|
||||
import com.xspaceagi.log.sdk.request.AgentLogEntryRequest;
|
||||
import com.xspaceagi.log.sdk.request.AgentLogSearchParamsRequest;
|
||||
|
||||
/**
|
||||
* 日志平台的 RPC 服务,用于新增日志
|
||||
*/
|
||||
public interface LogPlatformRpcService {
|
||||
|
||||
/**
|
||||
* 新增日志
|
||||
*
|
||||
* @param logEntryRequest
|
||||
* @return
|
||||
*/
|
||||
boolean addLog(AgentLogEntryRequest logEntryRequest);
|
||||
|
||||
/**
|
||||
* 搜索日志
|
||||
*
|
||||
* @param searchParams 搜索参数
|
||||
* @param current 页码
|
||||
* @param pageSize 页大小
|
||||
* @return
|
||||
*/
|
||||
IPage<AgentLogModelResponse> searchAgentLogs(AgentLogSearchParamsRequest searchParams,
|
||||
Long current,
|
||||
Long pageSize);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.xspaceagi.log.sdk.vo;
|
||||
|
||||
import com.xspaceagi.log.sdk.annotation.SearchField;
|
||||
import com.xspaceagi.log.sdk.annotation.SearchIndex;
|
||||
import com.xspaceagi.log.sdk.vo.SearchDocument;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SearchIndex(indexName = "req_log")
|
||||
public class LogDocument extends SearchDocument {
|
||||
|
||||
@Schema(description = "租户ID", hidden = true)
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "日志ID, 不用展示,用于查询详情")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "请求唯一标识可以用于关联一次请求中所有相关的操作")
|
||||
@SearchField(keyword = true)
|
||||
private String requestId;
|
||||
|
||||
@Schema(description = "日志产生对象所在的空间ID")
|
||||
private Long spaceId;
|
||||
|
||||
@Schema(description = "请求发起的用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户名")
|
||||
@SearchField(keyword = true)
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "日志对象类型")
|
||||
@SearchField(keyword = true)
|
||||
private String targetType;
|
||||
|
||||
@Schema(description = "日志对象名称")
|
||||
@SearchField(keyword = true)
|
||||
private String targetName;
|
||||
|
||||
@Schema(description = "日志对象ID")
|
||||
@SearchField(keyword = true)
|
||||
private String targetId;
|
||||
|
||||
@Schema(description = "会话ID")
|
||||
@SearchField(keyword = true)
|
||||
private String conversationId;
|
||||
|
||||
@Schema(description = "输入参数")
|
||||
@SearchField(store = true)
|
||||
private String input;
|
||||
|
||||
@Schema(description = "执行结果")
|
||||
@SearchField(store = true)
|
||||
private String output;
|
||||
|
||||
@Schema(description = "执行过程数据")
|
||||
@SearchField(store = true)
|
||||
private String processData;
|
||||
|
||||
@Schema(description = "缓存输入token数量")
|
||||
private Integer cacheInputToken;
|
||||
|
||||
@Schema(description = "输入token数量")
|
||||
private Integer inputToken;
|
||||
|
||||
@Schema(description = "输出token数量")
|
||||
private Integer outputToken;
|
||||
|
||||
@Schema(description = "请求开始时间")
|
||||
private Long requestStartTime;
|
||||
|
||||
@Schema(description = "请求结束时间")
|
||||
private Long requestEndTime;
|
||||
|
||||
@Schema(description = "执行结果码 0000为成功")
|
||||
@SearchField(keyword = true)
|
||||
private String resultCode;
|
||||
|
||||
@Schema(description = "执行结果描述")
|
||||
@SearchField(store = true)
|
||||
private String resultMsg;
|
||||
|
||||
@Schema(description = "日志产生时间")
|
||||
private Long createTime;
|
||||
|
||||
@Schema(description = "日志产生来源", hidden = true)
|
||||
@SearchField(keyword = true)
|
||||
private String from;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xspaceagi.log.sdk.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SearchDocument implements Serializable {
|
||||
|
||||
private String id;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xspaceagi.log.sdk.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SearchResult implements Serializable {
|
||||
|
||||
private Long total;
|
||||
private List<SearchResultItem> items;
|
||||
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class SearchResultItem {
|
||||
private Double score;
|
||||
private SearchDocument document;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user