corpus

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VectorLen = 1024

	PrefixQ = "Q:"
	PrefixA = "A:"
)
View Source
const (
	DocumentTable = "corpus_document"
	DocumentAlias = "cd"
	DocumentLabel = "document"
	DocumentTypID = "corpusDocument"
)

consts of Document 文档

View Source
const (
	DocVectorTable = "corpus_vector_400"
	DocVectorAlias = "cv"
	DocVectorLabel = "docVector"
	DocVectorTypID = "corpusDocVector"
)

consts of DocVector 文档向量

View Source
const (
	DocMatchLabel = "docMatch"
	DocMatchTypID = "corpusDocMatch"
)

consts of DocMatch 提示匹配结果

View Source
const (
	ChatLogTable = "qa_chat_log"
	ChatLogAlias = "cl"
	ChatLogLabel = "chatLog"
	ChatLogTypID = "corpusChatLog"
)

consts of ChatLog 聊天日志

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatLog

type ChatLog struct {
	comm.BaseModel `bun:"table:qa_chat_log,alias:cl" json:"-"`

	comm.DefaultModel

	ChatLogBasic

	comm.MetaField

} // @name corpusChatLog

ChatLog 聊天日志 Deprecated

func NewChatLogWithBasic

func NewChatLogWithBasic(in ChatLogBasic) *ChatLog

func NewChatLogWithID

func NewChatLogWithID(id any) *ChatLog

func (*ChatLog) Creating

func (z *ChatLog) Creating() error

Creating function call to it's inner fields defined hooks

func (*ChatLog) IdentityAlias

func (_ *ChatLog) IdentityAlias() string

func (*ChatLog) IdentityLabel

func (_ *ChatLog) IdentityLabel() string

func (*ChatLog) IdentityModel

func (_ *ChatLog) IdentityModel() string

func (*ChatLog) IdentityTable

func (_ *ChatLog) IdentityTable() string

func (*ChatLog) SetWith

func (z *ChatLog) SetWith(o ChatLogSet)

type ChatLogBasic

type ChatLogBasic struct {
	// 会话ID
	ChatID oid.OID `bun:"csid,notnull" extensions:"x-order=A" json:"csid" pg:"csid,notnull" swaggertype:"string"`
	// 提问
	Question string `bun:",notnull,type:text" extensions:"x-order=B" form:"prompt" json:"prompt" pg:",notnull,type:text"`
	// 回答
	Answer string `bun:",notnull,type:text" extensions:"x-order=C" form:"response" json:"response" pg:",notnull,type:text"`
	// for meta update
	MetaDiff *comm.MetaDiff `bson:"-" bun:"-" json:"metaUp,omitempty" pg:"-" swaggerignore:"true"`

} // @name corpusChatLogBasic

func (*ChatLogBasic) MetaAddKVs

func (in *ChatLogBasic) MetaAddKVs(args ...any) *ChatLogBasic

type ChatLogSet

type ChatLogSet struct {
	// 提问
	Question *string `extensions:"x-order=A" json:"prompt"`
	// 回答
	Answer *string `extensions:"x-order=B" json:"response"`
	// for meta update
	MetaDiff *comm.MetaDiff `json:"metaUp,omitempty" swaggerignore:"true"`

} // @name corpusChatLogSet

func (*ChatLogSet) MetaAddKVs

func (in *ChatLogSet) MetaAddKVs(args ...any) *ChatLogSet

type ChatLogs

type ChatLogs []ChatLog

type DocMatch

type DocMatch struct {
	// 文档编号
	DocID oid.OID `bun:"doc_id" extensions:"x-order=A" json:"docID" swaggertype:"string"`
	// 提示
	Subject string `bun:"subject" extensions:"x-order=B" form:"subject" json:"subject"`
	// 相似度
	Similarity float32 `bun:"similarity" extensions:"x-order=C" json:"similarity,omitempty"`

} // @name corpusDocMatch

DocMatch 提示匹配结果

type DocMatches

type DocMatches []DocMatch

func (DocMatches) DocumentIDs

func (z DocMatches) DocumentIDs() (out oid.OIDs)

func (DocMatches) Subjects

func (z DocMatches) Subjects() (out []string)

type DocVector

type DocVector struct {
	comm.BaseModel `bun:"table:corpus_vector_400,alias:cv" json:"-"`

	comm.DefaultModel

	DocVectorBasic

	// 相似度 仅用于查询结果
	Similarity float32 `bun:"-" extensions:"x-order=D" json:"similarity,omitempty" pg:"-"`

	comm.MetaField

} // @name corpusDocVector

DocVector 文档向量 400=1024, 600=1536

func NewDocVectorWithBasic

func NewDocVectorWithBasic(in DocVectorBasic) *DocVector

func NewDocVectorWithID

func NewDocVectorWithID(id any) *DocVector

func (*DocVector) Creating

func (z *DocVector) Creating() error

Creating function call to it's inner fields defined hooks

func (*DocVector) IdentityAlias

func (_ *DocVector) IdentityAlias() string

func (*DocVector) IdentityLabel

func (_ *DocVector) IdentityLabel() string

func (*DocVector) IdentityModel

func (_ *DocVector) IdentityModel() string

func (*DocVector) IdentityTable

func (_ *DocVector) IdentityTable() string

func (*DocVector) SetWith

func (z *DocVector) SetWith(o DocVectorSet)

type DocVectorBasic

type DocVectorBasic struct {
	// 文档编号
	DocID oid.OID `bun:"doc_id,notnull" extensions:"x-order=A" json:"docID" pg:"doc_id,notnull" swaggertype:"string"`
	// 主题 由名称+属性组成
	Subject string `bun:"subject,notnull,type:text" extensions:"x-order=B" form:"subject" json:"subject" pg:"subject,notnull,type:text"`
	// 向量值 长为1024的浮点数集
	Vector Vector `bun:"embedding,type:vector(1024)" extensions:"x-order=C" json:"vector,omitempty" pg:"embedding,type:vector(1024)"`
	// for meta update
	MetaDiff *comm.MetaDiff `bson:"-" bun:"-" json:"metaUp,omitempty" pg:"-" swaggerignore:"true"`

} // @name corpusDocVectorBasic

func (*DocVectorBasic) MetaAddKVs

func (in *DocVectorBasic) MetaAddKVs(args ...any) *DocVectorBasic

type DocVectorSet

type DocVectorSet struct {
	// 主题 由名称+属性组成
	Subject *string `extensions:"x-order=A" json:"subject"`
	// 向量值 长为1024的浮点数集
	Vector *Vector `extensions:"x-order=B" json:"vector,omitempty"`
	// for meta update
	MetaDiff *comm.MetaDiff `json:"metaUp,omitempty" swaggerignore:"true"`

} // @name corpusDocVectorSet

func (*DocVectorSet) MetaAddKVs

func (in *DocVectorSet) MetaAddKVs(args ...any) *DocVectorSet

type DocVectors

type DocVectors []DocVector

type Document

type Document struct {
	comm.BaseModel `bun:"table:corpus_document,alias:cd" json:"-"`

	comm.DefaultModel

	DocumentBasic

	comm.MetaField

} // @name corpusDocument

Document 文档 语料库

func NewDocumentWithBasic

func NewDocumentWithBasic(in DocumentBasic) *Document

func NewDocumentWithID

func NewDocumentWithID(id any) *Document

func (*Document) Creating

func (z *Document) Creating() error

Creating function call to it's inner fields defined hooks

func (*Document) GetSubject

func (z *Document) GetSubject() string

func (*Document) IdentityAlias

func (_ *Document) IdentityAlias() string

func (*Document) IdentityLabel

func (_ *Document) IdentityLabel() string

func (*Document) IdentityModel

func (_ *Document) IdentityModel() string

func (*Document) IdentityTable

func (_ *Document) IdentityTable() string

func (*Document) SetWith

func (z *Document) SetWith(o DocumentSet)

type DocumentBasic

type DocumentBasic struct {
	// 主标题 名称
	Title string `` /* 161-byte string literal not displayed */
	// 小节标题 属性 类别
	Heading string `` /* 165-byte string literal not displayed */
	// 内容 值
	Content string `bun:",notnull,type:text" extensions:"x-order=C" form:"content" json:"content" pg:",notnull,type:text"`
	// for meta update
	MetaDiff *comm.MetaDiff `bson:"-" bun:"-" json:"metaUp,omitempty" pg:"-" swaggerignore:"true"`

} // @name corpusDocumentBasic

func (*DocumentBasic) MetaAddKVs

func (in *DocumentBasic) MetaAddKVs(args ...any) *DocumentBasic

type DocumentSet

type DocumentSet struct {
	// 主标题 名称
	Title *string `extensions:"x-order=A" json:"title"`
	// 小节标题 属性 类别
	Heading *string `extensions:"x-order=B" json:"heading"`
	// 内容 值
	Content *string `extensions:"x-order=C" json:"content"`
	// for meta update
	MetaDiff *comm.MetaDiff `json:"metaUp,omitempty" swaggerignore:"true"`

} // @name corpusDocumentSet

func (*DocumentSet) MetaAddKVs

func (in *DocumentSet) MetaAddKVs(args ...any) *DocumentSet

type Documents

type Documents []Document

func (Documents) Headings

func (z Documents) Headings() []string

func (Documents) IDs

func (z Documents) IDs() (out oid.OIDs)

func (Documents) MarkdownText

func (z Documents) MarkdownText() string

type Pair

type Pair struct {
	Question string `json:"Q"`
	Anwser   string `json:"A"`
}

Pair 一对问答

type Pairs

type Pairs []Pair

func ParseText

func ParseText(text string) (result Pairs)

type Vector

type Vector []float32

Jump to

Keyboard shortcuts

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