rag

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RagConfig, _ = getRagConfig()
View Source
var RagPromptTemplate = `` /* 463-byte string literal not displayed */

Functions

func ApplyChunkOverlap

func ApplyChunkOverlap(chunks []string, overlapSize int) []string

func ChunkFile

func ChunkFile(filePath string, chunkSize int) ([]string, error)

func ChunkReaderByLines

func ChunkReaderByLines(reader io.Reader, maxChunkSize int) ([]string, error)

ChunkReaderByLines Block by row

func ChunkStructuredFile

func ChunkStructuredFile(filePath string, maxChunkSize int) ([]string, error)

ChunkStructuredFile

func CreateOverlappingChunks

func CreateOverlappingChunks(chunks []string, overlapSize int) []string

CreateOverlappingChunks create overlapping blocks from the given text block chunks: original text block overlapSize: the size of the overlap (number of characters) Return a new block with overlap

func GetFileType

func GetFileType(fileExt string) string

Types

type AOGAPIResponse

type AOGAPIResponse struct {
	BusinessCode int         `json:"business_code"`
	Message      string      `json:"message"`
	Data         interface{} `json:"data"`
}

type AOGEmbeddingResponse

type AOGEmbeddingResponse struct {
	Object string `json:"object"`
	Data   []struct {
		Object    string    `json:"object"`
		Embedding []float32 `json:"embedding"`
		Index     int       `json:"index"`
	} `json:"data"`
	Model string         `json:"model"`
	Usage map[string]int `json:"usage"`
}

type AOGGenerateResponse

type AOGGenerateResponse struct {
	ID           string `json:"id"`
	Created      int64  `json:"created"`
	Model        string `json:"model"`
	Response     string `json:"response"`
	FinishReason string `json:"finish_reason"`
}

type ChunkScore

type ChunkScore struct {
	ChunkID    string
	Content    string
	Similarity float32
}

type EmbeddingData

type EmbeddingData struct {
	Object     string    `json:"object"`
	Embedding  []float32 `json:"embedding"`
	EmbedIndex int       `json:"index"`
}

type EmbeddingRequest

type EmbeddingRequest struct {
	Model string   `json:"model"`
	Input []string `json:"input"`
}

type EmbeddingResponse

type EmbeddingResponse struct {
	Object     string         `json:"object"`
	Embeddings [][]float32    `json:"embeddings"`
	Model      string         `json:"model"`
	Usage      EmbeddingUsage `json:"usage"`
}

type EmbeddingUsage

type EmbeddingUsage struct {
	PromptTokens int `json:"prompt_tokens"`
	TotalTokens  int `json:"total_tokens"`
}

type EngineService

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

func (*EngineService) Generate

Generate Implementing non-streaming text generation

func (*EngineService) GenerateEmbedding

func (e *EngineService) GenerateEmbedding(ctx context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error)

GenerateEmbedding Implement vector embedding generation function

type EngineServiceInterface

type EngineServiceInterface interface {
	// Generate
	Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)

	// GenerateEmbedding
	GenerateEmbedding(ctx context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error)
}

EngineServiceInterface Defines the core interface of the engine service

type EngineServiceProvider

type EngineServiceProvider interface {
	EngineServiceInterface
}

EngineServiceProvider Defines the core interface of the engine service

func NewEngineService

func NewEngineService() EngineServiceProvider

NewEngineService Create a new engine service instance

type GenerateRequest

type GenerateRequest struct {
	Model       string  `json:"model"`
	Prompt      string  `json:"prompt"`
	Temperature float32 `json:"temperature,omitempty"`
	MaxTokens   int     `json:"max_tokens,omitempty"`
	Stream      bool    `json:"stream,omitempty"`
	Think       bool    `json:"think"`
}

GenerateRequest

type GenerateResponse

type GenerateResponse struct {
	ID         string `json:"id"`
	Model      string `json:"model"`
	ModelName  string `json:"model_name,omitempty"` // 新增字段
	Content    string `json:"content"`
	IsComplete bool   `json:"is_complete"`        // 流式输出时,是否是最后一个块
	Thoughts   string `json:"thinking,omitempty"` // 深度思考的结果
}

GenerateResponse

Jump to

Keyboard shortcuts

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