Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.iwe3.langchain4j.config;
|
||||
|
||||
import dev.langchain4j.model.chat.ChatModel;
|
||||
import dev.langchain4j.model.openai.OpenAiChatModel;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class LLMConfig {
|
||||
|
||||
@Bean(name = "qwen")
|
||||
public ChatModel chatModelQwen(){
|
||||
/*大模型3件套:apikey ,model-name,base-url */
|
||||
return OpenAiChatModel.builder()
|
||||
.apiKey(System.getenv("DASH_SCOPE_API_KEY"))
|
||||
.modelName("qwen-plus")
|
||||
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.iwe3.langchain4j.config;
|
||||
|
||||
import dev.langchain4j.memory.chat.ChatMemoryProvider;
|
||||
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
|
||||
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class SeparateChatAssistantConfig {
|
||||
|
||||
/**
|
||||
* 聊天记忆提供器
|
||||
* 配置:采用memoryId来完成隔离
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
ChatMemoryProvider chatMemoryProvider() {
|
||||
return memoryId -> MessageWindowChatMemory.builder()
|
||||
.id(memoryId)
|
||||
.maxMessages(10).chatMemoryStore(new InMemoryChatMemoryStore())
|
||||
.build();
|
||||
//如果未来想自定义 -> 则自己写一个类实现 ChatMemoryStore
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user