Skip to content

Commit

Permalink
remove threadInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Nov 19, 2024
1 parent 16b8a40 commit d4e100f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import reactor.core.publisher.Flux;

import java.util.HashMap;
import java.util.Map;

public interface AIAssistant {

/**
Expand Down Expand Up @@ -59,14 +56,6 @@ public interface AIAssistant {
*/
PlatformType getPlatform();

/**
* This is used to create a thread
* @return
*/
default Map<String, String> createThread() {
return new HashMap<>();
}

/**
* This is used to set system prompt
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public class ChatThreadPO extends BasePO implements Serializable {
@Column(name = "id")
private Long id;

@Column(name = "thread_info")
private String threadInfo;

@Column(name = "user_id", nullable = false)
private Long userId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public interface ChatThreadConverter {
@Mapping(source = "id", target = "threadId")
ChatThreadVO fromPO2VO(ChatThreadPO platformAuthorizedPO);

@Mapping(source = "threadInfo", target = "threadInfo", qualifiedByName = "map2String")
ChatThreadPO fromDTO2PO(ChatThreadDTO chatThreadDTO);

@Mapping(source = "threadInfo", target = "threadInfo", qualifiedByName = "jsonString2Map")
ChatThreadDTO fromPO2DTO(ChatThreadPO chatThreadPO);

ChatThreadDTO fromReq2DTO(ChatbotThreadReq chatbotThreadReq);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ public class ChatThreadDTO {
private String name;

private Map<String, String> authCredentials;

private Map<String, String> threadInfo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ private AuthPlatformPO getActiveAuthPlatform() {
return null;
}

private AIAssistantConfig getAIAssistantConfig(
String model, Map<String, String> credentials, Map<String, String> configs) {
private AIAssistantConfig getAIAssistantConfig(String model, Map<String, String> credentials) {
return AIAssistantConfig.builder()
.setModel(model)
.setLanguage(LocaleContextHolder.getLocale().toString())
.addCredentials(credentials)
.addConfigs(configs)
.build();
}

Expand All @@ -119,13 +117,9 @@ private PlatformType getPlatformType(String platformName) {
}

private AIAssistant buildAIAssistant(
String platformName,
String model,
Map<String, String> credentials,
Long threadId,
Map<String, String> configs) {
String platformName, String model, Map<String, String> credentials, Long threadId) {
return getAIAssistantFactory()
.create(getPlatformType(platformName), getAIAssistantConfig(model, credentials, configs), threadId);
.create(getPlatformType(platformName), getAIAssistantConfig(model, credentials), threadId);
}

@Override
Expand All @@ -141,10 +135,6 @@ public ChatThreadVO createChatThread(ChatThreadDTO chatThreadDTO) {
chatThreadDTO.setPlatformId(platformPO.getId());
chatThreadDTO.setAuthId(authPlatformPO.getId());

AIAssistant aiAssistant = buildAIAssistant(
platformPO.getName(), authPlatformDTO.getModel(), authPlatformDTO.getAuthCredentials(), null, null);
Map<String, String> threadInfo = aiAssistant.createThread();
chatThreadDTO.setThreadInfo(threadInfo);
ChatThreadPO chatThreadPO = ChatThreadConverter.INSTANCE.fromDTO2PO(chatThreadDTO);
chatThreadPO.setUserId(userId);
chatThreadDao.save(chatThreadPO);
Expand Down Expand Up @@ -213,8 +203,7 @@ public SseEmitter talk(Long threadId, String message) {
platformPO.getName(),
authPlatformDTO.getModel(),
authPlatformDTO.getAuthCredentials(),
chatThreadPO.getId(),
chatThreadDTO.getThreadInfo());
chatThreadPO.getId());
Flux<String> stringFlux = aiAssistant.streamAsk(message);

SseEmitter emitter = new SseEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ CREATE TABLE `llm_chat_thread`
`auth_id` BIGINT(20) UNSIGNED NOT NULL,
`user_id` BIGINT(20) UNSIGNED NOT NULL,
`is_deleted` TINYINT(1) DEFAULT 0 NULL,
`thread_info` TEXT DEFAULT NULL,
`name` VARCHAR(255) DEFAULT NULL,
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP,
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ CREATE TABLE llm_chat_thread
id BIGINT CHECK (id > 0) NOT NULL GENERATED ALWAYS AS IDENTITY,
auth_id BIGINT CHECK (auth_id > 0) NOT NULL,
user_id BIGINT CHECK (user_id > 0) NOT NULL,
thread_info TEXT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
is_deleted BOOLEAN DEFAULT FALSE,
create_time TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
Expand Down

0 comments on commit d4e100f

Please sign in to comment.