Havoc412 81cd287109 feat(api): 新增 RAG 聊天模式和优化 ES 查询功能
- 新增 RAG 聊天模式常量和前端字段设定
- 修改 Encounters Create 方法中的 ES 同步逻辑
- 更新 Rag ChatSSE 和 ChatWebSocket 方法,支持新的聊天模式
- 重构 NlpWebSocketResult 创建函数,使用新增的常量
- 新增 Encounter 的 TopK 方法,用于 ES 向量搜索
- 更新 DocResult 结构,实现 DocInterface 接口
- 修改 prompts.yml,增加 Diary 模式的提示模板
2024-11-20 17:32:10 +08:00

30 lines
726 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model_res
import (
"catface/app/model"
"catface/app/model_es"
"fmt"
"time"
)
func NewEncounterResult(encounter *model.Encounter, encounter_es *model_es.Encounter) *EncounterResult {
return &EncounterResult{
DocBase: DocBase{Type: "encounter"},
Id: encounter.Id,
Title: encounter.Title,
Content: encounter.Content,
UpdatedAt: encounter.UpdatedAt}
}
type EncounterResult struct {
DocBase
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
UpdatedAt *time.Time `json:"updated_at"`
}
func (e EncounterResult) ToString() string {
return fmt.Sprintf(`路遇笔记标题:%s路遇笔记内容%s`, e.Title, e.Content)
}