|
@@ -27,7 +27,7 @@ const (
|
|
|
DEFALUT_PROMPT_NAME = "default"
|
|
|
CONTENT_TYPE_JSON = "application/json"
|
|
|
KNOWLEDGE_BASE_CHAT_API = "/chat/kb_chat"
|
|
|
- DOCUMENT_CHAT_API = "/chat/file_chat"
|
|
|
+ DOCUMENT_CHAT_API = "/chat/file_chat"
|
|
|
KNOWLEDGE_BASE_SEARCH_DOCS_API = "/knowledge_base/search_docs"
|
|
|
)
|
|
|
|
|
@@ -64,14 +64,19 @@ func GetInstance() llm.LLMService {
|
|
|
return etaLlmClient
|
|
|
}
|
|
|
|
|
|
-func (ds *ETALLMClient) DocumentChat(query string, KnowledgeId string, history []string, stream bool) (llmRes *http.Response, err error) {
|
|
|
+func (ds *ETALLMClient) DocumentChat(query string, KnowledgeId string, history []json.RawMessage, stream bool) (llmRes *http.Response, err error) {
|
|
|
ChatHistory := make([]eta_llm_http.HistoryContent, 0)
|
|
|
for _, historyItemStr := range history {
|
|
|
- str := strings.Split(historyItemStr, "-")
|
|
|
- historyItem := eta_llm_http.HistoryContent{
|
|
|
- Role: str[0],
|
|
|
- Content: str[1],
|
|
|
+ var historyItem eta_llm_http.HistoryContent
|
|
|
+ parseErr := json.Unmarshal(historyItemStr, &historyItem)
|
|
|
+ if parseErr != nil {
|
|
|
+ continue
|
|
|
}
|
|
|
+ //str := strings.Split(historyItemStr, "-")
|
|
|
+ //historyItem := eta_llm_http.HistoryContent{
|
|
|
+ // Role: str[0],
|
|
|
+ // Content: str[1],
|
|
|
+ //}
|
|
|
ChatHistory = append(ChatHistory, historyItem)
|
|
|
}
|
|
|
kbReq := eta_llm_http.DocumentChatRequest{
|
|
@@ -93,13 +98,18 @@ func (ds *ETALLMClient) DocumentChat(query string, KnowledgeId string, history [
|
|
|
}
|
|
|
return ds.DoStreamPost(DOCUMENT_CHAT_API, body)
|
|
|
}
|
|
|
-func (ds *ETALLMClient) KnowledgeBaseChat(query string, KnowledgeBaseName string, history []string) (llmRes *http.Response, err error) {
|
|
|
+func (ds *ETALLMClient) KnowledgeBaseChat(query string, KnowledgeBaseName string, history []json.RawMessage) (llmRes *http.Response, err error) {
|
|
|
ChatHistory := make([]eta_llm_http.HistoryContent, 0)
|
|
|
for _, historyItemStr := range history {
|
|
|
- str := strings.Split(historyItemStr, "-")
|
|
|
- historyItem := eta_llm_http.HistoryContent{
|
|
|
- Role: str[0],
|
|
|
- Content: str[1],
|
|
|
+ //str := strings.Split(historyItemStr, "-")
|
|
|
+ //historyItem := eta_llm_http.HistoryContent{
|
|
|
+ // Role: str[0],
|
|
|
+ // Content: str[1],
|
|
|
+ //}
|
|
|
+ var historyItem eta_llm_http.HistoryContent
|
|
|
+ parseErr := json.Unmarshal(historyItemStr, &historyItem)
|
|
|
+ if parseErr != nil {
|
|
|
+ continue
|
|
|
}
|
|
|
ChatHistory = append(ChatHistory, historyItem)
|
|
|
}
|