Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ExtractionToolcallRaw = `` /* 5266-byte string literal not displayed */

ExtractionToolcallRaw is the optimized toolcall for entity and relationship extraction

View Source
const SemanticToolcallRaw = `` /* 1825-byte string literal not displayed */

SemanticToolcallRaw is the toolcall semantic segmentation

Variables

View Source
var ExtractionToolcall = GetExtractionToolcall()

ExtractionToolcall is the extraction toolcall

View Source
var SemanticToolcall = GetSemanticToolcall()

SemanticToolcall is the semantic toolcall

Functions

func BatchGenChunkIDs

func BatchGenChunkIDs(count int) []string

BatchGenChunkIDs generates multiple chunk IDs at once

func BatchGenDocIDs

func BatchGenDocIDs(count int) []string

BatchGenDocIDs generates multiple document IDs at once

func ExtractCollectionIDFromDocID

func ExtractCollectionIDFromDocID(docID string) (string, string)

ExtractCollectionIDFromDocID extracts the GraphName from a prefixed docID Returns the GraphName and the plain UUID part

func ExtractCollectionIDFromGraphName

func ExtractCollectionIDFromGraphName(graphName string) string

ExtractCollectionIDFromGraphName extracts the original collection ID from a graph collection name

func ExtractCollectionIDFromStoreName

func ExtractCollectionIDFromStoreName(storeName string) string

ExtractCollectionIDFromStoreName extracts the original collection ID from a store collection name

func ExtractCollectionIDFromVectorName

func ExtractCollectionIDFromVectorName(vectorName string) string

ExtractCollectionIDFromVectorName extracts the original collection ID from a vector collection name This is the reverse operation of GetCollectionIDs

func ExtractionPrompt

func ExtractionPrompt(userPrompt string) string

ExtractionPrompt returns the extraction prompt, with JSON format instructions for non-toolcall mode

func ExtractionPromptWithJSONFormat

func ExtractionPromptWithJSONFormat(userPrompt string) string

ExtractionPromptWithJSONFormat returns the extraction prompt with JSON format instructions for non-toolcall mode

func GenChunkID

func GenChunkID() string

GenChunkID generates a UUID for chunk identification

func GenCollectionID

func GenCollectionID(prefix string) string

GenCollectionID generates a unique collection ID with prefix + timestamp

func GenDocID

func GenDocID() string

GenDocID generates a UUID for document identification (without dashes)

func GenDocIDWithCollectionID

func GenDocIDWithCollectionID(graphName string) string

GenDocIDWithCollectionID generates a UUID for document identification with GraphName prefix Format: graphname__uuid (without dashes)

func GenShortID

func GenShortID() string

GenShortID generates a shorter ID using timestamp and random bytes Useful for cases where shorter IDs are preferred

func GetCollectionIDs

func GetCollectionIDs(name string) (types.CollectionIDs, error)

GetCollectionIDs generates simple collection IDs: name_vector, name_graph, name_store

func GetExtractionToolcall

func GetExtractionToolcall() []map[string]interface{}

GetExtractionToolcall returns the extraction toolcall

func GetSemanticToolcall

func GetSemanticToolcall() []map[string]interface{}

GetSemanticToolcall returns the semantic toolcall

func IsDocIDWithCollectionID

func IsDocIDWithCollectionID(docID string) bool

IsDocIDWithCollectionID checks if a docID contains a GraphName prefix

func IsValidUUID

func IsValidUUID(id string) bool

IsValidUUID checks if a string is a valid UUID format

func ParseJSONOptions

func ParseJSONOptions(optionsStr string) (map[string]interface{}, error)

ParseJSONOptions parses JSON options string and returns a map

func PostLLM

func PostLLM(ctx context.Context, conn connector.Connector, endpoint string, payload map[string]interface{}) (interface{}, error)

PostLLM sends a POST request to LLM API using connector

func PostLLMFile

func PostLLMFile(ctx context.Context, conn connector.Connector, endpoint string, filePath string, formData map[string]interface{}) (interface{}, error)

PostLLMFile sends a POST request to LLM API with file upload using multipart/form-data

func SemanticPrompt

func SemanticPrompt(userPrompt string, size int) string

SemanticPrompt returns the semantic prompt

func StreamLLM

func StreamLLM(ctx context.Context, conn connector.Connector, endpoint string, payload map[string]interface{}, callback func(data []byte) error) error

StreamLLM sends a streaming request to LLM service with real-time callback

func ValidateName

func ValidateName(name string) error

ValidateName validates collection name format Only allows a-z, A-Z, 0-9, and underscore characters

Types

type FileReader

type FileReader struct {
	*os.File
}

FileReader wraps os.File to implement io.ReadSeeker with Close method

func OpenFileAsReader

func OpenFileAsReader(filename string) (*FileReader, error)

OpenFileAsReader opens a file and returns a ReadSeeker with Close method

func (*FileReader) Close

func (f *FileReader) Close() error

Close closes the underlying file

type Parser

type Parser struct {
	Content   string
	Arguments string
	Toolcall  bool
	// contains filtered or unexported fields
}

Parser handles streaming LLM responses and accumulates data

func NewExtractionParser

func NewExtractionParser() *Parser

NewExtractionParser creates a new extraction parser for tool call parsing

func NewSemanticParser

func NewSemanticParser(isToolcall bool) *Parser

NewSemanticParser creates a new semantic parser

func (*Parser) ParseExtractionEntities

func (parser *Parser) ParseExtractionEntities(chunkData []byte) ([]types.Node, []types.Relationship, error)

ParseExtractionEntities parses a single streaming chunk for extraction and returns extraction progress

func (*Parser) ParseExtractionRegular

func (parser *Parser) ParseExtractionRegular(finalContent string) ([]types.Node, []types.Relationship, error)

ParseExtractionRegular parses entities and relationships from regular LLM content

func (*Parser) ParseExtractionToolcall

func (parser *Parser) ParseExtractionToolcall(finalArguments string) ([]types.Node, []types.Relationship, error)

ParseExtractionToolcall parses the final arguments of the extraction toolcall

func (*Parser) ParseSemanticPositions

func (parser *Parser) ParseSemanticPositions(chunkData []byte) ([]types.Position, error)

ParseSemanticPositions parses a single streaming chunk returns a semantic chunk

func (*Parser) ParseSemanticRegular

func (parser *Parser) ParseSemanticRegular(finalContent string) ([]types.Position, error)

ParseSemanticRegular parses the final content of the regular

func (*Parser) ParseSemanticToolcall

func (parser *Parser) ParseSemanticToolcall(finalArguments string) ([]types.Position, error)

ParseSemanticToolcall parses the final arguments of the toolcall

func (*Parser) SetToolcall

func (parser *Parser) SetToolcall(isToolcall bool)

SetToolcall sets the toolcall mode for the parser

Jump to

Keyboard shortcuts

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