services

package
v0.0.0-...-15e837a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTopK = 5
)

默认配置

Variables

This section is empty.

Functions

func AuthenticateUser

func AuthenticateUser(username, password string) (string, error)

func CreateConversation

func CreateConversation(userID int64, title, model, apiKey string) (*models.CreateConversationResp, error)

CreateConversation 创建新的会话

func DeleteUserConversation

func DeleteUserConversation(userID int64, conversationID int64) error

DeleteUserConversation 删除指定的用户对话

func GetConversationHistory

func GetConversationHistory(conversationID int64) (*models.ConversationHistory, error)

GetConversationHistory 获取完整的会话历史

func GetUserConversations

func GetUserConversations(userID int64) ([]models.ConversationSummary, error)

GetUserConversations 查询用户的所有对话

func RegisterUser

func RegisterUser(username, password string) error

func StreamSendMessage

func StreamSendMessage(c *gin.Context, conversationID int64, message string) error

StreamSendMessage 处理流式消息发送

Types

type RAGService

type RAGService struct {
	// contains filtered or unexported fields
}

RAGService 提供 RAG 相关功能

func GetRAGService

func GetRAGService() (*RAGService, error)

GetRAGService 获取 RAG 服务单例

func (*RAGService) Close

func (s *RAGService) Close()

Close 关闭 RAG 服务

func (*RAGService) CreateKnowledgeBase

func (s *RAGService) CreateKnowledgeBase(uid, kbName, embeddingModel string) (*models.CreateKnowledgeBaseResponse, error)

CreateKnowledgeBase 创建知识库

func (*RAGService) DeleteDocument

func (s *RAGService) DeleteDocument(uid, kbID, docID string) (*models.DeleteDocumentResponse, error)

DeleteDocument 删除文档

func (*RAGService) DeleteKnowledgeBase

func (s *RAGService) DeleteKnowledgeBase(uid, kbID string) (*models.DeleteKnowledgeBaseResponse, error)

DeleteKnowledgeBase 删除知识库

func (*RAGService) GenerateRagPrompt

func (s *RAGService) GenerateRagPrompt(kbID, query string, topK int) (string, error)

GenerateRagPrompt 生成基于知识库的对话提示

func (*RAGService) ListDocuments

func (s *RAGService) ListDocuments(kbID string) (*models.ListDocumentsResponse, error)

ListDocuments 获取知识库中的文档列表

func (*RAGService) ListEmbeddingModels

func (s *RAGService) ListEmbeddingModels() (*models.ListEmbeddingModelsResponse, error)

ListEmbeddingModels 获取支持的嵌入模型列表

func (*RAGService) ListKnowledgeBases

func (s *RAGService) ListKnowledgeBases(uid string) (*models.ListKnowledgeBasesResponse, error)

ListKnowledgeBases 获取用户的知识库列表

func (*RAGService) RetrieveInfo

func (s *RAGService) RetrieveInfo(kbID, query string, topK int) (*models.RetrieveResponse, error)

RetrieveInfo 从知识库检索信息

func (*RAGService) UploadDocument

func (s *RAGService) UploadDocument(uid, kbID, docName string, fileContent []byte, fileType string) (*models.UploadDocumentResponse, error)

UploadDocument 上传文档

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL