auxdataaisdkgo

package module
v0.0.0-...-2eb7696 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 12 Imported by: 0

README

sdk-go

SDK for AuxData.ai AIaaS Platform

WORK IN PROGRESS DO NOT USE!

Documentation

Index

Constants

View Source
const (
	DEFAULT_URL                = "https://auxdata.ai"
	DEV_URL                    = "https://dev.auxdata.ai"
	DEBUG_URL                  = "http://localhost:8080"
	DEFAULT_MAX_RETRIES        = 5
	DEFAULT_TIMEOUT            = 120 * time.Second
	BASE_ROUTE                 = "/api/v1"
	SEARCH_URL_ROUTE_AGENT     = BASE_ROUTE + "/agent/${agentid}/document"
	SEARCH_URL_ROUTE_CONTAINER = BASE_ROUTE + "/agent/${agentid}/container/${containerid}/document"
	UPLOAD_URL_ROUTE           = BASE_ROUTE + "/agent/${agentid}/container/${containerid}/document"
	CHAT_URL_ROUTE             = BASE_ROUTE + "/agent/${agentid}/chat"
	CHAT_CONTAINER_URL_ROUTE   = BASE_ROUTE + "/agent/${agentid}/container/${containerid}/chat"
	AISERVICE_URL_ROUTE        = BASE_ROUTE + "/agent/${agentid}/executeservice/${serviceid}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AiExecutionConfig

type AiExecutionConfig struct {
	Provider                         string  `json:"provider"`
	ChainOfThougtPrompting           bool    `json:"chainofthought"`
	PalPrompting                     bool    `json:"palprompting"`
	ReflectionPrompting              bool    `json:"reflectionprompting"`
	LogicRules                       bool    `json:"logicrules"`
	PromptDebugging                  bool    `json:"promptdebugging"`
	RollingChunks                    bool    `json:"rollingchunks"`
	MaxParameterSize                 int64   `json:"maxparametersize"` // 1000 - 100000
	TopP                             int64   `json:"topp"`             // 0 - 99
	Temperature                      int64   `json:"temperature"`      // 0 - 150
	Language                         string  `json:"language"`
	Role                             string  `json:"role"`
	QualityGate                      float32 `json:"qualitygate"`
	GptFallback                      bool    `json:"gptfallback"`
	ChunkLimit                       int64   `json:"chunklimit"`
	DisableRAG                       bool    `json:"disablerag"`
	Containers                       []int64 `json:"containers"`
	Customizing                      string  `json:"customizing"`
	HistoryDepth                     int64   `json:"historydepth"`
	PresencePenalty                  float32 `json:"presencepenalty"`  // openai specific
	FrequencyPenalty                 float32 `json:"frequencypenalty"` // openai specific
	Greeting                         string  `json:"greeting"`
	ImageSize                        string  `json:"imagesize"`
	Voice                            string  `json:"voice"`
	SaveInKnowledgeDb                bool    `json:"saveinknowledgedb"`
	ContainerForSaveId               int64   `json:"containerforsaveid"`
	HierarchicalSearch               bool    `json:"hierarchicalsearch"`
	HierarchicalSearchChunkLimit     int64   `json:"hierarchicalsearchchunklimit"`
	ChatbotMemory                    bool    `json:"chatbotmemoryactive"`
	ChatbotShowSourceInformation     bool    `json:"chatbotshowsourceinformation"`
	ChatbotMaxServiceRecommandations int64   `json:"chatbotmaxservicerecommandations"`
	ChatbotQualityGateRecommendation int64   `json:"chatbotqualitygaterecommendation"`
	ChatbotQualityGateMemory         int64   `json:"chatbotqualitygatememory"`
}

type AiServiceMultiAnswer

type AiServiceMultiAnswer struct {
	Prompt  string            `json:"questions"`
	Results []AiServiceResult `json:"answers"`
}

type AiServiceResult

type AiServiceResult struct {
	Result             string                    `json:"answer"`
	NextQuestionResult AiServiceMultiAnswer      `json:"nextQuestion"`
	QuestionObject     ExecuteServiceStepCommand `json:"questionObject"`
}

type AiServiceValue

type AiServiceValue interface {
	// contains filtered or unexported methods
}

type AiServiceValueFile

type AiServiceValueFile struct {
	Value File
}

type AiServiceValueString

type AiServiceValueString struct {
	Value string
}

type AuxDataClient

type AuxDataClient struct {
	// contains filtered or unexported fields
}

func NewAuxDataClient

func NewAuxDataClient(apiKey string, url string, maxRetries int, timeout time.Duration) *AuxDataClient

NewAuxDataClient creates a new instance of AuxDataClient with the provided parameters. If the apiKey is an empty string, it attempts to retrieve the API key from the environment variable "AUXDTA_API_KEY". Parameters:

  • apiKey: The API key for authentication. If empty, it will be fetched from the environment variable.
  • url: The base URL for the API.
  • maxRetries: The maximum number of retry attempts for failed requests.
  • timeout: The timeout duration for the client.

Returns:

A pointer to an initialized AuxDataClient.

func NewAuxDataClientDefault

func NewAuxDataClientDefault(apiKey string) *AuxDataClient

NewAuxDataClientDefault creates a new instance of AuxDataClient with default settings. It requires an API key as a parameter and uses default values for URL, maximum retries, and timeout.

Parameters:

  • apiKey: A string representing the API key for authentication.

Returns:

  • A pointer to an instance of AuxDataClient configured with default settings.

func (*AuxDataClient) ChatWithAllContainers

func (c *AuxDataClient) ChatWithAllContainers(agentId int64, chat Chat) (ChatResult, error)

ChatWithAllContainers sends a chat message to all containers associated with the given agent ID. It constructs the appropriate URL route with the agent ID and sends the chat message.

Parameters:

  • agentId: The ID of the agent to send the chat message to.
  • chat: The chat message to be sent.

Returns:

  • ChatResult: The result of the chat operation.
  • error: An error if the chat operation fails.

func (*AuxDataClient) ChatWithOneContainers

func (c *AuxDataClient) ChatWithOneContainers(agentId int64, containerId int64, chat Chat) (ChatResult, error)

ChatWithOneContainers sends a chat message to a specific container identified by the given agent and container IDs. It constructs the appropriate URL route with the provided parameters and sends the chat message.

Parameters:

  • agentId: The ID of the agent initiating the chat.
  • containerId: The ID of the container to which the chat message is sent.
  • chat: The chat message to be sent.

Returns:

  • ChatResult: The result of the chat operation.
  • error: An error object if an error occurred during the chat operation.

func (*AuxDataClient) ExecuteAiService

func (c *AuxDataClient) ExecuteAiService(agentId int64, serviceId int64, parameters map[string]AiServiceValue) (ExecuteServiceResult, error)

ExecuteAiService executes an AI service for a given agent and service ID with specified parameters.

Parameters:

  • agentId: The ID of the agent for which the AI service is to be executed.
  • serviceId: The ID of the AI service to be executed.
  • parameters: A map of parameters to be passed to the AI service.

Returns:

  • ExecuteServiceResult: The result of the AI service execution.
  • error: An error object if there was an issue executing the service, otherwise nil.

func (*AuxDataClient) SearchOnAgent

func (c *AuxDataClient) SearchOnAgent(agentId int64, search Search) (DetailSearchResult, error)

SearchOnAgent performs a search operation for a specific agent.

Parameters:

  • agentId: The ID of the agent to search on.
  • search: The search criteria to use.

Returns:

  • DetailSearchResult: The result of the search operation.
  • error: An error object if the search operation fails.

func (*AuxDataClient) SearchOnContainer

func (c *AuxDataClient) SearchOnContainer(agentId int64, containerId int64, search Search) (DetailSearchResult, error)

SearchOnContainer performs a search operation within a specified container. It takes the following parameters: - agentId: The ID of the agent performing the search. - containerId: The ID of the container to search within. - search: The search criteria to be used.

It returns a DetailSearchResult containing the search results, or an error if the search fails.

func (*AuxDataClient) UploadFile

func (c *AuxDataClient) UploadFile(agentId int64, containerId int64, file FileData) ([]UploadedFilesResult, error)

UploadFile uploads a file to a specified container for a given agent.

Parameters:

  • agentId: The ID of the agent to which the file belongs.
  • containerId: The ID of the container where the file will be uploaded.
  • file: The file data to be uploaded.

Returns:

  • UploadedFilesResult: The result of the file upload operation.
  • error: An error object if the upload fails, otherwise nil.

func (*AuxDataClient) UploadFileFromDirectory

func (c *AuxDataClient) UploadFileFromDirectory(agentId int64, containerId int64, file FileDataToLoad) ([]UploadedFilesResult, error)

UploadFileFromDirectory uploads a file from a specified directory to a container. It takes the agent ID, container ID, and file data to load as parameters. The function reads the file content from the provided file path and uploads it using the UploadFile method. It returns the result of the upload and an error if any occurs during the process.

Parameters:

  • agentId: The ID of the agent performing the upload.
  • containerId: The ID of the container to which the file is being uploaded.
  • file: The file data to load, including the document ID, file path, and link.

Returns:

  • UploadedFilesResult: The result of the file upload.
  • error: An error if any occurs during the file reading or uploading process.

type Chat

type Chat struct {
	Prompt   string `json:"question"`
	ComUuid  string `json:"comuuid"`
	UserMail string `json:"usermail"`
}

type ChatCommunication

type ChatCommunication struct {
	Timestamp time.Time `json:"timestamp"`
	Prompt    string    `json:"user"`
	Response  string    `json:"bot"`
}

type ChatResult

type ChatResult struct {
	Command            ExecuteServiceStepCommand `json:"command"`
	Result             string                    `json:"answer"`
	Context            string                    `json:"context"`
	Error              string                    `json:"error"`
	ComUuid            string                    `json:"comuuid"`
	InformationSources []SearchChunkResult       `json:"sources"`
}

type DetailSearchCommand

type DetailSearchCommand struct {
	Question    string  `json:"question"`
	Token       string  `json:"accesstoken"`
	AgentId     int64   `json:"botid"`
	QualityGate float32 `json:"qualitygate"`
	ResultLimit int64   `json:"resultLimit"`
	ContainerId int64   `json:"containerid"`
}

type DetailSearchResult

type DetailSearchResult struct {
	Command DetailSearchCommand `json:"command"`
	Results []SearchChunkResult `json:"results"`
	Error   string              `json:"error"`
}

type ExecuteServiceCommand

type ExecuteServiceCommand struct {
	AgentId        int64             `json:"botid"`
	ServiceId      int64             `json:"templateid"`
	Parameters     map[string]string `json:"parameters,omitempty"`
	BackgroundMode bool              `json:"backgroundmodepossible"`
}

type ExecuteServiceResult

type ExecuteServiceResult struct {
	Command        ExecuteServiceCommand `json:"command"`
	MulitResults   AiServiceMultiAnswer  `json:"answer"`
	Error          string                `json:"error"`
	BackgroundMode bool                  `json:"background"`
}

type ExecuteServiceStepCommand

type ExecuteServiceStepCommand struct {
	Prompt                  string              `json:"question"`
	User                    User                `json:"user"`
	AgentId                 int64               `json:"botid"`
	ResultType              string              `json:"answertype"`
	Title                   string              `json:"title"`
	Displaytype             string              `json:"displaytype"`
	ComUuid                 string              `json:"comuuid"`
	History                 []ChatCommunication `json:"history"`
	Examples                []ResultExample     `json:"examples"`
	OutputFormatDescription string              `json:"outputformatdescription"`
	CommandConfig           AiExecutionConfig   `json:"queryconfig"`
	Preprocessing           Processor           `json:"prepocessing"`
	Postprocessing          PostProcessor       `json:"postpocessing"`
}

type File

type File struct {
	FileType string `json:"name"`
	Filename string `json:"type"`
	Content  string `json:"content"` // base64String
}

type FileData

type FileData struct {
	FileType    string
	Filename    string
	Link        string
	FileContent []byte
	DocumentId  string // for new documents always "" if you want to update a document set the documentid
}

type FileDataToLoad

type FileDataToLoad struct {
	FilePath   string
	Link       string
	DocumentId string // for new documents always "" if you want to update a document set the documentid
}

type PostProcessor

type PostProcessor struct {
	Type    string                `json:"type"`
	Command string                `json:"command"`
	Call    ProcessCallDefinition `json:"call"`
}

type ProcessCallDefinition

type ProcessCallDefinition struct {
	Id     int64    `json:"id"`
	Name   string   `json:"name"`
	Key    string   `json:"key"`
	Params []string `json:"params"`
}

type Processor

type Processor struct {
	Http     []ProcessCallDefinition `json:"http"`
	Function []ProcessCallDefinition `json:"function"`
}

type ResultExample

type ResultExample struct {
	Input  string `json:"input"`
	Output string `json:"output"`
}
type Search struct {
	SearchString string  `json:"question"`
	QualityGate  float32 `json:"qualitygate"`
	ResultLimit  int64   `json:"resultLimit"`
}

type SearchChunkResult

type SearchChunkResult struct {
	Chunk            string  `json:"chunk"`
	DocumentId       string  `json:"documentId"`
	Score            float32 `json:"score"`
	Name             string  `json:"name"`
	Link             string  `json:"link"`
	ChunkId          int64   `json:"chunkid"`
	CreationDate     string  `json:"creationdate"`
	LastModifiedDate string  `json:"lastmodifieddate"`
	AgentId          int64   `json:"agentid"`
}

type UploadedFilesResult

type UploadedFilesResult struct {
	Filename   string `json:"filename"`
	Filetype   string `json:"filetype"`
	DocumentId string `json:"documentid"`
}

type User

type User struct {
	Id             int64      `json:"id"`
	KeycloakId     string     `json:"keycloakuserId"`
	FirstName      string     `json:"firstName"`
	LastName       string     `json:"name"`
	OrganisationId int64      `json:"organisationId"`
	Role           int64      `json:"role"`
	Email          string     `json:"email"`
	Config         UserConfig `json:"config"`
}

type UserConfig

type UserConfig struct {
	Role       string `json:"role"`
	Behavior   string `json:"behavior"`
	TextSample string `json:"textsample"`
	Language   string `json:"language"`
}

Jump to

Keyboard shortcuts

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