| Modifier and Type | Field and Description |
|---|---|
protected LLMConfig |
llmConfig |
protected StreamCallBack |
streamCallBack |
| Constructor and Description |
|---|
AbstractLLM(LLMConfig llmConfig)
初始化
|
| Modifier and Type | Method and Description |
|---|---|
<RESP extends LLMResp> |
ask(List<ConversationMessage> chatMessages)
多轮问答
|
<RESP extends LLMResp> |
ask(List<ConversationMessage> chatMessages,
LLMParamConfig paramConfig)
多轮问答
|
RESP |
ask(String prompt)
单轮问答
|
RESP |
ask(String prompt,
LLMParamConfig paramConfig)
单轮问答
|
<T> T |
askForObject(String prompt,
Class<T> clazz)
单轮问答
|
<T> T |
askForObject(String prompt,
LLMParamConfig paramConfig,
Class<T> clazz)
单轮问答
|
protected String |
getExistPrompt(String prompt)
从缓存中查找
|
LLMConfig |
getLLMConfig()
获取当前LLM的配置
|
protected abstract RESP |
getLLMResponse(List<ConversationMessage> chatMessages,
LLMParamConfig llmParamConfig)
调用chat接口
|
protected abstract RESP |
getLLMResponseFromCache(String cache)
从缓存获取结果
|
protected boolean |
needAddNewSystemMessage() |
void |
setCache(Cache cache)
设置缓存
|
void |
setStreamCallback(StreamCallBack streamCallback)
设置流式接口回调函数
|
protected LLMConfig llmConfig
protected StreamCallBack streamCallBack
public AbstractLLM(LLMConfig llmConfig)
llmConfig - llm参数配置protected abstract RESP getLLMResponse(List<ConversationMessage> chatMessages, LLMParamConfig llmParamConfig)
chatMessages - LLM模型输入llmParamConfig - 模型参数配置protected abstract RESP getLLMResponseFromCache(String cache)
cache - 缓存public void setStreamCallback(StreamCallBack streamCallback)
LLMsetStreamCallback in interface LLMstreamCallback - StreamCallBackpublic LLMConfig getLLMConfig()
LLMgetLLMConfig in interface LLMprotected String getExistPrompt(String prompt)
prompt - promptpublic RESP ask(String prompt, LLMParamConfig paramConfig)
LLMpublic <RESP extends LLMResp> RESP ask(List<ConversationMessage> chatMessages)
LLMpublic <RESP extends LLMResp> RESP ask(List<ConversationMessage> chatMessages, LLMParamConfig paramConfig)
LLMpublic <T> T askForObject(String prompt, Class<T> clazz)
LLMaskForObject in interface LLMT - 响应类prompt - ask LLMclazz - 需要LLM转换的类型public <T> T askForObject(String prompt, LLMParamConfig paramConfig, Class<T> clazz)
LLMaskForObject in interface LLMT - 响应类prompt - ask LLMparamConfig - LLM参数配置clazz - 需要LLM转换的类型protected boolean needAddNewSystemMessage()
Copyright © 2024. All rights reserved.