#github.com/xulang-org/packages/rag
Xu 0.16.0 API
import: rag #github.com/xulang-org/packages/rag
counts: 33 functions, 48 methods, 12 types, 0 constants, 0 method sets
External package `rag #github.com/xulang-org/packages/rag`, provided by github.com/xulang-org/packages.
github.com/xulang-org/packages · 1.17.2 · Install and use
struct Chunk
pub struct Chunk {
pub id string
pub doc_id string
pub text string
pub source string
pub metadata_json string
pub embedding []f32
}
Purpose
Structure encapsulating id, doc_id, text, source, metadata_json.
Public fields
id string- field (string)
doc_id string- field (string)
text string- text
source string- field (string)
metadata_json string- field (string)
embedding []f32- field ([]f32)
struct SearchHit
pub struct SearchHit {
pub chunk Chunk
pub score f64
}
Purpose
Structure encapsulating chunk, score.
Public fields
chunk Chunk- field (Chunk)
score f64- field (f64)
struct MemoryStore
pub struct MemoryStore {
pub dim int
pub chunks []Chunk
}
Purpose
Structure encapsulating dim, chunks.
Public fields
dim int- field (int)
chunks []Chunk- field ([]Chunk)
struct ParentChildDoc
pub struct ParentChildDoc {
pub parents []Chunk
pub children []Chunk
}
Purpose
Structure encapsulating parents, children.
Public fields
parents []Chunk- field ([]Chunk)
children []Chunk- field ([]Chunk)
new_store
pub fn new_store(dim int) MemoryStore
Purpose
Construct store.
Parameters
dim int- dim (int)
Returns
MemoryStore — a value of this type
(&MemoryStore) len
pub fn (s &MemoryStore) len() int
Purpose
Operation on &MemoryStore: return the length.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
Returns
int — a value of this type
chunk_text
pub fn chunk_text(text string, chunk_size int, overlap int) []string
Purpose
Chunk text.
Parameters
text string- text (string)
chunk_size int- chunk_size (int)
overlap int- overlap (int)
Returns
[]string — slice result
chunk_recursive
pub fn chunk_recursive(text string, max_chars int, overlap int) []string
Purpose
Chunk recursive.
Parameters
text string- text (string)
max_chars int- max_chars (int)
overlap int- overlap (int)
Returns
[]string — slice result
($&MemoryStore) add_chunk
pub fn (s $&MemoryStore) add_chunk(id string, doc_id string, text string, source string, metadata_json string, embedding &[]f64) int
Purpose
Operation on $&MemoryStore: add chunk. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&MemoryStore- The
MemoryStore instance used by this call (exclusive borrow).
id string- id (string)
doc_id string- doc_id (string)
text string- text (string)
source string- source (string)
metadata_json string- metadata_json (string)
embedding &[]f64- embedding (read-only borrow; caller keeps the original; type &[]f64)
Returns
int — a value of this type
(&MemoryStore) search
pub fn (s &MemoryStore) search(query_emb &[]f64, top_k int, filter_doc_id string) []SearchHit
Purpose
Operation on &MemoryStore: binary search. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
(&MemoryStore) save_json
pub fn (s &MemoryStore) save_json(path string) int
Purpose
Operation on &MemoryStore: save json. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
path string- filesystem path (string)
Returns
int — a value of this type
load_json
pub fn load_json(path string) MemoryStore
Purpose
Load json. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
Returns
MemoryStore — a value of this type
index_document
pub fn index_document(store $&MemoryStore, client &openai.Client, embed_model string, doc_id string, source string, text string, chunk_size int, overlap int, metadata_json string) int
Purpose
Index document. Throws on failure; handle the error or propagate it to the caller.
Parameters
store $&MemoryStore- store (exclusive borrow; may modify the original; type $&MemoryStore)
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
embed_model string- embed_model (string)
doc_id string- doc_id (string)
source string- source (string)
text string- text (string)
chunk_size int- chunk_size (int)
overlap int- overlap (int)
metadata_json string- metadata_json (string)
Returns
int — index; see the description for its range and special values
retrieve
pub fn retrieve(store &MemoryStore, client &openai.Client, embed_model string, query string, top_k int, filter_doc_id string) []SearchHit
Purpose
Execute retrieve. Throws on failure; handle the error or propagate it to the caller.
Parameters
store &MemoryStore- store (read-only borrow; caller keeps the original; type &MemoryStore)
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
embed_model string- embed_model (string)
query string- query (string)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
format_context
pub fn format_context(hits &[]SearchHit) string
Purpose
Format as context.
Parameters
hits &[]SearchHit- hits (read-only borrow; caller keeps the original; type &[]SearchHit)
Returns
string — result string
chunk_markdown
pub fn chunk_markdown(doc_id string, source string, markdown string, max_chars int, overlap int) []Chunk
Purpose
Chunk markdown.
Parameters
doc_id string- doc_id (string)
source string- source (string)
markdown string- markdown (string)
max_chars int- max_chars (int)
overlap int- overlap (int)
Returns
[]Chunk — slice result
(&MemoryStore) search_bm25_filtered
pub fn (s &MemoryStore) search_bm25_filtered(query string, top_k int, filter_doc_id string) []SearchHit
Purpose
Operation on &MemoryStore: binary search bm25 filtered.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query string- query (string)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
(&MemoryStore) search_bm25
pub fn (s &MemoryStore) search_bm25(query string, top_k int) []SearchHit
Purpose
Operation on &MemoryStore: binary search bm25.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query string- query (string)
top_k int- top_k (int)
Returns
[]SearchHit — slice result
(&MemoryStore) search_hybrid_filtered
pub fn (s &MemoryStore) search_hybrid_filtered(query string, query_emb &[]f64, top_k int, rrf_k int, filter_doc_id string) []SearchHit
Purpose
Operation on &MemoryStore: binary search hybrid filtered.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
rrf_k int- rrf_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
(&MemoryStore) search_hybrid
pub fn (s &MemoryStore) search_hybrid(query string, query_emb &[]f64, top_k int, rrf_k int) []SearchHit
Purpose
Operation on &MemoryStore: binary search hybrid.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
rrf_k int- rrf_k (int)
Returns
[]SearchHit — slice result
(&MemoryStore) retrieve_hybrid
pub fn (s &MemoryStore) retrieve_hybrid(query string, query_emb &[]f64, top_k int, rrf_k int) string
Purpose
Operation on &MemoryStore: retrieve hybrid.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
rrf_k int- rrf_k (int)
Returns
string — result string
(&MemoryStore) search_mmr
pub fn (s &MemoryStore) search_mmr(query_emb &[]f64, top_k int, lambda f64, filter_doc_id string) []SearchHit
Purpose
Operation on &MemoryStore: binary search mmr. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
lambda f64- lambda (f64)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
($&MemoryStore) delete_doc
pub fn (s $&MemoryStore) delete_doc(doc_id string) int
Purpose
Operation on $&MemoryStore: delete doc.
Parameters
s $&MemoryStore- The
MemoryStore instance used by this call (exclusive borrow).
doc_id string- doc_id (string)
Returns
int — a value of this type
(&MemoryStore) search_by_meta
pub fn (s &MemoryStore) search_by_meta(query_emb &[]f64, top_k int, filter_doc_id string, meta_key string, meta_val string) []SearchHit
Purpose
Operation on &MemoryStore: binary search by meta. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
meta_key string- meta_key (string)
meta_val string- meta_val (string)
Returns
[]SearchHit — slice result
(&MemoryStore) search_hybrid_by_meta
pub fn (s &MemoryStore) search_hybrid_by_meta(query string, query_emb &[]f64, top_k int, rrf_k int, filter_doc_id string, meta_key string, meta_val string) []SearchHit
Purpose
Operation on &MemoryStore: binary search hybrid by meta.
Parameters
s &MemoryStore- The
MemoryStore instance used by this call (borrow).
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
rrf_k int- rrf_k (int)
filter_doc_id string- filter_doc_id (string)
meta_key string- meta_key (string)
meta_val string- meta_val (string)
Returns
[]SearchHit — slice result
rerank_hits
pub fn rerank_hits(hits &[]SearchHit, scores &[]f64, top_k int) []SearchHit
Purpose
Rerank hits.
Parameters
hits &[]SearchHit- hits (read-only borrow; caller keeps the original; type &[]SearchHit)
scores &[]f64- scores (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
Returns
[]SearchHit — slice result
rerank_with_api
pub fn rerank_with_api(client &openai.Client, model string, query string, hits &[]SearchHit, top_k int) []SearchHit
Purpose
Rerank with api. Throws on failure; handle the error or propagate it to the caller.
Parameters
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
query string- query (string)
hits &[]SearchHit- hits (read-only borrow; caller keeps the original; type &[]SearchHit)
top_k int- top_k (int)
Returns
[]SearchHit — slice result
chunk_parent_child
pub fn chunk_parent_child(doc_id string, source string, text string, parent_chars int, child_chars int, overlap int) ParentChildDoc
Purpose
Chunk parent child.
Parameters
doc_id string- doc_id (string)
source string- source (string)
text string- text (string)
parent_chars int- parent_chars (int)
child_chars int- child_chars (int)
overlap int- overlap (int)
Returns
ParentChildDoc — a value of this type
expand_to_parents
pub fn expand_to_parents(child_hits &[]SearchHit, parents &[]Chunk) []SearchHit
Purpose
Expand to parents.
Parameters
child_hits &[]SearchHit- child_hits (read-only borrow; caller keeps the original; type &[]SearchHit)
parents &[]Chunk- parents (read-only borrow; caller keeps the original; type &[]Chunk)
Returns
[]SearchHit — slice result
expand_queries_openai
pub fn expand_queries_openai(client &openai.Client, model string, query string, n int) []string
Purpose
Expand queries openai. Throws on failure; handle the error or propagate it to the caller.
Parameters
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
query string- query (string)
n int- count, length, or limit (int)
Returns
[]string — slice result
hyde_document_openai
pub fn hyde_document_openai(client &openai.Client, model string, query string) string
Purpose
Hyde document openai. Throws on failure; handle the error or propagate it to the caller.
Parameters
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
query string- query (string)
Returns
string — result string
compress_context
pub fn compress_context(query &string, hits &[]SearchHit, max_sentences_per_hit int) []SearchHit
Purpose
Compress context.
Parameters
query &string- query (read-only borrow; caller keeps the original; type &string)
hits &[]SearchHit- hits (read-only borrow; caller keeps the original; type &[]SearchHit)
max_sentences_per_hit int- max_sentences_per_hit (int)
Returns
[]SearchHit — slice result
format_context_cited
pub fn format_context_cited(hits &[]SearchHit) string
Purpose
Format as context cited.
Parameters
hits &[]SearchHit- hits (read-only borrow; caller keeps the original; type &[]SearchHit)
Returns
string — result string
struct PgVectorStore
pub struct PgVectorStore {
pub table string
pub dim int
pub metric string
}
Purpose
Structure encapsulating table, dim, metric.
Public fields
table string- field (string)
dim int- field (int)
metric string- field (string)
new_pgvector_store
pub fn new_pgvector_store(table string, dim int, metric string) PgVectorStore
Purpose
Construct pgvector store. Throws on failure; handle the error or propagate it to the caller.
Parameters
table string- table (string)
dim int- dim (int)
metric string- metric (string)
Returns
PgVectorStore — a value of this type
(&PgVectorStore) create_table_sql
pub fn (s &PgVectorStore) create_table_sql() string
Purpose
Operation on &PgVectorStore: create table sql.
Parameters
s &PgVectorStore- The
PgVectorStore instance used by this call (borrow).
Returns
string — result string
(&PgVectorStore) create_index_sql
pub fn (s &PgVectorStore) create_index_sql(index_name string, method string) string
Purpose
Operation on &PgVectorStore: create index sql. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &PgVectorStore- The
PgVectorStore instance used by this call (borrow).
index_name string- index_name (string)
method string- method (string)
Returns
string — result string
(&PgVectorStore) upsert_chunk_sql
pub fn (s &PgVectorStore) upsert_chunk_sql(c &Chunk) string
Purpose
Operation on &PgVectorStore: upsert chunk sql. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &PgVectorStore- The
PgVectorStore instance used by this call (borrow).
c &Chunk- byte or character code (read-only borrow; caller keeps the original; type &Chunk)
Returns
string — result string
(&PgVectorStore) search_sql
pub fn (s &PgVectorStore) search_sql(query_emb &[]f64, top_k int, filter_doc_id string) string
Purpose
Operation on &PgVectorStore: binary search sql. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &PgVectorStore- The
PgVectorStore instance used by this call (borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
string — result string
chunk_code
pub fn chunk_code(code string, max_chars int, overlap int) []string
Purpose
Chunk code.
Parameters
code string- code (string)
max_chars int- max_chars (int)
overlap int- overlap (int)
Returns
[]string — slice result
rerank_with_cohere
pub fn rerank_with_cohere(client &cohere.Client, model string, query string, hits &[]SearchHit, top_k int) []SearchHit
Purpose
Rerank with cohere. Throws on failure; handle the error or propagate it to the caller.
Parameters
client &cohere.Client- client (read-only borrow; caller keeps the original; type &cohere.Client)
model string- model (string)
query string- query (string)
hits &[]SearchHit- hits (read-only borrow; caller keeps the original; type &[]SearchHit)
top_k int- top_k (int)
Returns
[]SearchHit — slice result
struct Triple
pub struct Triple {
pub subject string
pub predicate string
pub object string
pub source string
}
Purpose
Structure encapsulating subject, predicate, object, source.
Public fields
subject string- field (string)
predicate string- field (string)
object string- field (string)
source string- field (string)
struct KnowledgeGraph
pub struct KnowledgeGraph {
pub triples []Triple
}
Purpose
Structure encapsulating triples.
Public fields
triples []Triple- field ([]Triple)
new_knowledge_graph
pub fn new_knowledge_graph() KnowledgeGraph
Purpose
Construct knowledge graph.
Parameters
No arguments are required.
Returns
KnowledgeGraph — a value of this type
(&KnowledgeGraph) len
pub fn (kg &KnowledgeGraph) len() int
Purpose
Operation on &KnowledgeGraph: return the length.
Parameters
kg &KnowledgeGraph- The
KnowledgeGraph instance used by this call (borrow).
Returns
int — a value of this type
($&KnowledgeGraph) add_triple
pub fn (kg $&KnowledgeGraph) add_triple(subject string, predicate string, object string, source string)
Purpose
Operation on $&KnowledgeGraph: add triple.
Parameters
kg $&KnowledgeGraph- The
KnowledgeGraph instance used by this call (exclusive borrow).
subject string- subject (string)
predicate string- predicate (string)
object string- object (string)
source string- source (string)
Returns
This call does not return a value.
(&KnowledgeGraph) query_neighbors
pub fn (kg &KnowledgeGraph) query_neighbors(entity string, max_hops int) []Triple
Purpose
Operation on &KnowledgeGraph: query neighbors.
Parameters
kg &KnowledgeGraph- The
KnowledgeGraph instance used by this call (borrow).
entity string- entity (string)
max_hops int- max_hops (int)
Returns
[]Triple — slice result
format_subgraph
pub fn format_subgraph(triples &[]Triple) string
Purpose
Format as subgraph.
Parameters
triples &[]Triple- triples (read-only borrow; caller keeps the original; type &[]Triple)
Returns
string — result string
(&KnowledgeGraph) save_json
pub fn (kg &KnowledgeGraph) save_json(path string) int
Purpose
Operation on &KnowledgeGraph: save json. Throws on failure; handle the error or propagate it to the caller.
Parameters
kg &KnowledgeGraph- The
KnowledgeGraph instance used by this call (borrow).
path string- filesystem path (string)
Returns
int — a value of this type
load_knowledge_graph_json
pub fn load_knowledge_graph_json(path string) KnowledgeGraph
Purpose
Load knowledge graph json. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
Returns
KnowledgeGraph — a value of this type
contextualize_chunks_openai
pub fn contextualize_chunks_openai(client &openai.Client, model string, doc_title string, full_doc_summary string, chunks &[]string) []string
Purpose
Contextualize chunks openai. Throws on failure; handle the error or propagate it to the caller.
Parameters
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
doc_title string- doc_title (string)
full_doc_summary string- full_doc_summary (string)
chunks &[]string- chunks (read-only borrow; caller keeps the original; type &[]string)
Returns
[]string — slice result
struct HybridGraphResult
pub struct HybridGraphResult {
pub hits []SearchHit
pub graph_triples []Triple
pub formatted_context string
}
Purpose
Structure encapsulating hits, graph_triples, formatted_context.
Public fields
hits []SearchHit- field ([]SearchHit)
graph_triples []Triple- field ([]Triple)
formatted_context string- field (string)
hybrid_graph_vector_search
pub fn hybrid_graph_vector_search(store &MemoryStore, kg &KnowledgeGraph, query string, query_emb &[]f64, seed_entities &[]string, top_k int, graph_hops int) HybridGraphResult
Purpose
Hybrid graph vector binary search.
Parameters
store &MemoryStore- store (read-only borrow; caller keeps the original; type &MemoryStore)
kg &KnowledgeGraph- kg (read-only borrow; caller keeps the original; type &KnowledgeGraph)
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
seed_entities &[]string- seed_entities (read-only borrow; caller keeps the original; type &[]string)
top_k int- top_k (int)
graph_hops int- graph_hops (int)
Returns
HybridGraphResult — a value of this type
struct PgVectorClient
pub struct PgVectorClient {
pub store PgVectorStore
}
Purpose
Rag Client session maintaining connection and operations.
Public fields
store PgVectorStore- field (PgVectorStore)
new_pgvector_client
pub fn new_pgvector_client(conn driver.Conn, table string, dim int, metric string) PgVectorClient
Purpose
Construct pgvector client. Throws on failure; handle the error or propagate it to the caller.
Parameters
conn driver.Conn- conn (driver.Conn)
table string- table (string)
dim int- dim (int)
metric string- metric (string)
Returns
PgVectorClient — a value of this type
open_pgvector_client
pub fn open_pgvector_client(dsn string, table string, dim int, metric string) PgVectorClient
Purpose
Open pgvector client. Throws on failure; handle the error or propagate it to the caller.
Parameters
dsn string- dsn (string)
table string- table (string)
dim int- dim (int)
metric string- metric (string)
Returns
PgVectorClient — a value of this type
($&PgVectorClient) ensure_table
pub fn (c $&PgVectorClient) ensure_table() int
Purpose
Operation on $&PgVectorClient: ensure table. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&PgVectorClient- The
PgVectorClient instance used by this call (exclusive borrow).
Returns
int — a value of this type
($&PgVectorClient) ensure_index
pub fn (c $&PgVectorClient) ensure_index(index_name string, method string) int
Purpose
Operation on $&PgVectorClient: ensure index. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&PgVectorClient- The
PgVectorClient instance used by this call (exclusive borrow).
index_name string- index_name (string)
method string- method (string)
Returns
int — index; see the description for its range and special values
($&PgVectorClient) upsert_chunk
pub fn (c $&PgVectorClient) upsert_chunk(ch &Chunk) int
Purpose
Operation on $&PgVectorClient: upsert chunk. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&PgVectorClient- The
PgVectorClient instance used by this call (exclusive borrow).
ch &Chunk- character code (read-only borrow; caller keeps the original; type &Chunk)
Returns
int — a value of this type
($&PgVectorClient) delete_doc
pub fn (c $&PgVectorClient) delete_doc(doc_id string) int
Purpose
Operation on $&PgVectorClient: delete doc. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&PgVectorClient- The
PgVectorClient instance used by this call (exclusive borrow).
doc_id string- doc_id (string)
Returns
int — a value of this type
($&PgVectorClient) search
pub fn (c $&PgVectorClient) search(query_emb &[]f64, top_k int, filter_doc_id string) []SearchHit
Purpose
Operation on $&PgVectorClient: binary search. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&PgVectorClient- The
PgVectorClient instance used by this call (exclusive borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
($&PgVectorClient) close
pub fn (c $&PgVectorClient) close() int
Purpose
Operation on $&PgVectorClient: close the resource. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&PgVectorClient- The
PgVectorClient instance used by this call (exclusive borrow).
Returns
int — a value of this type
struct PgVectorPool
pub struct PgVectorPool {
pub store PgVectorStore
}
Purpose
Rag Connection pool manager scheduling reusable socket connections.
Public fields
store PgVectorStore- field (PgVectorStore)
new_pgvector_pool
pub fn new_pgvector_pool(db sql.DB, table string, dim int, metric string) PgVectorPool
Purpose
Construct pgvector pool. Throws on failure; handle the error or propagate it to the caller.
Parameters
db sql.DB- db (sql.DB)
table string- table (string)
dim int- dim (int)
metric string- metric (string)
Returns
PgVectorPool — a value of this type
open_pgvector_pool
pub fn open_pgvector_pool(dsn string, table string, dim int, metric string, max_open int, max_idle int) PgVectorPool
Purpose
Open pgvector pool. Throws on failure; handle the error or propagate it to the caller.
Parameters
dsn string- dsn (string)
table string- table (string)
dim int- dim (int)
metric string- metric (string)
max_open int- max_open (int)
max_idle int- max_idle (int)
Returns
PgVectorPool — a value of this type
(&PgVectorPool) ensure_table
pub fn (p &PgVectorPool) ensure_table() int
Purpose
Operation on &PgVectorPool: ensure table. Throws on failure; handle the error or propagate it to the caller.
Parameters
p &PgVectorPool- The
PgVectorPool instance used by this call (borrow).
Returns
int — a value of this type
(&PgVectorPool) ensure_index
pub fn (p &PgVectorPool) ensure_index(index_name string, method string) int
Purpose
Operation on &PgVectorPool: ensure index. Throws on failure; handle the error or propagate it to the caller.
Parameters
p &PgVectorPool- The
PgVectorPool instance used by this call (borrow).
index_name string- index_name (string)
method string- method (string)
Returns
int — index; see the description for its range and special values
(&PgVectorPool) upsert_chunk
pub fn (p &PgVectorPool) upsert_chunk(ch &Chunk) int
Purpose
Operation on &PgVectorPool: upsert chunk. Throws on failure; handle the error or propagate it to the caller.
Parameters
p &PgVectorPool- The
PgVectorPool instance used by this call (borrow).
ch &Chunk- character code (read-only borrow; caller keeps the original; type &Chunk)
Returns
int — a value of this type
(&PgVectorPool) delete_doc
pub fn (p &PgVectorPool) delete_doc(doc_id string) int
Purpose
Operation on &PgVectorPool: delete doc. Throws on failure; handle the error or propagate it to the caller.
Parameters
p &PgVectorPool- The
PgVectorPool instance used by this call (borrow).
doc_id string- doc_id (string)
Returns
int — a value of this type
(&PgVectorPool) search
pub fn (p &PgVectorPool) search(query_emb &[]f64, top_k int, filter_doc_id string) []SearchHit
Purpose
Operation on &PgVectorPool: binary search. Throws on failure; handle the error or propagate it to the caller.
Parameters
p &PgVectorPool- The
PgVectorPool instance used by this call (borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
($&PgVectorPool) close
pub fn (p $&PgVectorPool) close() int
Purpose
Operation on $&PgVectorPool: close the resource. Throws on failure; handle the error or propagate it to the caller.
Parameters
p $&PgVectorPool- The
PgVectorPool instance used by this call (exclusive borrow).
Returns
int — a value of this type
struct SqliteVectorStore
pub struct SqliteVectorStore {
pub table string
pub dim int
}
Purpose
Structure encapsulating table, dim.
Public fields
table string- field (string)
dim int- field (int)
new_sqlite_store
pub fn new_sqlite_store(conn driver.Conn, table string, dim int) SqliteVectorStore
Purpose
Construct sqlite store. Throws on failure; handle the error or propagate it to the caller.
Parameters
conn driver.Conn- conn (driver.Conn)
table string- table (string)
dim int- dim (int)
Returns
SqliteVectorStore — a value of this type
open_sqlite_store
pub fn open_sqlite_store(path string, table string, dim int) SqliteVectorStore
Purpose
Open sqlite store. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
table string- table (string)
dim int- dim (int)
Returns
SqliteVectorStore — a value of this type
($&SqliteVectorStore) upsert_chunk
pub fn (s $&SqliteVectorStore) upsert_chunk(c &Chunk) int
Purpose
Operation on $&SqliteVectorStore: upsert chunk. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&SqliteVectorStore- The
SqliteVectorStore instance used by this call (exclusive borrow).
c &Chunk- byte or character code (read-only borrow; caller keeps the original; type &Chunk)
Returns
int — a value of this type
($&SqliteVectorStore) add_chunk
pub fn (s $&SqliteVectorStore) add_chunk(id string, doc_id string, text string, source string, metadata_json string, embedding &[]f64) int
Purpose
Operation on $&SqliteVectorStore: add chunk. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&SqliteVectorStore- The
SqliteVectorStore instance used by this call (exclusive borrow).
id string- id (string)
doc_id string- doc_id (string)
text string- text (string)
source string- source (string)
metadata_json string- metadata_json (string)
embedding &[]f64- embedding (read-only borrow; caller keeps the original; type &[]f64)
Returns
int — a value of this type
($&SqliteVectorStore) delete_doc
pub fn (s $&SqliteVectorStore) delete_doc(doc_id string) int
Purpose
Operation on $&SqliteVectorStore: delete doc. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&SqliteVectorStore- The
SqliteVectorStore instance used by this call (exclusive borrow).
doc_id string- doc_id (string)
Returns
int — a value of this type
(&SqliteVectorStore) cached_len
pub fn (s &SqliteVectorStore) cached_len() int
Purpose
Operation on &SqliteVectorStore: cached len.
Parameters
s &SqliteVectorStore- The
SqliteVectorStore instance used by this call (borrow).
Returns
int — a value of this type
($&SqliteVectorStore) refresh_cache
pub fn (s $&SqliteVectorStore) refresh_cache() int
Purpose
Operation on $&SqliteVectorStore: refresh cache. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&SqliteVectorStore- The
SqliteVectorStore instance used by this call (exclusive borrow).
Returns
int — a value of this type
(&SqliteVectorStore) count
pub fn (s &SqliteVectorStore) count() int
Purpose
Operation on &SqliteVectorStore: count non-overlapping occurrences. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &SqliteVectorStore- The
SqliteVectorStore instance used by this call (borrow).
Returns
int — a value of this type
(&SqliteVectorStore) load_memory_store
pub fn (s &SqliteVectorStore) load_memory_store(filter_doc_id string) MemoryStore
Purpose
Operation on &SqliteVectorStore: load memory store. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &SqliteVectorStore- The
SqliteVectorStore instance used by this call (borrow).
filter_doc_id string- filter_doc_id (string)
Returns
MemoryStore — a value of this type
(&SqliteVectorStore) search
pub fn (s &SqliteVectorStore) search(query_emb &[]f64, top_k int, filter_doc_id string) []SearchHit
Purpose
Operation on &SqliteVectorStore: binary search. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &SqliteVectorStore- The
SqliteVectorStore instance used by this call (borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
(&SqliteVectorStore) search_hybrid
pub fn (s &SqliteVectorStore) search_hybrid(query string, query_emb &[]f64, top_k int, rrf_k int, filter_doc_id string) []SearchHit
Purpose
Operation on &SqliteVectorStore: binary search hybrid.
Parameters
s &SqliteVectorStore- The
SqliteVectorStore instance used by this call (borrow).
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
rrf_k int- rrf_k (int)
filter_doc_id string- filter_doc_id (string)
Returns
[]SearchHit — slice result
($&SqliteVectorStore) close
pub fn (s $&SqliteVectorStore) close() int
Purpose
Operation on $&SqliteVectorStore: close the resource. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&SqliteVectorStore- The
SqliteVectorStore instance used by this call (exclusive borrow).
Returns
int — a value of this type
struct QdrantVectorStore
pub struct QdrantVectorStore {
pub client qdrant.Client
pub collection string
pub dim int
}
Purpose
Structure encapsulating client, collection, dim.
Public fields
client qdrant.Client- field (qdrant.Client)
collection string- field (string)
dim int- field (int)
new_qdrant_store
pub fn new_qdrant_store(endpoint string, api_key string, collection string, dim int) QdrantVectorStore
Purpose
Construct qdrant store. Throws on failure; handle the error or propagate it to the caller.
Parameters
endpoint string- endpoint (string)
api_key string- api_key (string)
collection string- collection (string)
dim int- dim (int)
Returns
QdrantVectorStore — a value of this type
($&QdrantVectorStore) ensure_collection
pub fn (s $&QdrantVectorStore) ensure_collection(distance string) bool
Purpose
Operation on $&QdrantVectorStore: ensure collection.
Parameters
s $&QdrantVectorStore- The
QdrantVectorStore instance used by this call (exclusive borrow).
distance string- distance (string)
Returns
bool — true or false
($&QdrantVectorStore) upsert_chunk
pub fn (s $&QdrantVectorStore) upsert_chunk(point_id int, c &Chunk) bool
Purpose
Operation on $&QdrantVectorStore: upsert chunk. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&QdrantVectorStore- The
QdrantVectorStore instance used by this call (exclusive borrow).
point_id int- point_id (int)
c &Chunk- byte or character code (read-only borrow; caller keeps the original; type &Chunk)
Returns
bool — true or false
($&QdrantVectorStore) search
pub fn (s $&QdrantVectorStore) search(query_emb &[]f64, top_k int) []SearchHit
Purpose
Operation on $&QdrantVectorStore: binary search. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&QdrantVectorStore- The
QdrantVectorStore instance used by this call (exclusive borrow).
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
Returns
[]SearchHit — slice result
($&KnowledgeGraph) ingest_text_openai
pub fn (kg $&KnowledgeGraph) ingest_text_openai(client &openai.Client, model string, text string, source string) int
Purpose
Operation on $&KnowledgeGraph: ingest text openai. Throws on failure; handle the error or propagate it to the caller.
Parameters
kg $&KnowledgeGraph- The
KnowledgeGraph instance used by this call (exclusive borrow).
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
text string- text (string)
source string- source (string)
Returns
int — a value of this type
(&KnowledgeGraph) match_entities
pub fn (kg &KnowledgeGraph) match_entities(text &string) []string
Purpose
Operation on &KnowledgeGraph: match entities.
Parameters
kg &KnowledgeGraph- The
KnowledgeGraph instance used by this call (borrow).
text &string- text (read-only borrow; caller keeps the original; type &string)
Returns
[]string — slice result
hybrid_graph_vector_search_auto
pub fn hybrid_graph_vector_search_auto(store &MemoryStore, kg &KnowledgeGraph, query string, query_emb &[]f64, top_k int, graph_hops int) HybridGraphResult
Purpose
Hybrid graph vector binary search auto.
Parameters
store &MemoryStore- store (read-only borrow; caller keeps the original; type &MemoryStore)
kg &KnowledgeGraph- kg (read-only borrow; caller keeps the original; type &KnowledgeGraph)
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
graph_hops int- graph_hops (int)
Returns
HybridGraphResult — a value of this type