x_commons

package
v0.3.71 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "0.3.71"

	ModeProduction = gg.ModeProduction
	ModeDebug      = gg.ModeDebug
	DefLang        = "en" // default language

	SessionContextId = "session-context"
)
View Source
const (
	DocSourceVFS    = "vfs"
	DocSourceEmail  = "email"
	DocSourceUpload = "upload"
)
View Source
const DirSensyOutputs = "./sensy-outputs" // all sensy outputs go here
View Source
const DirSensyPrompts = "./sensy-prompts" // source folder for prompts (only if used AI)

Variables

View Source
var (
	DefLimitTextSize                = 500000 // RAG limit of text size before chunk the text
	DefLimitMaxAutoCalculatedTokens = 65536  // Max number of auto-calc tokens
)

Functions

func AppPath

func AppPath(relativePath string) string

func AppRoot

func AppRoot() string

func CalculateNumCtx

func CalculateNumCtx(text string, sessionTokens int) (response int)

CalculateNumCtx computes a numerical context value based on input text length and session tokens. Minimum response value is 2048

func CountryName

func CountryName(langTag string) string

func CountryNameOf

func CountryNameOf(countryLang, outputLang string) string

func Decrypt added in v0.3.71

func Decrypt(text string, key []byte) (string, error)

func DecryptSilent added in v0.3.71

func DecryptSilent(text, salt string) string

func DecryptWithAppSalt added in v0.3.71

func DecryptWithAppSalt(text, salt string) string

func Download

func Download(url string) (data []byte, err error)

func Encrypt added in v0.3.71

func Encrypt(text string, key []byte) (string, error)

func EncryptSilent added in v0.3.71

func EncryptSilent(text, salt string) string

func EncryptWithAppSalt added in v0.3.71

func EncryptWithAppSalt(text string) string

func ExtractThinkContent added in v0.3.71

func ExtractThinkContent(text string) (thinkContent string, otherContent string)

func FormatDate

func FormatDate(langTag string, date time.Time) string

func FormatTime

func FormatTime(langTag string, date time.Time) string

func GetDirSensyPrompts

func GetDirSensyPrompts() string

func GetError

func GetError(m map[string]interface{}) (err error)

func GormConfig

func GormConfig(mode string) (config *gorm.Config)

func Hash

func Hash(items ...any) (response string)

func HashSerializable

func HashSerializable(items ...gg_.ISerializable) (response string)

func HashStrings

func HashStrings(items ...string) (response string)

func IsRAGRequired

func IsRAGRequired(textSize int) (response bool)

func Lang

func Lang(lang string) *nlp_detect.LanguageISO

func LangCode

func LangCode(lang string) string

LangCode return ISO code (i.e. "it") from lang code like "ita"

func LangCodeDetect

func LangCodeDetect(text string) string

func LangDetect

func LangDetect(text string) *nlp_detect.LanguageISO

func LangName

func LangName(lang string) string

LangName return ISO language name (i.e. "Italian") from a lang code like "it"

func LangNameDefOut

func LangNameDefOut(lang string) string

func LangNameOut

func LangNameOut(langIn, langOut string) string

func RenderMustache

func RenderMustache(text string, context ...interface{}) (string, error)

RenderMustache renders a Mustache template using the provided text and context, returning the rendered string or an error. If an error occurs during rendering, the original text is returned as the fallback response.

func Slugify

func Slugify(text string) (response string)

Slugify converts the input text into a URL-friendly slug by transforming it to lowercase and replacing certain characters with "_".

func SplitChunks added in v0.3.71

func SplitChunks(text string, chunkSize int) []string

func TempRoot

func TempRoot() string

func ToUID

func ToUID(sep string, args ...string) string

func ToUIDChunkItem

func ToUIDChunkItem(uid string, sep string, index int) (response string)

func ToUIDChunks

func ToUIDChunks(uid string, sep string) (response []string)

Types

type KnowledgeModeType

type KnowledgeModeType string
const (
	ModeKnowledge KnowledgeModeType = "knowledge"
	ModeSession   KnowledgeModeType = "session"
	ModeNotebook                    = "notebook"
)

type ProgressCallback

type ProgressCallback func(source string, value, total float64) (exit any)

Jump to

Keyboard shortcuts

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