Documentation
¶
Index ¶
- Constants
- Variables
- func IsDocumentPrompt(name string) bool
- type ActionType
- type ArtifactDocument
- type ArtifactDocumentFile
- type ArtifactOutput
- func (instance *ArtifactOutput) GetBytes() (bytes []byte, err error)
- func (instance *ArtifactOutput) GetText() (response string, err error)
- func (instance *ArtifactOutput) Map() map[string]interface{}
- func (instance *ArtifactOutput) SetBytes(bytes []byte)
- func (instance *ArtifactOutput) SetText(text string)
- func (instance *ArtifactOutput) String() string
- type CtrLLMTool
- type CtrOperation
- type CtrlIOVFSOptions
- type IAIAgent
- type IAIStage
- type ICtrlDatabase
- type ICtrlDatabases
- type ICtrlDirs
- type IIdentity
- type IOperation
- type ITool
- type LLMAgentGears
- type LLMAgentTool
- type LLMDocumentsEmbeddings
- type LLMDocumentsOptions
- type LLMDocumentsSources
- type LLMDriverCreatorOptions
- type LLMDriverOptions
- func (instance *LLMDriverOptions) GetAccessKey() (response string)
- func (instance *LLMDriverOptions) GetModelTools() (response string)
- func (instance *LLMDriverOptions) GetSecretKey() (response string)
- func (instance *LLMDriverOptions) Map() map[string]interface{}
- func (instance *LLMDriverOptions) Parse(m map[string]any) *LLMDriverOptions
- func (instance *LLMDriverOptions) String() string
- type LLMRagOptions
- type LLMRagOptionsItem
- type LLMRequest
- func (instance *LLMRequest) Add(args ...interface{}) *LLMRequest
- func (instance *LLMRequest) AddArtifacts(items ...map[string]any)
- func (instance *LLMRequest) AddMessage(message *RequestMessage) *LLMRequest
- func (instance *LLMRequest) AddUserMessage(arg interface{}) *LLMRequest
- func (instance *LLMRequest) AutoCalcMaxTokens(limit int) *LLMRequest
- func (instance *LLMRequest) CalcMaxTokens() int
- func (instance *LLMRequest) CalcMaxTokensMin(min int) int
- func (instance *LLMRequest) CalcPrompt() (response string)
- func (instance *LLMRequest) CalcPromptSystem() (response string)
- func (instance *LLMRequest) CalculateMaxTokens() int
- func (instance *LLMRequest) Clone() (clone *LLMRequest)
- func (instance *LLMRequest) DisableLLMTools()
- func (instance *LLMRequest) Errors() (response []string)
- func (instance *LLMRequest) GetLLMTool(name string) ITool
- func (instance *LLMRequest) GetLLMToolSchemas() map[string]string
- func (instance *LLMRequest) GetOptions() (response *RequestOptions)
- func (instance *LLMRequest) GetPrompt() (response string)
- func (instance *LLMRequest) GetPromptSystem() (response string)
- func (instance *LLMRequest) HasLLMTools() bool
- func (instance *LLMRequest) Map() (m map[string]interface{})
- func (instance *LLMRequest) MergeOptions(source map[string]interface{}, override bool) *LLMRequest
- func (instance *LLMRequest) Messages() (response []*RequestMessage)
- func (instance *LLMRequest) MessagesCount() (response int)
- func (instance *LLMRequest) MessagesLength() (response int)
- func (instance *LLMRequest) Parse(m map[string]interface{}) *LLMRequest
- func (instance *LLMRequest) Refresh() *LLMRequest
- func (instance *LLMRequest) ReplacePrompt(text string) *LLMRequest
- func (instance *LLMRequest) SetLLToolSchemaGetterFunc(f LLMToolGetFunc)
- func (instance *LLMRequest) SetLLToolSchemasFunc(f LLMToolSchemasFunc)
- func (instance *LLMRequest) SetOptionMaxTokens(value int) *LLMRequest
- func (instance *LLMRequest) SetOptionMaxTokensWithLimit(value, limit int) *LLMRequest
- func (instance *LLMRequest) SetOptions(arg any) *LLMRequest
- func (instance *LLMRequest) SetPrompt(text string) *LLMRequest
- func (instance *LLMRequest) SetPromptSystem(text string) *LLMRequest
- func (instance *LLMRequest) String() string
- func (instance *LLMRequest) ToolsHistoryAdd(names ...string)
- func (instance *LLMRequest) ToolsHistoryReset()
- type LLMRequestContext
- type LLMRequestDefaults
- type LLMRequestEmbeddings
- type LLMRequestPayload
- func (instance *LLMRequestPayload) Format(text string) (response string)
- func (instance *LLMRequestPayload) KBContextAppendChunks(items ...*x_commons_model.RagChunk) *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextAppendFileContent(filename string, bytes []byte) *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextAppendItems(items ...any) *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextAppendNote(groupName string, text string) *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextAppendRawElement(item string) *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextAsArrayMap() (response []map[string]interface{})
- func (instance *LLMRequestPayload) KBContextAsArrayRAG() (response []*x_commons_model.RagChunk)
- func (instance *LLMRequestPayload) KBContextGet() (response *RequestPayloadKBContext)
- func (instance *LLMRequestPayload) KBContextGroupedByFileId() (response *RequestPayloadKBContext)
- func (instance *LLMRequestPayload) KBContextReset() (response *RequestPayloadKBContext)
- func (instance *LLMRequestPayload) KBContextSetNotEmpty() *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextSetRawElements(items ...string) *LLMRequestPayload
- func (instance *LLMRequestPayload) KBContextSize() int
- func (instance *LLMRequestPayload) Map() (response map[string]interface{})
- func (instance *LLMRequestPayload) Parse(value any) bool
- func (instance *LLMRequestPayload) SetLang(value string) *LLMRequestPayload
- func (instance *LLMRequestPayload) String() string
- type LLMResponse
- func (instance *LLMResponse) AddArtifacts(items ...map[string]any)
- func (instance *LLMResponse) GetMetaProjectId() (response string)
- func (instance *LLMResponse) GetMetadata() (response map[string]interface{})
- func (instance *LLMResponse) IsJSONResponse() bool
- func (instance *LLMResponse) JSONCount() int
- func (instance *LLMResponse) JSONData() (response []map[string]interface{})
- func (instance *LLMResponse) JSONForEach(iterator func(jsonItem map[string]any)) *LLMResponse
- func (instance *LLMResponse) Map() (response map[string]interface{})
- func (instance *LLMResponse) MapLight() (response map[string]interface{})
- func (instance *LLMResponse) SetMetaProjectId(value string) *LLMResponse
- func (instance *LLMResponse) SetRequest(request *LLMRequest) *LLMResponse
- func (instance *LLMResponse) SetResponse(rawResponse map[string]interface{}) *LLMResponse
- func (instance *LLMResponse) SetTextResponse(value string) *LLMResponse
- func (instance *LLMResponse) String() string
- type LLMToolGetFunc
- type LLMToolSchemasFunc
- type OperationRequest
- func (instance *OperationRequest) CountArtifacts() int
- func (instance *OperationRequest) HasArtifacts() bool
- func (instance *OperationRequest) IsBatch() bool
- func (instance *OperationRequest) IsRealTime() bool
- func (instance *OperationRequest) Map() map[string]interface{}
- func (instance *OperationRequest) String() string
- type OperationResponse
- func (instance *OperationResponse) GetError() (response error)
- func (instance *OperationResponse) HasError() (response bool)
- func (instance *OperationResponse) Map() map[string]interface{}
- func (instance *OperationResponse) MapLight() (response map[string]interface{})
- func (instance *OperationResponse) SetError(err error) *OperationResponse
- func (instance *OperationResponse) String() string
- type OptionsAgent
- func (instance *OptionsAgent) AddDriver(item *LLMDriverOptions)
- func (instance *OptionsAgent) AddTool(item *LLMAgentTool)
- func (instance *OptionsAgent) Clone() (response *OptionsAgent)
- func (instance *OptionsAgent) ContainsDriver(uid string) bool
- func (instance *OptionsAgent) ContainsTool(name string) bool
- func (instance *OptionsAgent) Map() map[string]interface{}
- func (instance *OptionsAgent) String() string
- type OptionsAgentStage
- func (instance *OptionsAgentStage) AddDriver(item *LLMDriverOptions)
- func (instance *OptionsAgentStage) Clone() (response *OptionsAgentStage)
- func (instance *OptionsAgentStage) ContainsDriver(uid string) bool
- func (instance *OptionsAgentStage) Map() map[string]interface{}
- func (instance *OptionsAgentStage) String() string
- type RequestMessage
- func (instance *RequestMessage) Clone() (response *RequestMessage)
- func (instance *RequestMessage) Length() int
- func (instance *RequestMessage) Map() (response map[string]interface{})
- func (instance *RequestMessage) SetContent(value string) *RequestMessage
- func (instance *RequestMessage) String() string
- type RequestMessageList
- func (instance *RequestMessageList) Add(item *RequestMessage) *RequestMessageList
- func (instance *RequestMessageList) Count() (response int)
- func (instance *RequestMessageList) ForEach(f func(item *RequestMessage) any)
- func (instance *RequestMessageList) GetSystem() (response *RequestMessage)
- func (instance *RequestMessageList) GetUser() (response *RequestMessage)
- func (instance *RequestMessageList) Length() (response int)
- func (instance *RequestMessageList) Map() (response []map[string]interface{})
- func (instance *RequestMessageList) ReplaceUser(text string, images ...string) *RequestMessageList
- func (instance *RequestMessageList) SetSystem(text string) *RequestMessageList
- func (instance *RequestMessageList) SetUser(text string, images ...string) *RequestMessageList
- func (instance *RequestMessageList) String() string
- type RequestOptions
- type RequestPayloadKBContext
- func (instance *RequestPayloadKBContext) Append(items ...any) *RequestPayloadKBContext
- func (instance *RequestPayloadKBContext) GroupItemsByFileId() (response []map[string]interface{})
- func (instance *RequestPayloadKBContext) Map() (response map[string]interface{})
- func (instance *RequestPayloadKBContext) Reset() *RequestPayloadKBContext
- func (instance *RequestPayloadKBContext) Size() int
- func (instance *RequestPayloadKBContext) String() string
- func (instance *RequestPayloadKBContext) ToArrayMap() (response []map[string]interface{})
- func (instance *RequestPayloadKBContext) ToArrayRAG() (response []*x_commons_model.RagChunk)
- type StreamHandler
- type ToolModel
- type ToolModelFunction
- type ToolModelFunctionParameters
- type ToolModelFunctionParametersProperties
- type ToolResponseModel
- func (instance *ToolResponseModel) AddArtifacts(items ...map[string]any)
- func (instance *ToolResponseModel) GetError() (response error)
- func (instance *ToolResponseModel) HasError() (response bool)
- func (instance *ToolResponseModel) HasPrompts() (response bool)
- func (instance *ToolResponseModel) Name() (response string)
Constants ¶
const ( DriverOllama = "ollama" DriverChatGPT = "chatgpt" DriverClaude = "claude" DriverDalle = "dalle" DriverUnsplash = "unsplash" AIModelGemma3 = "gemma3" AIModelQwen3 = "qwen3" )
const ( RoleSystem string = "system" RoleUser = "user" RoleAssistant = "assistant" )
const ( AgentMain = "ag_main" // main generic agent with tools AgentMultifunctional = "ag_multifunctional" // multi functional general porpoise agent AgentTranslator = "ag_translator" // TRANSLATE TO ANY LANGUAGE )
const ( ToolBase = "get_fallback_answer" // fallback tool ToolCurrentWeather = "get_current_weather" // weather forecast ToolTextTranslator = "get_text_translation" // professional translation that uses ['ag_translator'] ToolTextSummary = "get_text_summary" ToolSearchDocuments = "search_documents" )
const ( OperationGeneric = "op_generic" OperationSemanticChunk = "op_semantic_chunk" OperationWebSearch = "op_web_search" OperationSummary = "op_summary" )
const ( OperationModeRealTime = "realtime" OperationModeBatch = "batch" OperationModeNone = "" )
const ( EntityDocument = "document" EntityDocumentGroup = "document_group" EntityOperation = "operation" EntityUser = "user" EntityHistory = "history" )
const ( PromptDefNameUpload = "upload" // special system prompt used only after a session upload PromptDefNameEntities = "entities" // system prompt used by tools or user actions to achieve a special task PromptDefNameContext = "context" )
const ChunkNone = "none" // no chunk
const ChunkRows = "rows" // number of rows
const ChunkSemantic = "semantic" // intelligent semantic chunk
const ContentOptionSyntaxHTML = "html"
const ContentOptionSyntaxMarkdown = "markdown"
const ContentOptionSyntaxTextPlain = "text"
const DBNameHistory = "history"
const DbNameOperations = "operations"
const DefLang = x_commons.DefLang // default llm language
const DefModel = "gemma3"
const DirSensyOutputs = x_commons.DirSensyOutputs // all sensy outputs go here
const DirSensyPrompts = x_commons.DirSensyPrompts // source folder for prompts (only if used AI)
const EventOnAuthenticate = "on_authenticate"
const EventOnAuthenticateSystem = "on_authenticate_system"
const EventOnLicenseCheck = "on_license_check"
const EventOnNewIdentity = "on_new_identity"
const EventOnNewRequest = "on_new_request"
const EventOnNewResponse = "on_new_response"
const EventOnTaskEnded = "on_task_ended"
const EventOnTaskStarted = "on_task_started"
const PrefixLiteral = "literal:"
const PrefixPrompt = "prompt:"
const PromptDefLang = DefLang
const PromptSeparator = "\n---\n"
Variables ¶
var PromptDefDocumentNames = []string{ PromptDefNameEntities, }
PromptDefDocumentNames contains names for prompts that require a "document" payload to be performed.
Functions ¶
func IsDocumentPrompt ¶
IsDocumentPrompt checks if the provided name is in the list of prompt names that require a "document" payload.
Types ¶
type ActionType ¶
type ActionType string
const ( ActionChat ActionType = "chat" ActionGenerate ActionType = "generate" )
type ArtifactDocument ¶ added in v0.3.71
type ArtifactDocument struct {
ID string `json:"_id,omitempty"`
Timestamp string `json:"timestamp"`
Type string `json:"type"`
File *ArtifactDocumentFile `json:"file"`
Summary string `json:"summary"`
}
func (*ArtifactDocument) Map ¶ added in v0.3.71
func (instance *ArtifactDocument) Map() map[string]interface{}
func (*ArtifactDocument) String ¶ added in v0.3.71
func (instance *ArtifactDocument) String() string
type ArtifactDocumentFile ¶ added in v0.3.71
type ArtifactDocumentFile struct {
FileName string `json:"file-name"`
FileTitle string `json:"file-title"`
FileExt string `json:"file-ext"`
FileHash string `json:"file-hash"`
FileSize int `json:"file-size"`
}
func (*ArtifactDocumentFile) Map ¶ added in v0.3.71
func (instance *ArtifactDocumentFile) Map() map[string]interface{}
func (*ArtifactDocumentFile) String ¶ added in v0.3.71
func (instance *ArtifactDocumentFile) String() string
type ArtifactOutput ¶ added in v0.3.71
type ArtifactOutput struct {
Type string `json:"type"` // pdf, html, markdown, ...
Name string `json:"name"` // Name specifies the name of the artifact.
Description string `json:"description"` // Description is a brief explanation or narrative for the artifact.
Base64 string `json:"content"` // Base64 is the base64-encoded string representing the artifact's content.
}
ArtifactOutput object generated by operations
func (*ArtifactOutput) GetBytes ¶ added in v0.3.71
func (instance *ArtifactOutput) GetBytes() (bytes []byte, err error)
func (*ArtifactOutput) GetText ¶ added in v0.3.71
func (instance *ArtifactOutput) GetText() (response string, err error)
func (*ArtifactOutput) Map ¶ added in v0.3.71
func (instance *ArtifactOutput) Map() map[string]interface{}
func (*ArtifactOutput) SetBytes ¶ added in v0.3.71
func (instance *ArtifactOutput) SetBytes(bytes []byte)
func (*ArtifactOutput) SetText ¶ added in v0.3.71
func (instance *ArtifactOutput) SetText(text string)
func (*ArtifactOutput) String ¶ added in v0.3.71
func (instance *ArtifactOutput) String() string
type CtrLLMTool ¶ added in v0.3.71
type CtrLLMTool func() ITool
type CtrOperation ¶ added in v0.3.71
type CtrOperation func(args ...any) IOperation
type CtrlIOVFSOptions ¶ added in v0.3.71
type CtrlIOVFSOptions struct {
*vfswatchdog_options.VfsWatchdogOptions
}
func NewCtrlIOVFSOptions ¶ added in v0.3.71
func NewCtrlIOVFSOptions(args ...any) (instance *CtrlIOVFSOptions)
func (*CtrlIOVFSOptions) Map ¶ added in v0.3.71
func (instance *CtrlIOVFSOptions) Map() (response map[string]interface{})
func (*CtrlIOVFSOptions) String ¶ added in v0.3.71
func (instance *CtrlIOVFSOptions) String() (response string)
type IAIAgent ¶ added in v0.3.71
type IAIAgent interface {
GetName() string
Options() (response *OptionsAgent)
RequestDefaults() (response *LLMRequestDefaults)
Dirs() (response ICtrlDirs)
Open() error
Close()
IsOpen() bool
HasStage() bool
Stage() IAIStage
SkillAdd(item any)
ToolsAdd(tool *LLMAgentTool) (err error)
Submit(request *LLMRequest) (response *LLMResponse, err error)
NewLLMRequest(messages ...interface{}) (response *LLMRequest)
}
type IAIStage ¶ added in v0.3.71
type IAIStage interface {
DirRoot() string
DirVectors() string
Events() (response *gg_events.Emitter)
Database(name string) ICtrlDatabase
Secrets() (response *gg_secrets.SecretsWallet)
AgentGet(name string) (response IAIAgent, err error)
OperationGet(name string) (response IOperation)
Identity() IIdentity
IdentitySystem() IIdentity
}
type ICtrlDatabase ¶ added in v0.3.71
type ICtrlDatabase interface {
Exists(id string) (response bool)
Get(id string) (response map[string]any, err error)
Update(entity map[string]any) (response map[string]any, err error)
Delete(id string) (response map[string]any, err error)
DeleteWhere(queryJSON map[string]any) (response []map[string]any, err error)
}
type ICtrlDatabases ¶ added in v0.3.71
type ICtrlDatabases interface {
Database(name string) ICtrlDatabase
}
type IIdentity ¶ added in v0.3.71
type IIdentity interface {
GetID() string
GetName() (response string)
GetRole() (response string)
IsAdmin() (response bool)
IsAnonymous() (response bool)
GetPayload() (response map[string]interface{})
Map() map[string]interface{}
String() string
}
IIdentity current logged user
type IOperation ¶ added in v0.3.71
type IOperation interface {
Submit(request *OperationRequest) (response *OperationResponse)
}
type ITool ¶ added in v0.3.71
type ITool interface {
Name() string
Schema() (response *ToolModel)
String() string
Init(dirWork, lang string, args ...any) (err error)
Query(arguments map[string]any, request *LLMRequest) (response *ToolResponseModel)
}
type LLMAgentGears ¶ added in v0.3.71
type LLMAgentGears struct {
AutoInstallDefaults bool `json:"auto-install-defaults"`
Prefetch bool `json:"prefetch"`
Items []map[string]interface{} `json:"items"`
}
func NewOptionsAgentGears ¶ added in v0.3.71
func NewOptionsAgentGears() (instance *LLMAgentGears)
func (*LLMAgentGears) Map ¶ added in v0.3.71
func (instance *LLMAgentGears) Map() map[string]interface{}
func (*LLMAgentGears) String ¶ added in v0.3.71
func (instance *LLMAgentGears) String() string
type LLMAgentTool ¶ added in v0.3.71
type LLMAgentTool struct {
Name string `json:"name"`
Lang string `json:"lang"`
Options map[string]interface{} `json:"options"`
}
func NewLLMAgentTool ¶ added in v0.3.71
func NewLLMAgentTool() (instance *LLMAgentTool)
func (*LLMAgentTool) Map ¶ added in v0.3.71
func (instance *LLMAgentTool) Map() map[string]interface{}
func (*LLMAgentTool) String ¶ added in v0.3.71
func (instance *LLMAgentTool) String() string
type LLMDocumentsEmbeddings ¶ added in v0.3.71
type LLMDocumentsEmbeddings struct {
RAG *LLMRagOptions `json:"rag"` // rag configuration
}
func NewLLMDocumentsEmbeddings ¶ added in v0.3.71
func NewLLMDocumentsEmbeddings() (instance *LLMDocumentsEmbeddings)
func (*LLMDocumentsEmbeddings) Map ¶ added in v0.3.71
func (instance *LLMDocumentsEmbeddings) Map() (response map[string]interface{})
func (*LLMDocumentsEmbeddings) String ¶ added in v0.3.71
func (instance *LLMDocumentsEmbeddings) String() string
type LLMDocumentsOptions ¶ added in v0.3.71
type LLMDocumentsOptions struct {
Database *gg_couchdb.CtrlCouchDBOptions `json:"database"`
Sources *LLMDocumentsSources `json:"sources"`
Embeddings *LLMDocumentsEmbeddings `json:"embeddings"` // rag configuration
}
func NewLLMDocumentsOptions ¶ added in v0.3.71
func NewLLMDocumentsOptions() (instance *LLMDocumentsOptions)
func (*LLMDocumentsOptions) Map ¶ added in v0.3.71
func (instance *LLMDocumentsOptions) Map() (response map[string]interface{})
func (*LLMDocumentsOptions) String ¶ added in v0.3.71
func (instance *LLMDocumentsOptions) String() (response string)
type LLMDocumentsSources ¶ added in v0.3.71
type LLMDocumentsSources struct {
VFS *CtrlIOVFSOptions `json:"vfs"`
}
func NewCtrlDocumentsSources ¶ added in v0.3.71
func NewCtrlDocumentsSources() (instance *LLMDocumentsSources)
func (*LLMDocumentsSources) Map ¶ added in v0.3.71
func (instance *LLMDocumentsSources) Map() (response map[string]interface{})
func (*LLMDocumentsSources) String ¶ added in v0.3.71
func (instance *LLMDocumentsSources) String() (response string)
type LLMDriverCreatorOptions ¶
type LLMDriverCreatorOptions struct {
Uid string `json:"uid"`
PlanUid string `json:"plan-uid"`
Lang string `json:"lang"`
TextQuery string `json:"text-query"`
TitleQuery string `json:"title-query"`
CreateImage bool `json:"create-image"`
ImageQuery string `json:"image-query"`
ImageParams []string `json:"image-params"`
Tags []string `json:"tags"`
Categories []string `json:"categories"`
CreateText bool `json:"create-text"`
SourceSyntax string `json:"source-syntax"` // markdown, text
TargetSyntax string `json:"target-syntax"` // html
}
func NewLLMDriverCreatorOptions ¶
func NewLLMDriverCreatorOptions(args ...interface{}) (instance *LLMDriverCreatorOptions)
func (*LLMDriverCreatorOptions) HasSyntax ¶
func (instance *LLMDriverCreatorOptions) HasSyntax() bool
func (*LLMDriverCreatorOptions) Map ¶
func (instance *LLMDriverCreatorOptions) Map() map[string]interface{}
func (*LLMDriverCreatorOptions) String ¶
func (instance *LLMDriverCreatorOptions) String() string
type LLMDriverOptions ¶
type LLMDriverOptions struct {
Uid string `json:"uid"` // (only for store drivers) store uid
DriverName string `json:"driver-name"` // name of the driver
Model string `json:"model"` // name of the model
ModelTools string `json:"model-tools"` // name of the model to use with tools
AccessKey string `json:"access-key"` // access token
SecretKey string `json:"secret-key,omitempty"`
OptionsCreator *LLMDriverCreatorOptions `json:"create-options,omitempty"`
OptionsModel *RequestOptions `json:"model-options"` // specific AI model option
}
func NewLLMDriverOptions ¶
func NewLLMDriverOptions(args ...interface{}) (instance *LLMDriverOptions)
func (*LLMDriverOptions) GetAccessKey ¶
func (instance *LLMDriverOptions) GetAccessKey() (response string)
func (*LLMDriverOptions) GetModelTools ¶ added in v0.3.71
func (instance *LLMDriverOptions) GetModelTools() (response string)
func (*LLMDriverOptions) GetSecretKey ¶
func (instance *LLMDriverOptions) GetSecretKey() (response string)
func (*LLMDriverOptions) Map ¶
func (instance *LLMDriverOptions) Map() map[string]interface{}
func (*LLMDriverOptions) Parse ¶
func (instance *LLMDriverOptions) Parse(m map[string]any) *LLMDriverOptions
func (*LLMDriverOptions) String ¶
func (instance *LLMDriverOptions) String() string
type LLMRagOptions ¶
type LLMRagOptions struct {
DatabasesAutogenerate bool `json:"databases-autogenerate"`
Databases []*LLMRagOptionsItem `json:"databases"`
}
func (*LLMRagOptions) Map ¶
func (instance *LLMRagOptions) Map() (response map[string]interface{})
func (*LLMRagOptions) String ¶
func (instance *LLMRagOptions) String() string
type LLMRagOptionsItem ¶
type LLMRagOptionsItem struct {
Driver string `json:"driver"`
*vectordb.VectorDBOptions
}
func NewLLMRagOptionsItem ¶
func NewLLMRagOptionsItem() *LLMRagOptionsItem
func (*LLMRagOptionsItem) Map ¶
func (instance *LLMRagOptionsItem) Map() (response map[string]interface{})
func (*LLMRagOptionsItem) SetName ¶
func (instance *LLMRagOptionsItem) SetName(name string) *LLMRagOptionsItem
func (*LLMRagOptionsItem) SetPath ¶
func (instance *LLMRagOptionsItem) SetPath(path string) *LLMRagOptionsItem
func (*LLMRagOptionsItem) String ¶
func (instance *LLMRagOptionsItem) String() string
type LLMRequest ¶
type LLMRequest struct {
Uid string `json:"uid"` // unique request id
// required
Version string `json:"version"` // application version
Driver string `json:"driver"` // name of driver
Model string `json:"model"` // ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
ModelTools string `json:"model-tools"` // model to use with tools
Payload *LLMRequestPayload `json:"payload"` // payload used to format prompts
Artifacts []*ArtifactDocument `json:"artifacts"` // list of objects passed to LLM. A request with artifacts is a request to be processed by "operations"
ToolsHistory []string `json:"tools-history,omitempty"` // list of tools used with a request
// optional
SkillName string `json:"skill-name,omitempty"` // (optional) used only in agents with a skill controller
PromptName string `json:"prompt-name,omitempty"` // (optional) used only in agents with a skill controller
Action ActionType `json:"action,omitempty"` // (optional) chat, generate
Format string `json:"format,omitempty"` // (optional) json
ProjectId string `json:"project-id,omitempty"` // (optional) ID of the project if any
SessionId string `json:"session-id,omitempty"` // (optional) ID of the session if any
VectorId string `json:"vector-id,omitempty"` // (optional) ID of RAG DB if any
VectorColl string `json:"vector-coll,omitempty"` // (optional) ID of RAG collection if any
VectorMaxResults int `json:"vector-max-results,omitempty"` // (optional) RAG max results.
VectorChunksMaxRows int `json:"vector-chunks-max-rows,omitempty"` // (optional) RAG chunks with a certain number of rows
VectorChunksMode string `json:"vector-chunks-mode,omitempty"` // (optional) "max-rows", "semantic". Default is empty/"max-rows"
Context []int `json:"context,omitempty"` // (optional) Previous context if any
Images []string `json:"images,omitempty"` // (optional) list of base64 encoded images
// not exposed
Stream StreamHandler `json:"-"` // Stream: only when stream is allowed
StreamThink StreamHandler `json:"-"` // StreamThink: only when stream is allowed
// contains filtered or unexported fields
}
func NewLLMRequest ¶
func NewLLMRequest(messages ...interface{}) (instance *LLMRequest)
func (*LLMRequest) Add ¶
func (instance *LLMRequest) Add(args ...interface{}) *LLMRequest
func (*LLMRequest) AddArtifacts ¶ added in v0.3.71
func (instance *LLMRequest) AddArtifacts(items ...map[string]any)
func (*LLMRequest) AddMessage ¶ added in v0.3.71
func (instance *LLMRequest) AddMessage(message *RequestMessage) *LLMRequest
func (*LLMRequest) AddUserMessage ¶
func (instance *LLMRequest) AddUserMessage(arg interface{}) *LLMRequest
func (*LLMRequest) AutoCalcMaxTokens ¶ added in v0.3.71
func (instance *LLMRequest) AutoCalcMaxTokens(limit int) *LLMRequest
func (*LLMRequest) CalcMaxTokens ¶
func (instance *LLMRequest) CalcMaxTokens() int
func (*LLMRequest) CalcMaxTokensMin ¶
func (instance *LLMRequest) CalcMaxTokensMin(min int) int
func (*LLMRequest) CalcPrompt ¶
func (instance *LLMRequest) CalcPrompt() (response string)
func (*LLMRequest) CalcPromptSystem ¶
func (instance *LLMRequest) CalcPromptSystem() (response string)
func (*LLMRequest) CalculateMaxTokens ¶
func (instance *LLMRequest) CalculateMaxTokens() int
func (*LLMRequest) Clone ¶ added in v0.3.71
func (instance *LLMRequest) Clone() (clone *LLMRequest)
func (*LLMRequest) DisableLLMTools ¶ added in v0.3.71
func (instance *LLMRequest) DisableLLMTools()
func (*LLMRequest) Errors ¶
func (instance *LLMRequest) Errors() (response []string)
func (*LLMRequest) GetLLMTool ¶ added in v0.3.71
func (instance *LLMRequest) GetLLMTool(name string) ITool
func (*LLMRequest) GetLLMToolSchemas ¶ added in v0.3.71
func (instance *LLMRequest) GetLLMToolSchemas() map[string]string
func (*LLMRequest) GetOptions ¶
func (instance *LLMRequest) GetOptions() (response *RequestOptions)
func (*LLMRequest) GetPrompt ¶
func (instance *LLMRequest) GetPrompt() (response string)
func (*LLMRequest) GetPromptSystem ¶
func (instance *LLMRequest) GetPromptSystem() (response string)
func (*LLMRequest) HasLLMTools ¶ added in v0.3.71
func (instance *LLMRequest) HasLLMTools() bool
func (*LLMRequest) Map ¶
func (instance *LLMRequest) Map() (m map[string]interface{})
func (*LLMRequest) MergeOptions ¶ added in v0.3.71
func (instance *LLMRequest) MergeOptions(source map[string]interface{}, override bool) *LLMRequest
func (*LLMRequest) Messages ¶
func (instance *LLMRequest) Messages() (response []*RequestMessage)
Messages returns a list of request messages from the LLMRequest instance, with their content optionally formatted.
func (*LLMRequest) MessagesCount ¶
func (instance *LLMRequest) MessagesCount() (response int)
func (*LLMRequest) MessagesLength ¶
func (instance *LLMRequest) MessagesLength() (response int)
func (*LLMRequest) Parse ¶
func (instance *LLMRequest) Parse(m map[string]interface{}) *LLMRequest
func (*LLMRequest) Refresh ¶
func (instance *LLMRequest) Refresh() *LLMRequest
func (*LLMRequest) ReplacePrompt ¶ added in v0.3.71
func (instance *LLMRequest) ReplacePrompt(text string) *LLMRequest
func (*LLMRequest) SetLLToolSchemaGetterFunc ¶ added in v0.3.71
func (instance *LLMRequest) SetLLToolSchemaGetterFunc(f LLMToolGetFunc)
func (*LLMRequest) SetLLToolSchemasFunc ¶ added in v0.3.71
func (instance *LLMRequest) SetLLToolSchemasFunc(f LLMToolSchemasFunc)
func (*LLMRequest) SetOptionMaxTokens ¶
func (instance *LLMRequest) SetOptionMaxTokens(value int) *LLMRequest
func (*LLMRequest) SetOptionMaxTokensWithLimit ¶
func (instance *LLMRequest) SetOptionMaxTokensWithLimit(value, limit int) *LLMRequest
func (*LLMRequest) SetOptions ¶
func (instance *LLMRequest) SetOptions(arg any) *LLMRequest
func (*LLMRequest) SetPrompt ¶
func (instance *LLMRequest) SetPrompt(text string) *LLMRequest
SetPrompt sets the user's prompt text in the LLMRequest messages if the instance and messages are not nil and text is non-empty. This may be a "prompt" wrapper that will be formatted with the request payload. NOTE: the request payload may contain a field "user-query" that will be merged with a prompt wrapper.
func (*LLMRequest) SetPromptSystem ¶
func (instance *LLMRequest) SetPromptSystem(text string) *LLMRequest
func (*LLMRequest) String ¶
func (instance *LLMRequest) String() string
func (*LLMRequest) ToolsHistoryAdd ¶ added in v0.3.71
func (instance *LLMRequest) ToolsHistoryAdd(names ...string)
func (*LLMRequest) ToolsHistoryReset ¶ added in v0.3.71
func (instance *LLMRequest) ToolsHistoryReset()
type LLMRequestContext ¶
type LLMRequestContext struct {
Version string `json:"version"` // application version
Driver string `json:"driver"` // name of driver (usually ollama)
Model string `json:"model"` // ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
Payload *LLMRequestPayload `json:"payload"` // payload used to format prompts
SkillName string `json:"skill-name,omitempty"` // (optional) used only in agents with a skill controller
PromptName string `json:"prompt-name,omitempty"` // (optional) used only in agents with a skill controller
UserQuery string `json:"user-query,omitempty"` // (optional) used only in RAG
UserQueryMaxResults int `json:"user-query-max-results,omitempty"` // (optional) used only in RAG
SessionId string `json:"session-id,omitempty"` // (optional) id of session
VectorId string `json:"vector-id,omitempty"` // (optional) ID of RAG collection if any
// contains filtered or unexported fields
}
func NewLLMRequestContext ¶
func NewLLMRequestContext() (instance *LLMRequestContext)
func (*LLMRequestContext) GetOptions ¶
func (instance *LLMRequestContext) GetOptions() (response *RequestOptions)
func (*LLMRequestContext) Map ¶
func (instance *LLMRequestContext) Map() (m map[string]interface{})
func (*LLMRequestContext) SetUserQueryMaxResults ¶
func (instance *LLMRequestContext) SetUserQueryMaxResults(maxResults int) *LLMRequestContext
func (*LLMRequestContext) String ¶
func (instance *LLMRequestContext) String() string
type LLMRequestDefaults ¶ added in v0.3.71
type LLMRequestDefaults struct {
Driver string `json:"driver"` // name of driver
Model string `json:"model"` // ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
ModelTools string `json:"model-tools"` // model to use with tools
SkillName string `json:"skill-name,omitempty"` // (optional) used only in agents with a skill controller
PromptName string `json:"prompt-name,omitempty"` // (optional) used only in agents with a skill controller
Action ActionType `json:"action,omitempty"` // (optional) chat, generate
}
type LLMRequestEmbeddings ¶
type LLMRequestEmbeddings struct {
Version string `json:"version"` // application version
Driver string `json:"driver"` // name of driver
Model string `json:"model"` // ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
Prompt string `json:"prompt"`
// contains filtered or unexported fields
}
func NewLLMRequestEmbeddings ¶
func NewLLMRequestEmbeddings() (instance *LLMRequestEmbeddings)
func (*LLMRequestEmbeddings) GetOptions ¶
func (instance *LLMRequestEmbeddings) GetOptions() (response *RequestOptions)
func (*LLMRequestEmbeddings) Map ¶
func (instance *LLMRequestEmbeddings) Map() (m map[string]interface{})
func (*LLMRequestEmbeddings) String ¶
func (instance *LLMRequestEmbeddings) String() string
type LLMRequestPayload ¶ added in v0.3.71
type LLMRequestPayload struct {
AgentName string `json:"agent-name"`
AgentShortName string `json:"agent-short-name"`
UserId string `json:"user-id"` // user id
Lang string `json:"lang"` // user lang
UserQuery string `json:"user-query"` // request of the user
PromptLang string `json:"prompt-lang"`
FromLang string `json:"from-lang"`
ToLang string `json:"to-lang"`
Today string `json:"today"`
Now string `json:"now"`
LangCountryPrompt string `json:"lang-country-prompt"`
KBContext *RequestPayloadKBContext `json:"context,omitempty"` // (optional) Some context for prompts that need a limited knowledge for response (ex: RAG)
KBContextRawElements []string `json:"context-elements,omitempty"` // (optional) Raw elements added to context (filenames or contents)
Tools []string `json:"tools,omitempty"` // (optional) LLM tools
}
func NewRequestPayload ¶
func NewRequestPayload(args ...any) (instance *LLMRequestPayload)
func (*LLMRequestPayload) Format ¶ added in v0.3.71
func (instance *LLMRequestPayload) Format(text string) (response string)
func (*LLMRequestPayload) KBContextAppendChunks ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAppendChunks(items ...*x_commons_model.RagChunk) *LLMRequestPayload
func (*LLMRequestPayload) KBContextAppendFileContent ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAppendFileContent(filename string, bytes []byte) *LLMRequestPayload
func (*LLMRequestPayload) KBContextAppendItems ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAppendItems(items ...any) *LLMRequestPayload
func (*LLMRequestPayload) KBContextAppendNote ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAppendNote(groupName string, text string) *LLMRequestPayload
func (*LLMRequestPayload) KBContextAppendRawElement ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAppendRawElement(item string) *LLMRequestPayload
func (*LLMRequestPayload) KBContextAsArrayMap ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAsArrayMap() (response []map[string]interface{})
func (*LLMRequestPayload) KBContextAsArrayRAG ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextAsArrayRAG() (response []*x_commons_model.RagChunk)
func (*LLMRequestPayload) KBContextGet ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextGet() (response *RequestPayloadKBContext)
func (*LLMRequestPayload) KBContextGroupedByFileId ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextGroupedByFileId() (response *RequestPayloadKBContext)
func (*LLMRequestPayload) KBContextReset ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextReset() (response *RequestPayloadKBContext)
func (*LLMRequestPayload) KBContextSetNotEmpty ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextSetNotEmpty() *LLMRequestPayload
func (*LLMRequestPayload) KBContextSetRawElements ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextSetRawElements(items ...string) *LLMRequestPayload
KBContextSetRawElements set a list of elements for debug info NOTE: this method must be invoked manually For performance reasons do not add full text documents, but only a shot preview
func (*LLMRequestPayload) KBContextSize ¶ added in v0.3.71
func (instance *LLMRequestPayload) KBContextSize() int
func (*LLMRequestPayload) Map ¶ added in v0.3.71
func (instance *LLMRequestPayload) Map() (response map[string]interface{})
func (*LLMRequestPayload) Parse ¶ added in v0.3.71
func (instance *LLMRequestPayload) Parse(value any) bool
func (*LLMRequestPayload) SetLang ¶ added in v0.3.71
func (instance *LLMRequestPayload) SetLang(value string) *LLMRequestPayload
func (*LLMRequestPayload) String ¶ added in v0.3.71
func (instance *LLMRequestPayload) String() string
type LLMResponse ¶
type LLMResponse struct {
Uid string `json:"uid"`
Version string `json:"version"`
Driver string `json:"driver"`
Model string `json:"model"`
SessionId string `json:"session-id"` // id of session if any
VectorId string `json:"vector-id"` // name of RAG DB if any
VectorColl string `json:"vector-coll"` // name of RAG collection if any
Request map[string]interface{} `json:"request"` // entire original request (only for debug)
RequestSystem string `json:"request-system"` // original request system prompt (only for debug)
RequestUser string `json:"request-user"` // original request user prompt (only for debug)
Done bool `json:"done"` // used only for stream
Elapsed int `json:"elapsed"` // milliseconds
UserLang string `json:"user-lang"` // language used by user
RespRaw map[string]interface{} `json:"resp-raw"` // Native JSON response
RespContext []int `json:"resp-context"` // Context generated after response
RespText string `json:"resp-text"` // Raw text response
RespThink string `json:"resp-think"` // Think
RespJsonObject map[string]interface{} `json:"resp-json-object"` // JSON response
RespJsonArray []map[string]interface{} `json:"resp-json-array"` // JSON response
RespKnowledge []map[string]interface{} `json:"resp-knowledge"` // knowledge used in system prompt context
RespKnowledgeMetadata []map[string]interface{} `json:"resp-knowledge-metadata"` // knowledge unique metadata used as references for response
RespKnowledgeRawElements []string `json:"resp-knowledge-raw-elements"` // original raw knowledge elements passed in request. Are files or texts
RespArtifacts []*ArtifactDocument `json:"resp-artifacts"` // Artifacts (objects) returned from a request or search or external tools
RespSession map[string]interface{} `json:"resp-session"` // session info
Metadata map[string]interface{} `json:"metadata"` // Used for custom fields. This is an external payload containing fields like "project-id", "sku", etc...
}
func NewLLMResponse ¶
func NewLLMResponse(request *LLMRequest) (instance *LLMResponse)
func (*LLMResponse) AddArtifacts ¶ added in v0.3.71
func (instance *LLMResponse) AddArtifacts(items ...map[string]any)
func (*LLMResponse) GetMetaProjectId ¶
func (instance *LLMResponse) GetMetaProjectId() (response string)
GetMetaProjectId (only for NOTEBOOK) retrieves the "project-id" value from the Metadata field of the LLMResponse instance. Returns an empty string if no value is found or if the instance is nil.
func (*LLMResponse) GetMetadata ¶
func (instance *LLMResponse) GetMetadata() (response map[string]interface{})
GetMetadata retrieves the Metadata field of the LLMResponse instance, initializing it as an empty map if nil.
func (*LLMResponse) IsJSONResponse ¶
func (instance *LLMResponse) IsJSONResponse() bool
func (*LLMResponse) JSONCount ¶
func (instance *LLMResponse) JSONCount() int
func (*LLMResponse) JSONData ¶
func (instance *LLMResponse) JSONData() (response []map[string]interface{})
func (*LLMResponse) JSONForEach ¶
func (instance *LLMResponse) JSONForEach(iterator func(jsonItem map[string]any)) *LLMResponse
func (*LLMResponse) Map ¶
func (instance *LLMResponse) Map() (response map[string]interface{})
func (*LLMResponse) MapLight ¶ added in v0.3.71
func (instance *LLMResponse) MapLight() (response map[string]interface{})
MapLight returns a lightweight map representation of the LLMResponse instance, excluding extensive or nested fields.
func (*LLMResponse) SetMetaProjectId ¶
func (instance *LLMResponse) SetMetaProjectId(value string) *LLMResponse
SetMetaProjectId (only for NOTEBOOK) sets the "project-id" value within the Metadata field of the LLMResponse instance and returns the instance.
func (*LLMResponse) SetRequest ¶
func (instance *LLMResponse) SetRequest(request *LLMRequest) *LLMResponse
SetRequest associates an LLMRequest with the LLMResponse instance and updates relevant fields like Model and UserLang.
func (*LLMResponse) SetResponse ¶
func (instance *LLMResponse) SetResponse(rawResponse map[string]interface{}) *LLMResponse
SetResponse updates the LLMResponse instance with the provided raw response data and marks the operation as complete.
func (*LLMResponse) SetTextResponse ¶
func (instance *LLMResponse) SetTextResponse(value string) *LLMResponse
func (*LLMResponse) String ¶
func (instance *LLMResponse) String() string
type LLMToolGetFunc ¶ added in v0.3.71
type LLMToolSchemasFunc ¶ added in v0.3.71
type OperationRequest ¶ added in v0.3.71
type OperationRequest struct {
Uid string `json:"uid"` // operation unique id
Name string `json:"name"` // operation name
ExecMode string `json:"exec-mode"` // "realtime", "batch" or "" empty.
LLMRequest *LLMRequest `json:"llm-request"` // user request
Artifacts []*ArtifactDocument `json:"artifacts"` // Artifacts (objects) to use into operation to transform or to use for new response artifacts
ArtifactIds []string `json:"artifact-ids"` // Document id passed to request
}
func NewOperationRequest ¶ added in v0.3.71
func NewOperationRequest(args ...any) (instance *OperationRequest)
func (*OperationRequest) CountArtifacts ¶ added in v0.3.71
func (instance *OperationRequest) CountArtifacts() int
func (*OperationRequest) HasArtifacts ¶ added in v0.3.71
func (instance *OperationRequest) HasArtifacts() bool
func (*OperationRequest) IsBatch ¶ added in v0.3.71
func (instance *OperationRequest) IsBatch() bool
func (*OperationRequest) IsRealTime ¶ added in v0.3.71
func (instance *OperationRequest) IsRealTime() bool
func (*OperationRequest) Map ¶ added in v0.3.71
func (instance *OperationRequest) Map() map[string]interface{}
func (*OperationRequest) String ¶ added in v0.3.71
func (instance *OperationRequest) String() string
type OperationResponse ¶ added in v0.3.71
type OperationResponse struct {
Error string `json:"error"`
LLMResponse *LLMResponse `json:"llm_response"` // override LLM response
Artifacts []*ArtifactDocument `json:"artifacts"` // Artifacts (objects) created or retrieved in operation
}
func (*OperationResponse) GetError ¶ added in v0.3.71
func (instance *OperationResponse) GetError() (response error)
func (*OperationResponse) HasError ¶ added in v0.3.71
func (instance *OperationResponse) HasError() (response bool)
func (*OperationResponse) Map ¶ added in v0.3.71
func (instance *OperationResponse) Map() map[string]interface{}
func (*OperationResponse) MapLight ¶ added in v0.3.71
func (instance *OperationResponse) MapLight() (response map[string]interface{})
func (*OperationResponse) SetError ¶ added in v0.3.71
func (instance *OperationResponse) SetError(err error) *OperationResponse
func (*OperationResponse) String ¶ added in v0.3.71
func (instance *OperationResponse) String() string
type OptionsAgent ¶
type OptionsAgent struct {
Name string `json:"name"` // agent name
ShortName string `json:"short-name"` // agent short name
Lang string `json:"lang"` // agent default lang
AutoCalcMaxTokens bool `json:"auto-calc-max-tokens"` // if max tokens must be calculated
LimitMaxTokens int `json:"limit-max-tokens"` // maximum number of tokens allowed in this agent
LimitContextMessages int `json:"limit-context-messages"` // LimitContextMessages defines the maximum number of context messages retained for processing in the agent configuration.
ChunksMaxRows int `json:"chunks-max-rows"` // ChunksMaxRows specifies the maximum number of rows allowed per data chunk in the agent configuration.
ChunksMode string `json:"chunks-mode"` // ChunksMode specifies the operational mode for processing data chunks in the agent configuration. "max-rows", "semantic"
Drivers []*LLMDriverOptions `json:"drivers"` // LLM drivers
Documents *LLMDocumentsOptions `json:"documents"` // couch db driver settings
Gears *LLMAgentGears `json:"gears"` // settings for converters, chunkers, etc..
Tools []*LLMAgentTool `json:"tools"` // agent tools
}
func NewOptionsAgent ¶
func NewOptionsAgent() (instance *OptionsAgent)
func (*OptionsAgent) AddDriver ¶
func (instance *OptionsAgent) AddDriver(item *LLMDriverOptions)
func (*OptionsAgent) AddTool ¶ added in v0.3.71
func (instance *OptionsAgent) AddTool(item *LLMAgentTool)
func (*OptionsAgent) Clone ¶ added in v0.3.71
func (instance *OptionsAgent) Clone() (response *OptionsAgent)
func (*OptionsAgent) ContainsDriver ¶
func (instance *OptionsAgent) ContainsDriver(uid string) bool
func (*OptionsAgent) ContainsTool ¶ added in v0.3.71
func (instance *OptionsAgent) ContainsTool(name string) bool
func (*OptionsAgent) Map ¶
func (instance *OptionsAgent) Map() map[string]interface{}
func (*OptionsAgent) String ¶
func (instance *OptionsAgent) String() string
type OptionsAgentStage ¶ added in v0.3.71
type OptionsAgentStage struct {
Lang string `json:"lang"` // agent default lang
AutoCalcMaxTokens bool `json:"auto-calc-max-tokens"` // if max tokens must be calculated
LimitMaxTokens int `json:"limit-max-tokens"` // maximum number of tokens allowed in this agent
LimitContextMessages int `json:"limit-context-messages"` // LimitContextMessages defines the maximum number of context messages retained for processing in the agent configuration.
ChunksMaxRows int `json:"chunks-max-rows"` // ChunksMaxRows specifies the maximum number of rows allowed per data chunk in the agent configuration.
ChunksMode string `json:"chunks-mode"` // ChunksMode specifies the operational mode for processing data chunks in the agent configuration. "max-rows", "semantic"
Drivers []*LLMDriverOptions `json:"drivers"` // LLM drivers
Documents *LLMDocumentsOptions `json:"documents"` // couch db driver settings
Gears *LLMAgentGears `json:"gears"` // settings for converters, chunkers, etc..
}
func NewOptionsAgentStage ¶ added in v0.3.71
func NewOptionsAgentStage() (instance *OptionsAgentStage)
func (*OptionsAgentStage) AddDriver ¶ added in v0.3.71
func (instance *OptionsAgentStage) AddDriver(item *LLMDriverOptions)
func (*OptionsAgentStage) Clone ¶ added in v0.3.71
func (instance *OptionsAgentStage) Clone() (response *OptionsAgentStage)
func (*OptionsAgentStage) ContainsDriver ¶ added in v0.3.71
func (instance *OptionsAgentStage) ContainsDriver(uid string) bool
func (*OptionsAgentStage) Map ¶ added in v0.3.71
func (instance *OptionsAgentStage) Map() map[string]interface{}
func (*OptionsAgentStage) String ¶ added in v0.3.71
func (instance *OptionsAgentStage) String() string
type RequestMessage ¶
type RequestMessage struct {
Role string `json:"role"` // the role of the message, either system, user or assistant
Content string `json:"content,omitempty"` // the content of the message
Images []string `json:"images,omitempty"` // (optional) a list of base64-encoded images (for multimodal models such as llava)
}
RequestMessage ollama standard chat message
func NewAIMessageAssistant ¶
func NewAIMessageAssistant() *RequestMessage
func NewAIMessageSystem ¶
func NewAIMessageSystem() *RequestMessage
func NewAIMessageUser ¶
func NewAIMessageUser() *RequestMessage
func (*RequestMessage) Clone ¶
func (instance *RequestMessage) Clone() (response *RequestMessage)
func (*RequestMessage) Length ¶
func (instance *RequestMessage) Length() int
func (*RequestMessage) Map ¶
func (instance *RequestMessage) Map() (response map[string]interface{})
func (*RequestMessage) SetContent ¶
func (instance *RequestMessage) SetContent(value string) *RequestMessage
func (*RequestMessage) String ¶
func (instance *RequestMessage) String() string
type RequestMessageList ¶
type RequestMessageList struct {
// contains filtered or unexported fields
}
func NewMessageList ¶
func NewMessageList(args ...interface{}) (instance *RequestMessageList)
func (*RequestMessageList) Add ¶
func (instance *RequestMessageList) Add(item *RequestMessage) *RequestMessageList
func (*RequestMessageList) Count ¶
func (instance *RequestMessageList) Count() (response int)
Count returns the number of non-nil elements in the RequestMessageList.
func (*RequestMessageList) ForEach ¶
func (instance *RequestMessageList) ForEach(f func(item *RequestMessage) any)
func (*RequestMessageList) GetSystem ¶
func (instance *RequestMessageList) GetSystem() (response *RequestMessage)
func (*RequestMessageList) GetUser ¶
func (instance *RequestMessageList) GetUser() (response *RequestMessage)
func (*RequestMessageList) Length ¶
func (instance *RequestMessageList) Length() (response int)
Length calculates the total length of the content across all non-nil RequestMessage objects in the list.
func (*RequestMessageList) Map ¶
func (instance *RequestMessageList) Map() (response []map[string]interface{})
func (*RequestMessageList) ReplaceUser ¶ added in v0.3.71
func (instance *RequestMessageList) ReplaceUser(text string, images ...string) *RequestMessageList
func (*RequestMessageList) SetSystem ¶
func (instance *RequestMessageList) SetSystem(text string) *RequestMessageList
func (*RequestMessageList) SetUser ¶
func (instance *RequestMessageList) SetUser(text string, images ...string) *RequestMessageList
func (*RequestMessageList) String ¶
func (instance *RequestMessageList) String() string
type RequestOptions ¶
type RequestOptions struct {
// optionals useful
N int `json:"n,omitempty"` // Default 1. How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
MaxTokens int `json:"max_tokens,omitempty"` // The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length
Temperature float32 `json:"temperature,omitempty"` // Default 1. What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
TopP float32 `json:"top_p,omitempty"` // Default 1. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
User string `json:"user,omitempty"` // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse
NumCtx int `json:"num_ctx,omitempty"` // OLLAMA
NumPredict int `json:"num_predict,omitempty"` // OLLAMA
// optionals
FrequencyPenalty int `json:"frequency_penalty,omitempty"` // Default 0. Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
LogitBias map[string]interface{} `json:"logit_bias,omitempty"` // Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
LogProbs bool `json:"logprobs,omitempty"` // Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. This option is currently not available on the gpt-4-vision-preview model.
TopLogProbs int `json:"top_logprobs,omitempty"` // An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.
PresencePenalty float32 `json:"presence_penalty,omitempty"` // Default 0.Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
Seed string `json:"seed,omitempty"` // This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
Stop string `json:"stop,omitempty"` // string / array / null. Up to 4 sequences where the API will stop generating further tokens.
Stream bool `json:"stream,omitempty"` // If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message
Tools []interface{} `json:"tools,omitempty"` // A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.
ToolChoice interface{} `json:"tool_choice,omitempty"` // Controls which (if any) function is called by the model. none means the model will not call a function and instead generates a message. auto means the model can pick between generating a message or calling a function. Specifying a particular function via {"type": "function", "function": {"name": "my_function"}} forces the model to call that function. none is the default when no functions are present. auto is the default if functions are present
TopK float32 `json:"topk,omitempty"` // Qwen3
MinP float32 `json:"min_p,omitempty"` // Qwen3
}
func NewModelOptions ¶
func NewModelOptions() (instance *RequestOptions)
func (*RequestOptions) Map ¶
func (instance *RequestOptions) Map() map[string]interface{}
func (*RequestOptions) String ¶
func (instance *RequestOptions) String() string
type RequestPayloadKBContext ¶
type RequestPayloadKBContext struct {
Alias string `json:"alias"` // if assigned (i.e. "x_commons.SessionContextId") the context is intended as vector placeholder
Items []map[string]interface{} `json:"items"`
}
func NewRequestPayloadKBContext ¶ added in v0.3.71
func NewRequestPayloadKBContext() (instance *RequestPayloadKBContext)
func (*RequestPayloadKBContext) Append ¶
func (instance *RequestPayloadKBContext) Append(items ...any) *RequestPayloadKBContext
func (*RequestPayloadKBContext) GroupItemsByFileId ¶ added in v0.3.56
func (instance *RequestPayloadKBContext) GroupItemsByFileId() (response []map[string]interface{})
func (*RequestPayloadKBContext) Map ¶
func (instance *RequestPayloadKBContext) Map() (response map[string]interface{})
func (*RequestPayloadKBContext) Reset ¶
func (instance *RequestPayloadKBContext) Reset() *RequestPayloadKBContext
func (*RequestPayloadKBContext) Size ¶
func (instance *RequestPayloadKBContext) Size() int
func (*RequestPayloadKBContext) String ¶
func (instance *RequestPayloadKBContext) String() string
func (*RequestPayloadKBContext) ToArrayMap ¶
func (instance *RequestPayloadKBContext) ToArrayMap() (response []map[string]interface{})
func (*RequestPayloadKBContext) ToArrayRAG ¶
func (instance *RequestPayloadKBContext) ToArrayRAG() (response []*x_commons_model.RagChunk)
type StreamHandler ¶
type StreamHandler func(data []byte)
type ToolModel ¶ added in v0.3.71
type ToolModel struct {
Type string `json:"type"`
Function *ToolModelFunction `json:"function"`
}
ToolModel
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather for a city.Args:",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "str",
"description": "The city to get the weather for.Returns: A string with the current temperature in Celsius for the city."
}
},
"required": [
"city"
]
}
}
}
func NewToolModel ¶ added in v0.3.71
func NewToolModel() (instance *ToolModel)
func NewToolModelFromSchema ¶ added in v0.3.71
type ToolModelFunction ¶ added in v0.3.71
type ToolModelFunction struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters *ToolModelFunctionParameters `json:"parameters"`
}
func (*ToolModelFunction) Map ¶ added in v0.3.71
func (instance *ToolModelFunction) Map() map[string]interface{}
func (*ToolModelFunction) String ¶ added in v0.3.71
func (instance *ToolModelFunction) String() string
type ToolModelFunctionParameters ¶ added in v0.3.71
type ToolModelFunctionParameters struct {
Type string `json:"type"`
Properties map[string]*ToolModelFunctionParametersProperties `json:"properties"`
Required []string `json:"required,omitempty"`
}
func (*ToolModelFunctionParameters) Map ¶ added in v0.3.71
func (instance *ToolModelFunctionParameters) Map() map[string]interface{}
func (*ToolModelFunctionParameters) String ¶ added in v0.3.71
func (instance *ToolModelFunctionParameters) String() string
type ToolModelFunctionParametersProperties ¶ added in v0.3.71
type ToolResponseModel ¶ added in v0.3.71
type ToolResponseModel struct {
Tool *ToolModel `json:"tool"`
Response []string `json:"response"` // text rows returned from tool
ResponseArtifacts []*ArtifactDocument `json:"response-artifacts"` // data/file/object returned from tool
LLMResponse *LLMResponse `json:"llm_response"` // override LLM response
Error string `json:"error"`
Prompt string `json:"prompt"` // override basic prompt
System string `json:"system"` // override system prompt
Payload map[string]any `json:"payload"` // overwrite the payload
}
func NewToolResponseModel ¶ added in v0.3.71
func NewToolResponseModel(tool any) (instance *ToolResponseModel)
func (*ToolResponseModel) AddArtifacts ¶ added in v0.3.71
func (instance *ToolResponseModel) AddArtifacts(items ...map[string]any)
func (*ToolResponseModel) GetError ¶ added in v0.3.71
func (instance *ToolResponseModel) GetError() (response error)
func (*ToolResponseModel) HasError ¶ added in v0.3.71
func (instance *ToolResponseModel) HasError() (response bool)
func (*ToolResponseModel) HasPrompts ¶ added in v0.3.71
func (instance *ToolResponseModel) HasPrompts() (response bool)
func (*ToolResponseModel) Name ¶ added in v0.3.71
func (instance *ToolResponseModel) Name() (response string)
Source Files
¶
- const.go
- const_agents.go
- const_entities.go
- const_interfaces.go
- const_interfaces_databases.go
- const_interfaces_tool.go
- const_prompt.go
- model_artifact_document.go
- model_artifact_output.go
- model_llm_request.go
- model_llm_request_context.go
- model_llm_request_embeddings.go
- model_llm_request_message.go
- model_llm_request_options.go
- model_llm_request_payload.go
- model_llm_response.go
- model_op_request.go
- model_op_response.go
- model_tool.go
- model_tool_response.go
- options_llm_agent.go
- options_llm_agent_stage.go
- options_llm_docs.go
- options_llm_docs_embeddings.go
- options_llm_docs_rag.go
- options_llm_docs_sources_vfs.go
- options_llm_driver.go
- options_llm_driver_creator.go
- options_llm_gears.go
- options_llm_tool.go
- utils_prompts.go