CAD Web AI Agent 接入
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.linkerbot.vibemake.bean.ai;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/** CAD Agent 的网页协议;业务编码与模型工具调用编码均不代表数据库 ID。 */
|
||||
public final class CadAiContracts {
|
||||
private CadAiContracts() {}
|
||||
|
||||
public record CadAiChatRequest(
|
||||
@NotBlank String protocolVersion,
|
||||
@NotBlank @Pattern(regexp = "[A-Za-z0-9_-]{1,64}") String documentSessionCode,
|
||||
@NotBlank @Pattern(regexp = "[A-Za-z0-9_-]{1,64}") String turnCode,
|
||||
@Pattern(regexp = "[A-Za-z0-9_-]{1,64}") String cadProjectCode,
|
||||
@NotEmpty @Size(max = 256) List<@NotNull @Valid CadAiHistoryItem> history,
|
||||
@NotNull @Valid CadAiContext context) {}
|
||||
|
||||
public record CadAiContext(
|
||||
@NotBlank @Size(max = 128) String documentRevision,
|
||||
JsonNode selection) {}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record CadAiContent(String type, String text, String mimeType, String data) {
|
||||
public static CadAiContent text(String text) {
|
||||
return new CadAiContent("text", text, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** type 为 message / toolCall / toolResult;每种类型只接受对应字段。 */
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record CadAiHistoryItem(
|
||||
String type, String role, List<CadAiContent> content,
|
||||
String callCode, String name, JsonNode arguments, Boolean isError) {
|
||||
public static CadAiHistoryItem message(String role, List<CadAiContent> content) {
|
||||
return new CadAiHistoryItem("message", role, content, null, null, null, null);
|
||||
}
|
||||
|
||||
public static CadAiHistoryItem call(String code, String name, JsonNode arguments) {
|
||||
return new CadAiHistoryItem("toolCall", null, null, code, name, arguments, null);
|
||||
}
|
||||
}
|
||||
|
||||
public record CadAiTool(String name, String description, JsonNode parameters) {}
|
||||
|
||||
public record CadAiLimits(
|
||||
long requestBytes, int imageBytes, int imageMaxEdge, int imagesPerRequest,
|
||||
int textBytes, int toolResultTextBytes, int historyItems,
|
||||
int maxModelCallsPerTurn, int maxChangesPerTurn,
|
||||
long requestTimeoutSeconds, int requestsPerMinute) {}
|
||||
|
||||
public record CadAiCapabilities(
|
||||
boolean enabled, String protocolVersion, String model,
|
||||
List<CadAiTool> tools, CadAiLimits limits) {}
|
||||
|
||||
public record CadAiUsage(long inputTokens, long outputTokens, long totalTokens) {}
|
||||
|
||||
public record CadAiTextDelta(String documentSessionCode, String turnCode, String text) {}
|
||||
|
||||
public record CadAiToolCall(
|
||||
String documentSessionCode, String turnCode,
|
||||
String callCode, String name, JsonNode arguments) {}
|
||||
|
||||
public record CadAiCompleted(
|
||||
String documentSessionCode, String turnCode, String finishReason,
|
||||
List<CadAiHistoryItem> output, CadAiUsage usage) {}
|
||||
|
||||
public record CadAiError(String documentSessionCode, String turnCode) {}
|
||||
}
|
||||
Reference in New Issue
Block a user