parent
388f37de6c
commit
ff46e6e846
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,8 +1,8 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
import xyz.wbsite.achat.core.embed.EmbeddingsRequest;
|
import xyz.wbsite.achat.embed.EmbeddingsRequest;
|
||||||
import xyz.wbsite.achat.core.embed.EmbeddingsResponse;
|
import xyz.wbsite.achat.embed.EmbeddingsResponse;
|
||||||
|
|
||||||
public interface ChatService {
|
public interface ChatService {
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
import xyz.wbsite.achat.core.embed.EmbeddingsRequest;
|
import xyz.wbsite.achat.embed.EmbeddingsRequest;
|
||||||
import xyz.wbsite.achat.core.embed.EmbeddingsResponse;
|
import xyz.wbsite.achat.embed.EmbeddingsResponse;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文本补全请求
|
* 文本补全请求
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息状态枚举
|
* 消息状态枚举
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.chat;
|
package xyz.wbsite.achat.chat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌使用统计
|
* 令牌使用统计
|
@ -0,0 +1,37 @@
|
|||||||
|
package xyz.wbsite.achat.chat.tool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*
|
||||||
|
* @author wangbing
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class Arg {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package xyz.wbsite.achat.chat.tool;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工具函数定义 - 符合OpenAI官方API规范
|
||||||
|
*
|
||||||
|
* @author wangbing
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class Function {
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private Parameters parameters;
|
||||||
|
|
||||||
|
public Function() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private Function(Builder builder) {
|
||||||
|
this.name = builder.name;
|
||||||
|
this.description = builder.description;
|
||||||
|
this.parameters = builder.parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Parameters getParameters() {
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(Parameters parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private Parameters parameters;
|
||||||
|
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder parameters(Parameters parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Function build() {
|
||||||
|
return new Function(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package xyz.wbsite.achat.chat.tool;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*
|
||||||
|
* @author wangbing
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*
|
||||||
|
* @author wangbing
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class Parameters {
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private List<String> required;
|
||||||
|
|
||||||
|
private Properties properties;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getRequired() {
|
||||||
|
return required;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequired(List<String> required) {
|
||||||
|
this.required = required;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(Properties properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package xyz.wbsite.achat.chat.tool;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*
|
||||||
|
* @author wangbing
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class Properties extends TreeMap<String,Arg> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package xyz.wbsite.achat.chat.tool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工具定义 - 符合OpenAI官方API规范
|
||||||
|
*
|
||||||
|
* @author wangbing
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class Tool {
|
||||||
|
private String type;
|
||||||
|
private Function function;
|
||||||
|
|
||||||
|
public Tool() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tool(Builder builder) {
|
||||||
|
this.type = builder.type;
|
||||||
|
this.function = builder.function;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Function getFunction() {
|
||||||
|
return function;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFunction(Function function) {
|
||||||
|
this.function = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String type;
|
||||||
|
private Function function;
|
||||||
|
|
||||||
|
public Builder type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder function(Function function) {
|
||||||
|
this.function = function;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tool build() {
|
||||||
|
return new Tool(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.embed;
|
package xyz.wbsite.achat.embed;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,6 +1,6 @@
|
|||||||
package xyz.wbsite.achat.core.embed;
|
package xyz.wbsite.achat.embed;
|
||||||
|
|
||||||
import xyz.wbsite.achat.core.chat.Usage;
|
import xyz.wbsite.achat.chat.Usage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.model;
|
package xyz.wbsite.achat.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.model;
|
package xyz.wbsite.achat.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package xyz.wbsite.achat.core.session;
|
package xyz.wbsite.achat.session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Message extends xyz.wbsite.achat.core.chat.Message {
|
public class Message extends xyz.wbsite.achat.chat.Message {
|
||||||
private String id;
|
private String id;
|
||||||
private String uid;
|
private String uid;
|
||||||
private String sid;
|
private String sid;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.session;
|
package xyz.wbsite.achat.session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口响应结果基类
|
* 接口响应结果基类
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.session;
|
package xyz.wbsite.achat.session;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,6 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.session;
|
package xyz.wbsite.achat.session;
|
||||||
|
|
||||||
import xyz.wbsite.achat.core.chat.Message;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.core.session;
|
package xyz.wbsite.achat.session;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,12 +1,12 @@
|
|||||||
package xyz.wbsite.achat.config;
|
package xyz.wbsite.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import xyz.wbsite.achat.core.chat.ChatService;
|
import xyz.wbsite.achat.chat.ChatService;
|
||||||
import xyz.wbsite.achat.core.chat.ChatServiceSampleImpl;
|
import xyz.wbsite.achat.chat.ChatServiceSampleImpl;
|
||||||
import xyz.wbsite.achat.core.session.SessionService;
|
import xyz.wbsite.achat.session.SessionService;
|
||||||
import xyz.wbsite.achat.core.session.SessionServiceMemoryImpl;
|
import xyz.wbsite.achat.session.SessionServiceMemoryImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话配置
|
* 对话配置
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat.config;
|
package xyz.wbsite.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
@ -1,4 +1,4 @@
|
|||||||
package xyz.wbsite.achat;
|
package xyz.wbsite.openai;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
@ -1,13 +1,13 @@
|
|||||||
package xyz.wbsite.achat;
|
package xyz.wbsite.openai;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import xyz.wbsite.achat.core.session.Result;
|
import xyz.wbsite.achat.session.Result;
|
||||||
import xyz.wbsite.achat.core.session.Session;
|
import xyz.wbsite.achat.session.Session;
|
||||||
import xyz.wbsite.achat.core.session.SessionService;
|
import xyz.wbsite.achat.session.SessionService;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,2 +1,3 @@
|
|||||||
server.port=8080
|
server.port=8080
|
||||||
spring.application.name=achat
|
spring.application.name=achat
|
||||||
|
cfg.api.key=qazwsxedc741852963
|
||||||
|
Loading…
Reference in new issue