rag

package
v0.0.0-...-0e769ad Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserRole      = "user"
	AssistantRole = "assistant"
	Temperature   = 0.3   // LLM parameter - Sampling temperature, lower is more deterministic, higher is more creative.
	TopP          = 1     // LLM parameter - Alternative to temperature, take the tokens with the top p probability.
	LogProbs      = false // LLM parameter - Whether to return log probabilities of the output tokens.
)
View Source
const BatchSize = 100

BatchSize is the maximal number of documents manipulated at once by the worker.

View Source
const DocTypeVersion = "1"

DocTypeVersion represents the doctype version. Each time this document structure is modified, update this value

Variables

This section is empty.

Functions

func CallRAGQuery

func CallRAGQuery(inst *instance.Instance, payload []byte, path string, contentType string) (*http.Response, error)

func CleanInstance

func CleanInstance(inst *instance.Instance) error

func Index

func Index(inst *instance.Instance, logger logger.Logger, msg IndexMessage) error

func Query

func Query(inst *instance.Instance, logger logger.Logger, query QueryMessage) error

Types

type ChatConversation

type ChatConversation struct {
	DocID    string                 `json:"_id"`
	DocRev   string                 `json:"_rev,omitempty"`
	Messages []ChatMessage          `json:"messages"`
	Metadata *metadata.CozyMetadata `json:"cozyMetadata"`
}

func Chat

func Chat(inst *instance.Instance, payload ChatPayload) (*ChatConversation, error)

func (*ChatConversation) Clone

func (c *ChatConversation) Clone() couchdb.Doc

func (*ChatConversation) DocType

func (c *ChatConversation) DocType() string

func (*ChatConversation) ID

func (c *ChatConversation) ID() string

func (*ChatConversation) Included

func (c *ChatConversation) Included() []jsonapi.Object
func (c *ChatConversation) Links() *jsonapi.LinksList

func (*ChatConversation) Relationships

func (c *ChatConversation) Relationships() jsonapi.RelationshipMap

func (*ChatConversation) Rev

func (c *ChatConversation) Rev() string

func (*ChatConversation) SetID

func (c *ChatConversation) SetID(id string)

func (*ChatConversation) SetRev

func (c *ChatConversation) SetRev(rev string)

type ChatMessage

type ChatMessage struct {
	ID        string    `json:"id"`
	Role      string    `json:"role"`
	Content   string    `json:"content"`
	Sources   []Source  `json:"sources,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
}

type ChatPayload

type ChatPayload struct {
	ChatConversationID string
	Query              string `json:"q"`
}

type IndexMessage

type IndexMessage struct {
	Doctype string `json:"doctype"`
}

type QueryMessage

type QueryMessage struct {
	Task  string `json:"task"`
	DocID string `json:"doc_id"`
}

type Source

type Source struct {
	ID             string `json:"id"`
	DocType        string `json:"doctype"`
	Filename       string `json:"filename"`
	FileURL        string `json:"fileUrl"`
	ChunkURL       string `json:"chunkUrl"`
	Page           int    `json:"page"`
	EmailPreview   string `json:"email.preview,omitempty"`
	RelationshipID string `json:"relationship_id,omitempty"`
	ParentID       string `json:"parent_id,omitempty"`
	Subject        string `json:"email.subject,omitempty"`
	Datetime       string `json:"datetime,omitempty"`
}

Jump to

Keyboard shortcuts

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