...

Package externalfunctions

import "github.com/ansys/allie-flowkit/pkg/externalfunctions"
Overview
Index

Overview ▾

Index ▾

Variables
func AddDataRequest(collectionName string, documentData []sharedtypes.DbData)
func AisAcsSemanticHybridSearchs(query string, embeddedQuery []float32, indexList []string, physics []string, topK int) (output []sharedtypes.ACSSearchResponse)
func AisChangeAcsResponsesByFactor(factors map[string]float64, semanticSearchOutput []sharedtypes.ACSSearchResponse) (changedSemanticSearchOutput []sharedtypes.ACSSearchResponse)
func AisPerformLLMFinalRequest(systemTemplate string, userTemplate string, query string, history []sharedtypes.HistoricMessage, context []sharedtypes.ACSSearchResponse, prohibitedWords []string, errorList1 []string, errorList2 []string, isStream bool) (message string, stream *chan string)
func AisPerformLLMRephraseRequest(systemTemplate string, userTemplate string, query string, history []sharedtypes.HistoricMessage) (rephrasedQuery string)
func AisReturnIndexList(accessPoint string) (indexList []string)
func AnsysGPTACSSemanticHybridSearchs(query string, embeddedQuery []float32, indexList []string, filter map[string]string, topK int) (output []sharedtypes.ACSSearchResponse)
func AnsysGPTBuildFinalQuery(refrasedQuery string, context []sharedtypes.ACSSearchResponse) (finalQuery string, errorResponse string, displayFixedMessageToUser bool)
func AnsysGPTCheckProhibitedWords(query string, prohibitedWords []string, errorResponseMessage string) (foundProhibited bool, responseMessage string)
func AnsysGPTExtractFieldsFromQuery(query string, fieldValues map[string][]string, defaultFields []sharedtypes.AnsysGPTDefaultFields) (fields map[string]string)
func AnsysGPTGetSystemPrompt(query string, prohibitedWords []string, template string) (systemPrompt string)
func AnsysGPTPerformLLMRephraseRequest(userTemplate string, query string, history []sharedtypes.HistoricMessage, systemPrompt string) (rephrasedQuery string)
func AnsysGPTPerformLLMRephraseRequestNew(template string, query string, history []sharedtypes.HistoricMessage) (rephrasedQuery string)
func AnsysGPTPerformLLMRequest(finalQuery string, history []sharedtypes.HistoricMessage, systemPrompt string, isStream bool) (message string, stream *chan string)
func AnsysGPTRemoveNoneCitationsFromSearchResponse(semanticSearchOutput []sharedtypes.ACSSearchResponse, citations []sharedtypes.AnsysGPTCitation) (reducedSemanticSearchOutput []sharedtypes.ACSSearchResponse)
func AnsysGPTReorderSearchResponseAndReturnOnlyTopK(semanticSearchOutput []sharedtypes.ACSSearchResponse, topK int) (reorderedSemanticSearchOutput []sharedtypes.ACSSearchResponse)
func AnsysGPTReturnIndexList(indexGroups []string) (indexList []string)
func AppendMessageHistory(newMessage string, role AppendMessageHistoryRole, history []sharedtypes.HistoricMessage) (updatedHistory []sharedtypes.HistoricMessage)
func AppendStringSlices(slice1, slice2, slice3, slice4, slice5 []string) []string
func AssignStringToString(inputString string) (outputString string)
func BuildFinalQueryForCodeLLMRequest(request string, knowledgedbResponse []sharedtypes.DbResponse) (finalQuery string)
func BuildFinalQueryForGeneralLLMRequest(request string, knowledgedbResponse []sharedtypes.DbResponse) (finalQuery string)
func BuildLibraryContext(message string, libraryContext string) (messageWithContext string)
func CreateCollectionRequest(collectionName string)
func CreateDbFilter(guid []string, documentId []string, documentName []string, level []string, tags sharedtypes.DbArrayFilter, keywords sharedtypes.DbArrayFilter, metadata []sharedtypes.DbJsonFilter) (databaseFilter sharedtypes.DbFilters)
func CreateKeywordsDbFilter(keywords []string, needAll bool) (databaseFilter sharedtypes.DbArrayFilter)
func CreateMetadataDbFilter(fieldName string, fieldType string, filterData []string, needAll bool) (databaseFilter sharedtypes.DbJsonFilter)
func CreateTagsDbFilter(tags []string, needAll bool) (databaseFilter sharedtypes.DbArrayFilter)
func DownloadGithubFileContent(githubRepoName string, githubRepoOwner string, githubRepoBranch string, gihubFilePath string, githubAccessToken string) (checksum string, content []byte)
func GeneralNeo4jQuery(query string) (databaseResponse sharedtypes.Neo4jResponse)
func GeneralQuery(collectionName string, maxRetrievalCount int, outputFields []string, filters sharedtypes.DbFilters) (databaseResponse []sharedtypes.DbResponse)
func GenerateDocumentTree(documentName string, documentId string, documentChunks []string, embeddingsDimensions int, getSummary bool, getKeywords bool, numKeywords int, chunkSize int, numLlmWorkers int) (returnedDocumentData []sharedtypes.DbData)
func GetDocumentType(filePath string) (documentType string)
func GetGithubFilesToExtract(githubRepoName string, githubRepoOwner string, githubRepoBranch string, githubAccessToken string, githubFileExtensions []string, githubFilteredDirectories []string, githubExcludedDirectories []string) (githubFilesToExtract []string)
func GetListCollections() (collectionsList []string)
func GetLocalFileContent(localFilePath string) (checksum string, content []byte)
func GetLocalFilesToExtract(localPath string, localFileExtensions []string, localFilteredDirectories []string, localExcludedDirectories []string) (localFilesToExtract []string)
func LangchainSplitter(bytesContent []byte, documentType string, chunkSize int, chunkOverlap int) (output []string)
func PerformBatchEmbeddingRequest(input []string) (embeddedVectors [][]float32)
func PerformCodeLLMRequest(input string, history []sharedtypes.HistoricMessage, isStream bool, validateCode bool) (message string, stream *chan string)
func PerformGeneralRequest(input string, history []sharedtypes.HistoricMessage, isStream bool, systemPrompt string) (message string, stream *chan string)
func PerformGeneralRequestSpecificModel(input string, history []sharedtypes.HistoricMessage, isStream bool, systemPrompt string, modelIds []string) (message string, stream *chan string)
func PerformKeywordExtractionRequest(input string, maxKeywordsSearch uint32) (keywords []string)
func PerformSummaryRequest(input string) (summary string)
func PerformVectorEmbeddingRequest(input string) (embeddedVector []float32)
func RetrieveDependencies(collectionName string, relationshipName string, relationshipDirection string, sourceDocumentId string, nodeTypesFilter sharedtypes.DbArrayFilter, maxHopsNumber int) (dependenciesIds []string)
func SendRestAPICall(requestType string, endpoint string, header map[string]string, query map[string]string, jsonBody string) (success bool, returnJsonBody string)
func SendVectorsToKnowledgeDB(vector []float32, keywords []string, keywordsSearch bool, collection string, similaritySearchResults int, similaritySearchMinScore float64) (databaseResponse []sharedtypes.DbResponse)
func ShortenMessageHistory(history []sharedtypes.HistoricMessage, maxLength int) (updatedHistory []sharedtypes.HistoricMessage)
func SimilaritySearch(collectionName string, embeddedVector []float32, maxRetrievalCount int, outputFields []string, filters sharedtypes.DbFilters, minScore float64, getLeafNodes bool, getSiblings bool, getParent bool, getChildren bool) (databaseResponse []sharedtypes.DbResponse)
func ansysGPTACSSemanticHybridSearch(query string, embeddedQuery []float32, indexName string, filter map[string]string, topK int, isAis bool, physics []string) (output []sharedtypes.ACSSearchResponse)
func convertToFloat32Slice(interfaceSlice []interface{}) ([]float32, error)
func createDbArrayFilter(filterData []string, needAll bool) (databaseFilter sharedtypes.DbArrayFilter)
func createDbJsonFilter(fieldName string, fieldType string, filterData []string, needAll bool) (databaseFilter sharedtypes.DbJsonFilter)
func createPayloadAndSendHttpRequest(url string, requestObject interface{}, responsePtr interface{}) (funcError error, statusCode int)
func dataExtractNewGithubClient(githubAccessToken string) (client *github.Client, ctx context.Context)
func dataExtractionDocumentLevelHandler(inputChannel chan *DataExtractionLLMInputChannelItem, errorChannel chan error, chunks []string, documentId string, documentPath string, getSummary bool, getKeywords bool, numKeywords uint32) (orderedChildDataObjects []*sharedtypes.DbData, err error)
func dataExtractionFilterGithubTreeEntries(tree *github.Tree, githubFilteredDirectories, githubExcludedDirectories, githubFileExtensions []string) (githubFilesToExtract []string)
func dataExtractionLLMHandlerWorker(waitgroup *sync.WaitGroup, inputChannel chan *DataExtractionLLMInputChannelItem, errorChannel chan error, embeddingsDimensions int)
func dataExtractionLocalFilepathExtractWalker(localPath string, localFileExtensions []string, localFilteredDirectories []string, localExcludedDirectories []string, filesToExtract *[]string, f os.FileInfo, err error) error
func dataExtractionPerformSplitterRequest(content []byte, documentType string, chunkSize int, chunkOverlap int) (output []string, err error)
func dataExtractionProcessBatchEmbeddings(documentData []*sharedtypes.DbData, maxBatchSize int) error
func extractAndConvertACSResponse(body []byte, indexName string) (output []sharedtypes.ACSSearchResponse)
func extractPythonCode(markdown string) (pythonCode string, error error)
func formatTemplate(template string, data map[string]string) string
func getFieldsAndReturnProperties(indexName string) (searchedEmbeddedFields string, returnedProperties string)
func httpRequest(method string, url string, headers map[string]string, body []byte) ([]byte, error)
func initializeClient(llmHandlerEndpoint string) *websocket.Conn
func listener(c *websocket.Conn, responseChannel chan sharedtypes.HandlerResponse)
func llmHandlerPerformKeywordExtractionRequest(input string, numKeywords uint32) (keywords []string, err error)
func llmHandlerPerformSummaryRequest(input string) (summary string, err error)
func llmHandlerPerformVectorEmbeddingRequest(input []string) (embeddedVectors [][]float32, err error)
func performGeneralRequest(input string, history []sharedtypes.HistoricMessage, isStream bool, systemPrompt string, options *sharedtypes.ModelOptions) (message string, stream *chan string, err error)
func randomNameGenerator() string
func sendChatRequest(data string, chatRequestType string, history []sharedtypes.HistoricMessage, maxKeywordsSearch uint32, systemPrompt string, llmHandlerEndpoint string, modelIds []string, options *sharedtypes.ModelOptions) chan sharedtypes.HandlerResponse
func sendChatRequestNoHistory(data string, chatRequestType string, maxKeywordsSearch uint32, llmHandlerEndpoint string, modelIds []string, options *sharedtypes.ModelOptions) chan sharedtypes.HandlerResponse
func sendEmbeddingsRequest(data interface{}, llmHandlerEndpoint string, modelIds []string) chan sharedtypes.HandlerResponse
func sendRequest(adapter string, data interface{}, RequestChannel chan []byte, chatRequestType string, dataStream string, history []sharedtypes.HistoricMessage, maxKeywordsSearch uint32, systemPrompt string, responseChannel chan sharedtypes.HandlerResponse, modelIds []string, options *sharedtypes.ModelOptions)
func shutdownHandler(c *websocket.Conn)
func transferDatafromResponseToStreamChannel(responseChannel *chan sharedtypes.HandlerResponse, streamChannel *chan string, validateCode bool)
func validatePythonCode(pythonCode string) (bool, bool, error)
func writer(c *websocket.Conn, RequestChannel chan []byte, responseChannel chan sharedtypes.HandlerResponse)
type ACSSearchRequest
type ACSSearchResponseALH
type ACSSearchResponseCrtech
type ACSSearchResponseLSdyna
type ACSSearchResponseStruct
type ACSSearchResponseStructALH
type ACSSearchResponseStructCrtech
type ACSSearchResponseStructLSdyna
type ACSVectorQuery
type AppendMessageHistoryRole
type DataExtractionBranch
type DataExtractionLLMInputChannelItem
    func dataExtractionNewLlmInputChannelItem(data *sharedtypes.DbData, instructionSequenceWaitGroup *sync.WaitGroup, adapter string, chatRequestType string, maxNumberOfKeywords uint32, lock *sync.Mutex) *DataExtractionLLMInputChannelItem
type DataExtractionSplitterServiceRequest
type DataExtractionSplitterServiceResponse
type queryInput
type queryOutput
type retrieveDependenciesInput
type retrieveDependenciesOutput
type similarityElement
type similaritySearchInput
type similaritySearchOutput
type summaryCounters

Package files

ansysgpt.go dataextraction.go externalfunctions.go generic.go knowledgedb.go llmhandler.go privatefunctions.go types.go

Variables

var ExternalFunctionsMap = map[string]interface{}{

    "PerformVectorEmbeddingRequest":       PerformVectorEmbeddingRequest,
    "PerformBatchEmbeddingRequest":        PerformBatchEmbeddingRequest,
    "PerformKeywordExtractionRequest":     PerformKeywordExtractionRequest,
    "PerformGeneralRequest":               PerformGeneralRequest,
    "PerformGeneralRequestSpecificModel":  PerformGeneralRequestSpecificModel,
    "PerformCodeLLMRequest":               PerformCodeLLMRequest,
    "BuildLibraryContext":                 BuildLibraryContext,
    "BuildFinalQueryForGeneralLLMRequest": BuildFinalQueryForGeneralLLMRequest,
    "BuildFinalQueryForCodeLLMRequest":    BuildFinalQueryForCodeLLMRequest,
    "AppendMessageHistory":                AppendMessageHistory,
    "ShortenMessageHistory":               ShortenMessageHistory,

    "SendVectorsToKnowledgeDB": SendVectorsToKnowledgeDB,
    "GetListCollections":       GetListCollections,
    "RetrieveDependencies":     RetrieveDependencies,
    "GeneralNeo4jQuery":        GeneralNeo4jQuery,
    "GeneralQuery":             GeneralQuery,
    "SimilaritySearch":         SimilaritySearch,
    "CreateKeywordsDbFilter":   CreateKeywordsDbFilter,
    "CreateTagsDbFilter":       CreateTagsDbFilter,
    "CreateMetadataDbFilter":   CreateMetadataDbFilter,
    "CreateDbFilter":           CreateDbFilter,

    "AnsysGPTCheckProhibitedWords":                   AnsysGPTCheckProhibitedWords,
    "AnsysGPTExtractFieldsFromQuery":                 AnsysGPTExtractFieldsFromQuery,
    "AnsysGPTPerformLLMRephraseRequest":              AnsysGPTPerformLLMRephraseRequest,
    "AnsysGPTPerformLLMRephraseRequestNew":           AnsysGPTPerformLLMRephraseRequestNew,
    "AnsysGPTBuildFinalQuery":                        AnsysGPTBuildFinalQuery,
    "AnsysGPTPerformLLMRequest":                      AnsysGPTPerformLLMRequest,
    "AnsysGPTReturnIndexList":                        AnsysGPTReturnIndexList,
    "AnsysGPTACSSemanticHybridSearchs":               AnsysGPTACSSemanticHybridSearchs,
    "AnsysGPTRemoveNoneCitationsFromSearchResponse":  AnsysGPTRemoveNoneCitationsFromSearchResponse,
    "AnsysGPTReorderSearchResponseAndReturnOnlyTopK": AnsysGPTReorderSearchResponseAndReturnOnlyTopK,
    "AnsysGPTGetSystemPrompt":                        AnsysGPTGetSystemPrompt,
    "AisPerformLLMRephraseRequest":                   AisPerformLLMRephraseRequest,
    "AisReturnIndexList":                             AisReturnIndexList,
    "AisAcsSemanticHybridSearchs":                    AisAcsSemanticHybridSearchs,
    "AisChangeAcsResponsesByFactor":                  AisChangeAcsResponsesByFactor,
    "AisPerformLLMFinalRequest":                      AisPerformLLMFinalRequest,

    "GetGithubFilesToExtract":   GetGithubFilesToExtract,
    "GetLocalFilesToExtract":    GetLocalFilesToExtract,
    "AppendStringSlices":        AppendStringSlices,
    "DownloadGithubFileContent": DownloadGithubFileContent,
    "GetLocalFileContent":       GetLocalFileContent,
    "GetDocumentType":           GetDocumentType,
    "LangchainSplitter":         LangchainSplitter,
    "GenerateDocumentTree":      GenerateDocumentTree,
    "AddDataRequest":            AddDataRequest,
    "CreateCollectionRequest":   CreateCollectionRequest,

    "AssignStringToString": AssignStringToString,
    "SendRestAPICall":      SendRestAPICall,
}

func AddDataRequest

func AddDataRequest(collectionName string, documentData []sharedtypes.DbData)

AddDataRequest sends a request to the add_data endpoint.

Tags:

  • @displayName: Add Data

Parameters:

  • collectionName: name of the collection the request is sent to.
  • data: the data to add.

func AisAcsSemanticHybridSearchs

func AisAcsSemanticHybridSearchs(
    query string,
    embeddedQuery []float32,
    indexList []string,
    physics []string,
    topK int) (output []sharedtypes.ACSSearchResponse)

AisAcsSemanticHybridSearchs performs a semantic hybrid search in ACS

Tags:

  • @displayName: AIS ACS Semantic Hybrid Search

Parameters:

  • query: the query string
  • embeddedQuery: the embedded query
  • indexList: the index list
  • physics: the physics
  • topK: the number of results to be returned

Returns:

  • output: the search results

func AisChangeAcsResponsesByFactor

func AisChangeAcsResponsesByFactor(factors map[string]float64, semanticSearchOutput []sharedtypes.ACSSearchResponse) (changedSemanticSearchOutput []sharedtypes.ACSSearchResponse)

AisChangeAcsResponsesByFactor changes the ACS responses by a factor

Tags:

  • @displayName: Change ACS Responses By Factor

Parameters:

  • factors: the factors
  • semanticSearchOutput: the search response

Returns:

  • changedSemanticSearchOutput: the changed search response

func AisPerformLLMFinalRequest

func AisPerformLLMFinalRequest(systemTemplate string,
    userTemplate string,
    query string,
    history []sharedtypes.HistoricMessage,
    context []sharedtypes.ACSSearchResponse,
    prohibitedWords []string,
    errorList1 []string,
    errorList2 []string,
    isStream bool) (message string, stream *chan string)

AisPerformLLMFinalRequest performs a final request to LLM

Tags:

  • @displayName: AIS Final Request

Parameters:

  • systemTemplate: the system template for the final request
  • userTemplate: the user template for the final request
  • query: the user query
  • history: the conversation history
  • prohibitedWords: the list of prohibited words
  • errorList1: the list of error words
  • errorList2: the list of error words

Returns:

  • stream: the stream channel

func AisPerformLLMRephraseRequest

func AisPerformLLMRephraseRequest(systemTemplate string, userTemplate string, query string, history []sharedtypes.HistoricMessage) (rephrasedQuery string)

AisPerformLLMRephraseRequest performs a rephrase request to LLM

Tags:

  • @displayName: AIS Rephrase Request

Parameters:

  • systemTemplate: the system template for the rephrase request
  • userTemplate: the user template for the rephrase request
  • query: the user query
  • history: the conversation history

Returns:

  • rephrasedQuery: the rephrased query

func AisReturnIndexList

func AisReturnIndexList(accessPoint string) (indexList []string)

AisReturnIndexList returns the index list for AIS

Tags:

  • @displayName: Get AIS Index List

Parameters:

  • accessPoint: the access point

Returns:

  • indexList: the index list

func AnsysGPTACSSemanticHybridSearchs

func AnsysGPTACSSemanticHybridSearchs(
    query string,
    embeddedQuery []float32,
    indexList []string,
    filter map[string]string,
    topK int) (output []sharedtypes.ACSSearchResponse)

AnsysGPTACSSemanticHybridSearchs performs a semantic hybrid search in ACS

Tags:

  • @displayName: ACS Semantic Hybrid Search

Parameters:

  • query: the query string
  • embeddedQuery: the embedded query
  • indexList: the index list
  • typeOfAsset: the type of asset
  • physics: the physics
  • product: the product
  • productMain: the main product
  • filter: the filter
  • filterAfterVectorSearch: the flag to define the filter order
  • returnedProperties: the properties to be returned
  • topK: the number of results to be returned from vector search
  • searchedEmbeddedFields: the ACS fields to be searched

Returns:

  • output: the search results

func AnsysGPTBuildFinalQuery

func AnsysGPTBuildFinalQuery(refrasedQuery string, context []sharedtypes.ACSSearchResponse) (finalQuery string, errorResponse string, displayFixedMessageToUser bool)

AnsysGPTBuildFinalQuery builds the final query for Ansys GPT

Tags:

  • @displayName: Build Final Query

Parameters:

  • refrasedQuery: the refrased query
  • context: the context

Returns:

  • finalQuery: the final query

func AnsysGPTCheckProhibitedWords

func AnsysGPTCheckProhibitedWords(query string, prohibitedWords []string, errorResponseMessage string) (foundProhibited bool, responseMessage string)

AnsysGPTCheckProhibitedWords checks the user query for prohibited words

Tags:

  • @displayName: Check Prohibited Words

Parameters:

  • query: the user query
  • prohibitedWords: the list of prohibited words
  • errorResponseMessage: the error response message

Returns:

  • foundProhibited: the flag indicating whether prohibited words were found
  • responseMessage: the response message

func AnsysGPTExtractFieldsFromQuery

func AnsysGPTExtractFieldsFromQuery(query string, fieldValues map[string][]string, defaultFields []sharedtypes.AnsysGPTDefaultFields) (fields map[string]string)

AnsysGPTExtractFieldsFromQuery extracts the fields from the user query

Tags:

  • @displayName: Extract Fields

Parameters:

  • query: the user query
  • fieldValues: the field values that the user query can contain
  • defaultFields: the default fields that the user query can contain

Returns:

  • fields: the extracted fields

func AnsysGPTGetSystemPrompt

func AnsysGPTGetSystemPrompt(query string, prohibitedWords []string, template string) (systemPrompt string)

AnsysGPTGetSystemPrompt returns the system prompt for Ansys GPT

Tags:

  • @displayName: Get System Prompt

Parameters:

  • rephrasedQuery: the rephrased query

Returns:

  • systemPrompt: the system prompt

func AnsysGPTPerformLLMRephraseRequest

func AnsysGPTPerformLLMRephraseRequest(userTemplate string, query string, history []sharedtypes.HistoricMessage, systemPrompt string) (rephrasedQuery string)

AnsysGPTPerformLLMRephraseRequest performs a rephrase request to LLM

Tags:

  • @displayName: Rephrase Request

Parameters:

  • template: the template for the rephrase request
  • query: the user query
  • history: the conversation history

Returns:

  • rephrasedQuery: the rephrased query

func AnsysGPTPerformLLMRephraseRequestNew

func AnsysGPTPerformLLMRephraseRequestNew(template string, query string, history []sharedtypes.HistoricMessage) (rephrasedQuery string)

AnsysGPTPerformLLMRephraseRequestNew performs a rephrase request to LLM

Tags:

  • @displayName: Rephrase Request New

Parameters:

  • template: the template for the rephrase request
  • query: the user query
  • history: the conversation history

Returns:

  • rephrasedQuery: the rephrased query

func AnsysGPTPerformLLMRequest

func AnsysGPTPerformLLMRequest(finalQuery string, history []sharedtypes.HistoricMessage, systemPrompt string, isStream bool) (message string, stream *chan string)

AnsysGPTPerformLLMRequest performs a request to Ansys GPT

Tags:

  • @displayName: LLM Request

Parameters:

  • finalQuery: the final query
  • history: the conversation history
  • systemPrompt: the system prompt

Returns:

  • stream: the stream channel

func AnsysGPTRemoveNoneCitationsFromSearchResponse

func AnsysGPTRemoveNoneCitationsFromSearchResponse(semanticSearchOutput []sharedtypes.ACSSearchResponse, citations []sharedtypes.AnsysGPTCitation) (reducedSemanticSearchOutput []sharedtypes.ACSSearchResponse)

AnsysGPTRemoveNoneCitationsFromSearchResponse removes none citations from search response

Tags:

  • @displayName: Remove None Citations

Parameters:

  • semanticSearchOutput: the search response
  • citations: the citations

Returns:

  • reducedSemanticSearchOutput: the reduced search response

func AnsysGPTReorderSearchResponseAndReturnOnlyTopK

func AnsysGPTReorderSearchResponseAndReturnOnlyTopK(semanticSearchOutput []sharedtypes.ACSSearchResponse, topK int) (reorderedSemanticSearchOutput []sharedtypes.ACSSearchResponse)

AnsysGPTReorderSearchResponseAndReturnOnlyTopK reorders the search response

Tags:

  • @displayName: Reorder Search Response

Parameters:

  • semanticSearchOutput: the search response
  • topK: the number of results to be returned

Returns:

  • reorderedSemanticSearchOutput: the reordered search response

func AnsysGPTReturnIndexList

func AnsysGPTReturnIndexList(indexGroups []string) (indexList []string)

AnsysGPTReturnIndexList returns the index list for Ansys GPT

Tags:

  • @displayName: List Indexes

Parameters:

  • indexGroups: the index groups

Returns:

  • indexList: the index list

func AppendMessageHistory

func AppendMessageHistory(newMessage string, role AppendMessageHistoryRole, history []sharedtypes.HistoricMessage) (updatedHistory []sharedtypes.HistoricMessage)

AppendMessageHistory appends a new message to the conversation history

Tags:

  • @displayName: Append Message History

Parameters:

  • newMessage: the new message
  • role: the role of the message
  • history: the conversation history

Returns:

  • updatedHistory: the updated conversation history

func AppendStringSlices

func AppendStringSlices(slice1, slice2, slice3, slice4, slice5 []string) []string

AppendStringSlices creates a new slice by appending all elements of the provided slices.

Tags:

  • @displayName: Append String Slices

Parameters:

  • slice1, slice2, slice3, slice4, slice5: slices to append.

Returns:

  • result: a new slice with all elements appended.

func AssignStringToString

func AssignStringToString(inputString string) (outputString string)

AssignStringToString assigns a string to another string

Tags:

  • @displayName: Assign String to String

Parameters:

  • inputString: the input string

Returns:

  • outputString: the output string

func BuildFinalQueryForCodeLLMRequest

func BuildFinalQueryForCodeLLMRequest(request string, knowledgedbResponse []sharedtypes.DbResponse) (finalQuery string)

BuildFinalQueryForCodeLLMRequest builds the final query for a code generation request to LLM. The final query is a markdown string that contains the original request and the code examples from the KnowledgeDB.

Tags:

  • @displayName: Final Query (Code LLM Request)

Parameters:

  • request: the original request
  • knowledgedbResponse: the KnowledgeDB response

Returns:

  • finalQuery: the final query

func BuildFinalQueryForGeneralLLMRequest

func BuildFinalQueryForGeneralLLMRequest(request string, knowledgedbResponse []sharedtypes.DbResponse) (finalQuery string)

BuildFinalQueryForGeneralLLMRequest builds the final query for a general request to LLM. The final query is a markdown string that contains the original request and the examples from the KnowledgeDB.

Tags:

  • @displayName: Final Query (General LLM Request)

Parameters:

  • request: the original request
  • knowledgedbResponse: the KnowledgeDB response

Returns:

  • finalQuery: the final query

func BuildLibraryContext

func BuildLibraryContext(message string, libraryContext string) (messageWithContext string)

BuildLibraryContext builds the context string for the query

Tags:

  • @displayName: Library Context

Parameters:

  • message: the message string
  • libraryContext: the library context string

Returns:

  • messageWithContext: the message with context

func CreateCollectionRequest

func CreateCollectionRequest(collectionName string)

CreateCollectionRequest sends a request to the collection endpoint.

Tags:

  • @displayName: Create Collection

Parameters:

  • collectionName: the name of the collection to create.

func CreateDbFilter

func CreateDbFilter(
    guid []string,
    documentId []string,
    documentName []string,
    level []string,
    tags sharedtypes.DbArrayFilter,
    keywords sharedtypes.DbArrayFilter,
    metadata []sharedtypes.DbJsonFilter) (databaseFilter sharedtypes.DbFilters)

CreateDbFilter creates a filter for the KnowledgeDB.

The function returns the filter.

Tags:

  • @displayName: Create Filter

Parameters:

  • guid: the guid filter
  • documentId: the document ID filter
  • documentName: the document name filter
  • level: the level filter
  • tags: the tags filter
  • keywords: the keywords filter
  • metadata: the metadata filter

Returns:

  • databaseFilter: the filter

func CreateKeywordsDbFilter

func CreateKeywordsDbFilter(keywords []string, needAll bool) (databaseFilter sharedtypes.DbArrayFilter)

CreateKeywordsDbFilter creates a keywords filter for the KnowledgeDB.

The function returns the keywords filter.

Tags:

  • @displayName: Keywords Filter

Parameters:

  • keywords: the keywords to be used for the filter
  • needAll: flag to indicate whether all keywords are needed

Returns:

  • databaseFilter: the keywords filter

func CreateMetadataDbFilter

func CreateMetadataDbFilter(fieldName string, fieldType string, filterData []string, needAll bool) (databaseFilter sharedtypes.DbJsonFilter)

CreateMetadataDbFilter creates a metadata filter for the KnowledgeDB.

The function returns the metadata filter.

Tags:

  • @displayName: Metadata Filter

Parameters:

  • fieldName: the name of the field
  • fieldType: the type of the field
  • filterData: the filter data
  • needAll: flag to indicate whether all data is needed

Returns:

  • databaseFilter: the metadata filter

func CreateTagsDbFilter

func CreateTagsDbFilter(tags []string, needAll bool) (databaseFilter sharedtypes.DbArrayFilter)

CreateTagsDbFilter creates a tags filter for the KnowledgeDB.

The function returns the tags filter.

Tags:

  • @displayName: Tags Filter

Parameters:

  • tags: the tags to be used for the filter
  • needAll: flag to indicate whether all tags are needed

Returns:

  • databaseFilter: the tags filter

func DownloadGithubFileContent

func DownloadGithubFileContent(githubRepoName string, githubRepoOwner string,
    githubRepoBranch string, gihubFilePath string, githubAccessToken string) (checksum string, content []byte)

DownloadGithubFileContent downloads file content from github and returns checksum and content.

Tags:

  • @displayName: Download Github File Content

Parameters:

  • githubRepoName: name of the github repository.
  • githubRepoOwner: owner of the github repository.
  • githubRepoBranch: branch of the github repository.
  • gihubFilePath: path to file in the github repository.
  • githubAccessToken: access token for github.

Returns:

  • checksum: checksum of file.
  • content: content of file.

func GeneralNeo4jQuery

func GeneralNeo4jQuery(query string) (databaseResponse sharedtypes.Neo4jResponse)

GeneralNeo4jQuery executes the given Neo4j query and returns the response.

The function returns the neo4j response.

Tags:

  • @displayName: General Neo4J Query

Parameters:

  • query: the Neo4j query to be executed.

Returns:

  • databaseResponse: the Neo4j response

func GeneralQuery

func GeneralQuery(collectionName string, maxRetrievalCount int, outputFields []string, filters sharedtypes.DbFilters) (databaseResponse []sharedtypes.DbResponse)

GeneralQuery performs a general query in the KnowledgeDB.

The function returns the query results.

Tags:

  • @displayName: Query

Parameters:

  • collectionName: the name of the collection to which the data objects will be added.
  • maxRetrievalCount: the maximum number of results to be retrieved.
  • outputFields: the fields to be included in the output.
  • filters: the filter for the query.

Returns:

  • databaseResponse: the query results

func GenerateDocumentTree

func GenerateDocumentTree(documentName string, documentId string, documentChunks []string,
    embeddingsDimensions int, getSummary bool, getKeywords bool, numKeywords int, chunkSize int, numLlmWorkers int) (returnedDocumentData []sharedtypes.DbData)

GenerateDocumentTree generates a tree structure from the document chunks.

Tags:

  • @displayName: Document Tree

Parameters:

  • documentName: name of the document.
  • documentId: id of the document.
  • documentChunks: chunks of the document.
  • embeddingsDimensions: dimensions of the embeddings.
  • getSummary: whether to get summary.
  • getKeywords: whether to get keywords.
  • numKeywords: number of keywords.
  • chunkSize: size of the chunks.
  • numLlmWorkers: number of llm workers.

Returns:

  • documentData: tree structure of the document.

func GetDocumentType

func GetDocumentType(filePath string) (documentType string)

GetDocumentType returns the document type of a file.

Tags:

  • @displayName: Get Document Type

Parameters:

  • filePath: path to file.

Returns:

  • documentType: file extension.

func GetGithubFilesToExtract

func GetGithubFilesToExtract(githubRepoName string, githubRepoOwner string,
    githubRepoBranch string, githubAccessToken string, githubFileExtensions []string,
    githubFilteredDirectories []string, githubExcludedDirectories []string) (githubFilesToExtract []string)

GetGithubFilesToExtract gets all files from github that need to be extracted.

Tags:

  • @displayName: List Github Files

Parameters:

  • githubRepoName: name of the github repository.
  • githubRepoOwner: owner of the github repository.
  • githubRepoBranch: branch of the github repository.
  • githubAccessToken: access token for github.
  • githubFileExtensions: github file extensions.
  • githubFilteredDirectories: github filtered directories.
  • githubExcludedDirectories: github excluded directories.

Returns:

  • githubFilesToExtract: github files to extract.

func GetListCollections

func GetListCollections() (collectionsList []string)

GetListCollections retrieves the list of collections from the KnowledgeDB.

Tags:

  • @displayName: List Collections

The function returns the list of collections.

Parameters:

  • knowledgeDbEndpoint: the KnowledgeDB endpoint

Returns:

  • collectionsList: the list of collections

func GetLocalFileContent

func GetLocalFileContent(localFilePath string) (checksum string, content []byte)

GetLocalFileContent reads local file and returns checksum and content.

Tags:

  • @displayName: Get Local File Content

Parameters:

  • localFilePath: path to file.

Returns:

  • checksum: checksum of file.
  • content: content of file.

func GetLocalFilesToExtract

func GetLocalFilesToExtract(localPath string, localFileExtensions []string,
    localFilteredDirectories []string, localExcludedDirectories []string) (localFilesToExtract []string)

GetLocalFilesToExtract gets all files from local that need to be extracted.

Tags:

  • @displayName: List Local Files

Parameters:

  • localPath: path to the local directory.
  • localFileExtensions: local file extensions.
  • localFilteredDirectories: local filtered directories.
  • localExcludedDirectories: local excluded directories.

Returns:

  • localFilesToExtract: local files to extract.

func LangchainSplitter

func LangchainSplitter(bytesContent []byte, documentType string, chunkSize int, chunkOverlap int) (output []string)

LangchainSplitter splits content into chunks using langchain.

Tags:

  • @displayName: Split Content

Parameters:

  • content: content to split.
  • documentType: type of document.
  • chunkSize: size of the chunks.
  • chunkOverlap: overlap of the chunks.

Returns:

  • output: chunks as an slice of strings.

func PerformBatchEmbeddingRequest

func PerformBatchEmbeddingRequest(input []string) (embeddedVectors [][]float32)

PerformBatchEmbeddingRequest performs a batch vector embedding request to LLM

Tags:

  • @displayName: Batch Embeddings

Parameters:

  • input: the input strings

Returns:

  • embeddedVectors: the embedded vectors in float32 format

func PerformCodeLLMRequest

func PerformCodeLLMRequest(input string, history []sharedtypes.HistoricMessage, isStream bool, validateCode bool) (message string, stream *chan string)

PerformCodeLLMRequest performs a code generation request to LLM

Tags:

  • @displayName: Code LLM Request

Parameters:

  • input: the input string
  • history: the conversation history
  • isStream: the stream flag

Returns:

  • message: the generated code
  • stream: the stream channel

func PerformGeneralRequest

func PerformGeneralRequest(input string, history []sharedtypes.HistoricMessage, isStream bool, systemPrompt string) (message string, stream *chan string)

PerformGeneralRequest performs a general chat completion request to LLM

Tags:

  • @displayName: General LLM Request

Parameters:

  • input: the input string
  • history: the conversation history
  • isStream: the stream flag
  • systemPrompt: the system prompt

Returns:

  • message: the generated message
  • stream: the stream channel

func PerformGeneralRequestSpecificModel

func PerformGeneralRequestSpecificModel(input string, history []sharedtypes.HistoricMessage, isStream bool, systemPrompt string, modelIds []string) (message string, stream *chan string)

PerformGeneralRequestSpecificModel performs a general request to LLM with a specific model

Tags:

  • @displayName: General LLM Request (Specific Models)

Parameters:

  • input: the user input
  • history: the conversation history
  • isStream: the flag to indicate whether the response should be streamed
  • systemPrompt: the system prompt
  • modelId: the model ID

Returns:

  • message: the response message
  • stream: the stream channel

func PerformKeywordExtractionRequest

func PerformKeywordExtractionRequest(input string, maxKeywordsSearch uint32) (keywords []string)

PerformKeywordExtractionRequest performs a keywords extraction request to LLM

Tags:

  • @displayName: Keyword Extraction

Parameters:

  • input: the input string
  • maxKeywordsSearch: the maximum number of keywords to search for

Returns:

  • keywords: the keywords extracted from the input string as a slice of strings

func PerformSummaryRequest

func PerformSummaryRequest(input string) (summary string)

PerformSummaryRequest performs a summary request to LLM

Tags:

  • @displayName: Summary

Parameters:

  • input: the input string

Returns:

  • summary: the summary extracted from the input string

func PerformVectorEmbeddingRequest

func PerformVectorEmbeddingRequest(input string) (embeddedVector []float32)

PerformVectorEmbeddingRequest performs a vector embedding request to LLM

Tags:

  • @displayName: Embeddings

Parameters:

  • input: the input string

Returns:

  • embeddedVector: the embedded vector in float32 format

func RetrieveDependencies

func RetrieveDependencies(
    collectionName string,
    relationshipName string,
    relationshipDirection string,
    sourceDocumentId string,
    nodeTypesFilter sharedtypes.DbArrayFilter,
    maxHopsNumber int) (dependenciesIds []string)

RetrieveDependencies retrieves the dependencies of the specified source node.

The function returns the list of dependencies.

Tags:

  • @displayName: Retrieve Dependencies

Parameters:

  • collectionName: the name of the collection to which the data objects will be added.
  • relationshipName: the name of the relationship to retrieve dependencies for.
  • relationshipDirection: the direction of the relationship to retrieve dependencies for.
  • sourceDocumentId: the document ID of the source node.
  • nodeTypesFilter: filter based on node types.
  • maxHopsNumber: maximum number of hops to traverse.

Returns:

  • dependenciesIds: the list of dependencies

func SendRestAPICall

func SendRestAPICall(requestType string, endpoint string, header map[string]string, query map[string]string, jsonBody string) (success bool, returnJsonBody string)

SendAPICall sends an API call to the specified URL with the specified headers and query parameters.

Tags:

  • @displayName: REST Call

Parameters:

  • requestType: the type of the request (GET, POST, PUT, PATCH, DELETE)
  • urlString: the URL to send the request to
  • headers: the headers to include in the request
  • query: the query parameters to include in the request
  • jsonBody: the body of the request as a JSON string

Returns:

  • success: a boolean indicating whether the request was successful
  • returnJsonBody: the JSON body of the response as a string

func SendVectorsToKnowledgeDB

func SendVectorsToKnowledgeDB(vector []float32, keywords []string, keywordsSearch bool, collection string, similaritySearchResults int, similaritySearchMinScore float64) (databaseResponse []sharedtypes.DbResponse)

SendVectorsToKnowledgeDB sends the given vector to the KnowledgeDB and returns the most relevant data. The number of results is specified in the config file. The keywords are used to filter the results. The min score filter is also specified in the config file. If it is not specified, the default value is used.

The function returns the most relevant data.

Tags:

  • @displayName: Similarity Search

Parameters:

  • vector: the vector to be sent to the KnowledgeDB
  • keywords: the keywords to be used to filter the results
  • keywordsSearch: the flag to enable the keywords search
  • collection: the collection name
  • similaritySearchResults: the number of results to be returned
  • similaritySearchMinScore: the minimum score for the results

Returns:

  • databaseResponse: an array of the most relevant data

func ShortenMessageHistory

func ShortenMessageHistory(history []sharedtypes.HistoricMessage, maxLength int) (updatedHistory []sharedtypes.HistoricMessage)

ShortenMessageHistory shortens the conversation history to a maximum length. It will retain only the most recent messages and older messages will be removed.

Tags:

  • @displayName: Shorten History

Parameters:

  • history: the conversation history
  • maxLength: the maximum length of the conversation history

Returns:

  • updatedHistory: the updated conversation history

func SimilaritySearch

func SimilaritySearch(
    collectionName string,
    embeddedVector []float32,
    maxRetrievalCount int,
    outputFields []string,
    filters sharedtypes.DbFilters,
    minScore float64,
    getLeafNodes bool,
    getSiblings bool,
    getParent bool,
    getChildren bool) (databaseResponse []sharedtypes.DbResponse)

SimilaritySearch performs a similarity search in the KnowledgeDB.

The function returns the similarity search results.

Tags:

  • @displayName: Similarity Search (Filtered)

Parameters:

  • collectionName: the name of the collection to which the data objects will be added.
  • embeddedVector: the embedded vector used for searching.
  • maxRetrievalCount: the maximum number of results to be retrieved.
  • outputFields: the fields to be included in the output.
  • filters: the filter for the query.
  • minScore: the minimum score filter.
  • getLeafNodes: flag to indicate whether to retrieve all the leaf nodes in the result node branch.
  • getSiblings: flag to indicate whether to retrieve the previous and next node to the result nodes.
  • getParent: flag to indicate whether to retrieve the parent object.
  • getChildren: flag to indicate whether to retrieve the children objects.

Returns:

  • databaseResponse: the similarity search results

func ansysGPTACSSemanticHybridSearch

func ansysGPTACSSemanticHybridSearch(
    query string,
    embeddedQuery []float32,
    indexName string,
    filter map[string]string,
    topK int,
    isAis bool,
    physics []string) (output []sharedtypes.ACSSearchResponse)

ansysGPTACSSemanticHybridSearch performs a semantic hybrid search in ACS

Parameters:

  • query: the query string
  • embeddedQuery: the embedded query
  • indexName: the index name
  • filter: string build in specific format (https://learn.microsoft.com/en-us/azure/search/search-filters)
  • filterAfterVectorSearch: the flag to define the filter order (recommended true)
  • returnedProperties: the properties to be returned
  • topK: the number of results to be returned from vector search
  • searchedEmbeddedFields: the ACS fields to be searched

Returns:

  • output: the search results

func convertToFloat32Slice

func convertToFloat32Slice(interfaceSlice []interface{}) ([]float32, error)

convertToFloat32Slice converts an interface slice to a float32 slice.

Parameters:

  • interfaceSlice: the interface slice.

Returns:

  • float32Slice: the float32 slice.
  • error: an error if any.

func createDbArrayFilter

func createDbArrayFilter(filterData []string, needAll bool) (databaseFilter sharedtypes.DbArrayFilter)

createDbArrayFilter creates an array filter for the KnowledgeDB.

The function returns the array filter.

Parameters:

  • filterData: the filter data
  • needAll: flag to indicate whether all data is needed

Returns:

  • databaseFilter: the array filter

func createDbJsonFilter

func createDbJsonFilter(fieldName string, fieldType string, filterData []string, needAll bool) (databaseFilter sharedtypes.DbJsonFilter)

createDbJsonFilter creates a JSON filter for the KnowledgeDB.

The function returns the JSON filter.

Parameters:

  • fieldName: the name of the field
  • fieldType: the type of the field
  • filterData: the filter data
  • needAll: flag to indicate whether all data is needed

Returns:

  • databaseFilter: the JSON filter

func createPayloadAndSendHttpRequest

func createPayloadAndSendHttpRequest(url string, requestObject interface{}, responsePtr interface{}) (funcError error, statusCode int)

createPayloadAndSendHttpRequest creates a JSON payload and sends an HTTP POST request.

Parameters:

  • url: the URL to send the request to.
  • requestObject: the object to send in the request body.
  • responsePtr: a pointer to the object to store the response in.

Returns:

  • error: the error returned by the function.

func dataExtractNewGithubClient

func dataExtractNewGithubClient(githubAccessToken string) (client *github.Client, ctx context.Context)

dataExtractNewGithubClient initializes a new GitHub client with the given access token.

Parameters:

  • githubAccessToken: the GitHub access token.

Returns:

  • *github.Client: the GitHub client.
  • context.Context: the context.

func dataExtractionDocumentLevelHandler

func dataExtractionDocumentLevelHandler(inputChannel chan *DataExtractionLLMInputChannelItem, errorChannel chan error, chunks []string, documentId string, documentPath string, getSummary bool,
    getKeywords bool, numKeywords uint32) (orderedChildDataObjects []*sharedtypes.DbData, err error)

dataExtractionDocumentLevelHandler handles the data extraction at document level.

Parameters:

  • inputChannel: the input channel.
  • chunks: the document chunks.
  • documentId: the document ID.
  • documentPath: the document path.
  • getSummary: the flag to indicate whether to get the summary.
  • getKeywords: the flag to indicate whether to get the keywords.
  • numKeywords: the number of keywords.

Returns:

  • orderedChildDataObjects: the ordered child data objects.

func dataExtractionFilterGithubTreeEntries

func dataExtractionFilterGithubTreeEntries(tree *github.Tree, githubFilteredDirectories, githubExcludedDirectories, githubFileExtensions []string) (githubFilesToExtract []string)

dataExtractionFilterGithubTreeEntries filters the Github tree entries based on the specified filters.

Parameters:

  • tree: the Github tree.
  • githubFilteredDirectories: the Github filtered directories.
  • githubExcludedDirectories: the Github excluded directories.
  • githubFileExtensions: the Github file extensions.

Returns:

  • []string: the files to extract.

func dataExtractionLLMHandlerWorker

func dataExtractionLLMHandlerWorker(waitgroup *sync.WaitGroup, inputChannel chan *DataExtractionLLMInputChannelItem, errorChannel chan error, embeddingsDimensions int)

dataExtractionLLMHandlerWorker is a worker function for the LLM Handler requests during data extraction.

Parameters:

  • waitgroup: the wait group
  • inputChannel: the input channel
  • errorChannel: the error channel
  • embeddingsDimensions: the embeddings dimensions

Returns:

  • error: an error if any

func dataExtractionLocalFilepathExtractWalker

func dataExtractionLocalFilepathExtractWalker(localPath string, localFileExtensions []string,
    localFilteredDirectories []string, localExcludedDirectories []string, filesToExtract *[]string, f os.FileInfo, err error) error

dataExtractionLocalFilepathExtractWalker is the walker function for the local file extraction.

Parameters:

  • localPath: the local path.
  • localFileExtensions: the local file extensions.
  • localFilteredDirectories: the local filtered directories.
  • localExcludedDirectories: the local excluded directories.
  • filesToExtract: the files to extract.
  • f: the file info

Returns:

  • error: error that occured during execution.

func dataExtractionPerformSplitterRequest

func dataExtractionPerformSplitterRequest(content []byte, documentType string, chunkSize int, chunkOverlap int) (output []string, err error)

dataExtractionPerformSplitterRequest performs a data extraction splitter request to the Python service.

Parameters:

  • content: the content.
  • documentType: the document type.
  • chunkSize: the chunk size.
  • chunkOverlap: the chunk overlap.

Returns:

  • output: the output.
  • error: an error if any.

func dataExtractionProcessBatchEmbeddings

func dataExtractionProcessBatchEmbeddings(documentData []*sharedtypes.DbData, maxBatchSize int) error

dataExtractionProcessBatchEmbeddings processes the data extraction batch embeddings.

Parameters:

  • documentData: the document data.
  • maxBatchSize: the max batch size.

Returns:

  • error: an error if any

func extractAndConvertACSResponse

func extractAndConvertACSResponse(body []byte, indexName string) (output []sharedtypes.ACSSearchResponse)

extractAndConvertACSResponse extracts and converts the ACS response to ACSSearchResponse

Parameters:

  • body: the response body
  • indexName: the index name

Returns:

  • output: the search results

func extractPythonCode

func extractPythonCode(markdown string) (pythonCode string, error error)

extractPythonCode extracts the Python code from a markdown string. If the string does not contain a code block, it is assumed that the string is Python code and is returned as is.

Parameters:

  • markdown: the markdown string

Returns:

  • string: the Python code
  • error: error if any

func formatTemplate

func formatTemplate(template string, data map[string]string) string

formatTemplate formats a template string with the given data

Parameters:

  • template: the template string
  • data: the data to be used for formatting

Returns:

  • string: the formatted template string

func getFieldsAndReturnProperties

func getFieldsAndReturnProperties(indexName string) (searchedEmbeddedFields string, returnedProperties string)

getFieldsAndReturnProperties returns the searchedEmbeddedFields and returnedProperties based on the index name

Parameters:

  • indexName: the index name

Returns:

  • searchedEmbeddedFields: the ACS fields to be searched
  • returnedProperties: the properties to be returned

func httpRequest

func httpRequest(method string, url string, headers map[string]string, body []byte) ([]byte, error)

httpRequest is a general function for making HTTP requests.

Parameters:

  • method: HTTP method.
  • url: URL to make the request to.
  • headers: headers to include in the request.
  • body: body of the request.

Returns:

  • response body.
  • error.

func initializeClient

func initializeClient(llmHandlerEndpoint string) *websocket.Conn

initializeClient initializes the LLM Handler client

Returns:

  • *websocket.Conn: the websocket connection

func listener

func listener(c *websocket.Conn, responseChannel chan sharedtypes.HandlerResponse)

listener listens for messages from the LLM Handler

Parameters:

  • c: the websocket connection
  • responseChannel: the response channel

func llmHandlerPerformKeywordExtractionRequest

func llmHandlerPerformKeywordExtractionRequest(input string, numKeywords uint32) (keywords []string, err error)

llmHandlerPerformKeywordExtractionRequest performs a keyword extraction request to LLM Handler.

Parameters:

  • input: the input string.
  • numKeywords: the number of keywords.

Returns:

  • keywords: the keywords.
  • error: an error if any.

func llmHandlerPerformSummaryRequest

func llmHandlerPerformSummaryRequest(input string) (summary string, err error)

llmHandlerPerformSummaryRequest performs a summary request to LLM Handler.

Parameters:

  • input: the input string.

Returns:

  • summary: the summary.
  • error: an error if any.

func llmHandlerPerformVectorEmbeddingRequest

func llmHandlerPerformVectorEmbeddingRequest(input []string) (embeddedVectors [][]float32, err error)

llmHandlerPerformVectorEmbeddingRequest performs a vector embedding request to LLM Handler.

Parameters:

  • input: slice of input strings.

Returns:

  • embeddedVector: the embedded vectors.
  • error: an error if any.

func performGeneralRequest

func performGeneralRequest(input string, history []sharedtypes.HistoricMessage, isStream bool, systemPrompt string, options *sharedtypes.ModelOptions) (message string, stream *chan string, err error)

performGeneralRequest performs a general chat completion request to LLM.

Parameters:

  • input: the input string.
  • history: the conversation history.
  • isStream: the stream flag.
  • systemPrompt: the system prompt.

Returns:

  • message: the generated message.
  • stream: the stream channel.
  • err: the error.

func randomNameGenerator

func randomNameGenerator() string

randomNameGenerator generates a random name for the temporary Python script file

Returns:

  • string: the name of the temporary Python script file

func sendChatRequest

func sendChatRequest(data string, chatRequestType string, history []sharedtypes.HistoricMessage, maxKeywordsSearch uint32, systemPrompt string, llmHandlerEndpoint string, modelIds []string, options *sharedtypes.ModelOptions) chan sharedtypes.HandlerResponse

sendChatRequest sends a chat request to LLM

Parameters:

  • data: the input string
  • chatRequestType: the chat request type
  • history: the conversation history
  • sc: the session context

Returns:

  • chan sharedtypes.HandlerResponse: the response channel

func sendChatRequestNoHistory

func sendChatRequestNoHistory(data string, chatRequestType string, maxKeywordsSearch uint32, llmHandlerEndpoint string, modelIds []string, options *sharedtypes.ModelOptions) chan sharedtypes.HandlerResponse

sendChatRequestNoHistory sends a chat request to LLM without history

Parameters:

  • data: the input string
  • chatRequestType: the chat request type
  • sc: the session context

Returns:

  • chan sharedtypes.HandlerResponse: the response channel

func sendEmbeddingsRequest

func sendEmbeddingsRequest(data interface{}, llmHandlerEndpoint string, modelIds []string) chan sharedtypes.HandlerResponse

sendEmbeddingsRequest sends an embeddings request to LLM

Parameters:

  • data: the input string
  • sc: the session context

Returns:

  • chan sharedtypes.HandlerResponse: the response channel

func sendRequest

func sendRequest(adapter string, data interface{}, RequestChannel chan []byte, chatRequestType string, dataStream string, history []sharedtypes.HistoricMessage, maxKeywordsSearch uint32, systemPrompt string, responseChannel chan sharedtypes.HandlerResponse, modelIds []string, options *sharedtypes.ModelOptions)

sendRequest sends a request to LLM

Parameters:

  • adapter: the adapter type. Types: "chat", "embeddings"
  • data: the input string
  • RequestChannel: the request channel
  • chatRequestType: the chat request type. Types: "summary", "code", "keywords"
  • dataStream: the data stream flag
  • history: the conversation history
  • sc: the session context

func shutdownHandler

func shutdownHandler(c *websocket.Conn)

shutdownHandler handles the shutdown of the LLM Handler

Parameters:

  • c: the websocket connection
  • RequestChannel: the request channel

func transferDatafromResponseToStreamChannel

func transferDatafromResponseToStreamChannel(responseChannel *chan sharedtypes.HandlerResponse, streamChannel *chan string, validateCode bool)

transferDatafromResponseToStreamChannel transfers the data from the response channel to the stream channel

Parameters:

  • responseChannel: the response channel
  • streamChannel: the stream channel
  • validateCode: the flag to indicate whether the code should be validated

func validatePythonCode

func validatePythonCode(pythonCode string) (bool, bool, error)

validatePythonCode validates the Python code using a Python code analysis tool (pyright) and returns several values to indicate the validity of the Python code.

Parameters:

  • pythonCode: the Python code to be validated

Returns:

  • bool: true if the Python code is valid, false otherwise
  • bool: true if the Python code has potential errors, false otherwise
  • error: an error message if the Python code is invalid

func writer

func writer(c *websocket.Conn, RequestChannel chan []byte, responseChannel chan sharedtypes.HandlerResponse)

writer writes messages to the LLM Handler

Parameters:

  • c: the websocket connection
  • RequestChannel: the request channel

type ACSSearchRequest

ACSRequest represents the request structure for the Azure Cognitive Search.

type ACSSearchRequest struct {
    Search                string           `json:"search"`
    VectorQueries         []ACSVectorQuery `json:"vectorQueries"`
    VectorFilterMode      string           `json:"vectorFilterMode"`
    Filter                string           `json:"filter"`
    QueryType             string           `json:"queryType"`
    SemanticConfiguration string           `json:"semanticConfiguration"`
    Top                   int              `json:"top"`
    Select                string           `json:"select"`
    Count                 bool             `json:"count"`
}

type ACSSearchResponseALH

ACSSearchResponse represents the response structure for the Azure Cognitive Search for ansysgpt-alh & ansysgpt-scbu.

type ACSSearchResponseALH struct {
    SourcetitleSAP      string  `json:"sourcetitleSAP"`
    SourceURLSAP        string  `json:"sourceURLSAP"`
    SourcetitleDCB      string  `json:"sourcetitleDCB"`
    SourceURLDCB        string  `json:"sourceURLDCB"`
    Content             string  `json:"content"`
    TypeOFasset         string  `json:"typeOFasset"`
    Physics             string  `json:"physics"`
    Product             string  `json:"product"`
    Version             string  `json:"version"`
    Weight              float64 `json:"weight"`
    TokenSize           int     `json:"token_size"`
    SearchScore         float64 `json:"@search.score"`
    SearchRerankerScore float64 `json:"@search.rerankerScore"`
    IndexName           string  `json:"indexName"`
}

type ACSSearchResponseCrtech

ACSSearchResponseCrtech represents the response structure for the Azure Cognitive Search for external-crtech-thermal-desktop.

type ACSSearchResponseCrtech struct {
    Physics             string  `json:"physics"`
    SourceTitleLvl3     string  `json:"sourceTitle_lvl3"`
    SourceURLLvl3       string  `json:"sourceURL_lvl3"`
    TokenSize           int     `json:"token_size"`
    SourceTitleLvl2     string  `json:"sourceTitle_lvl2"`
    Weight              float64 `json:"weight"`
    SourceURLLvl2       string  `json:"sourceURL_lvl2"`
    Product             string  `json:"product"`
    Content             string  `json:"content"`
    TypeOFasset         string  `json:"typeOFasset"`
    Version             string  `json:"version"`
    BridgeId            string  `json:"bridge_id"`
    SearchScore         float64 `json:"@search.score"`
    SearchRerankerScore float64 `json:"@search.rerankerScore"`
    IndexName           string  `json:"indexName"`
}

type ACSSearchResponseLSdyna

ACSSearchResponse represents the response structure for the Azure Cognitive Search for lsdyna-documentation-r14.

type ACSSearchResponseLSdyna struct {
    Title               string  `json:"title"`
    Url                 string  `json:"url"`
    Content             string  `json:"content"`
    TypeOFasset         string  `json:"typeOFasset"`
    Physics             string  `json:"physics"`
    Product             string  `json:"product"`
    TokenSize           int     `json:"token_size"`
    SearchScore         float64 `json:"@search.score"`
    SearchRerankerScore float64 `json:"@search.rerankerScore"`
    IndexName           string  `json:"indexName"`
}

type ACSSearchResponseStruct

ACSSearchResponseStruct represents the response structure for the Azure Cognitive Search for granular-ansysgpt, ansysgpt-documentation-2023r2, scade-documentation-2023r2, ansys-dot-com-marketing.

type ACSSearchResponseStruct struct {
    OdataContext string                          `json:"@odata.context"`
    OdataCount   int                             `json:"@odata.count"`
    Value        []sharedtypes.ACSSearchResponse `json:"value"`
}

type ACSSearchResponseStructALH

ACSSearchResponseStruct represents the response structure for the Azure Cognitive Search for ansysgpt-alh & ansysgpt-scbu.

type ACSSearchResponseStructALH struct {
    OdataContext string                 `json:"@odata.context"`
    OdataCount   int                    `json:"@odata.count"`
    Value        []ACSSearchResponseALH `json:"value"`
}

type ACSSearchResponseStructCrtech

ACSSearchResponseStructCrtech represents the response structure for the Azure Cognitive Search for external-crtech-thermal-desktop.

type ACSSearchResponseStructCrtech struct {
    OdataContext string                    `json:"@odata.context"`
    OdataCount   int                       `json:"@odata.count"`
    Value        []ACSSearchResponseCrtech `json:"value"`
}

type ACSSearchResponseStructLSdyna

ACSSearchResponseStruct represents the response structure for the Azure Cognitive Search for lsdyna-documentation-r14.

type ACSSearchResponseStructLSdyna struct {
    OdataContext string                    `json:"@odata.context"`
    OdataCount   int                       `json:"@odata.count"`
    Value        []ACSSearchResponseLSdyna `json:"value"`
}

type ACSVectorQuery

ACSVectorQuery represents the vector query structure for the Azure Cognitive Search.

type ACSVectorQuery struct {
    Kind   string    `json:"kind"`
    K      int       `json:"k"`
    Vector []float32 `json:"vector"`
    Fields string    `json:"fields"`
}

type AppendMessageHistoryRole

type AppendMessageHistoryRole string
const (
    user      AppendMessageHistoryRole = "user"
    assistant AppendMessageHistoryRole = "assistant"
    system    AppendMessageHistoryRole = "system"
)

type DataExtractionBranch

DataExtractionBranch represents the branch structure for the data extraction.

type DataExtractionBranch struct {
    Text             string
    ChildDataObjects []*sharedtypes.DbData
    ChildDataIds     []string
}

type DataExtractionLLMInputChannelItem

DataExtractionLLMInputChannelItem represents the input channel item for the data extraction llm handler workers.

type DataExtractionLLMInputChannelItem struct {
    Data                *sharedtypes.DbData
    Adapter             string
    ChatRequestType     string
    MaxNumberOfKeywords uint32

    InstructionSequenceWaitGroup *sync.WaitGroup
    Lock                         *sync.Mutex

    EmbeddingVector []float32
    Summary         string
    Keywords        []string
    CollectionName  string
}

func dataExtractionNewLlmInputChannelItem

func dataExtractionNewLlmInputChannelItem(data *sharedtypes.DbData, instructionSequenceWaitGroup *sync.WaitGroup, adapter string, chatRequestType string, maxNumberOfKeywords uint32, lock *sync.Mutex) *DataExtractionLLMInputChannelItem

dataExtractionNewLlmInputChannelItem creates a new llm input channel item.

Parameters:

  • data: data.
  • instructionSequenceWaitGroup: instruction sequence wait group.
  • adapter: adapter.
  • chatRequestType: chat request type.
  • maxNumberOfKeywords: max number of keywords.
  • lock: lock.

Returns:

  • llmInputChannelItem: llm input channel item.

type DataExtractionSplitterServiceRequest

type DataExtractionSplitterServiceRequest struct {
    DocumentContent []byte `json:"document_content"`
    ChunkSize       int    `json:"chunk_size"`
    ChunkOverlap    int    `json:"chunk_overlap"`
}

type DataExtractionSplitterServiceResponse

type DataExtractionSplitterServiceResponse struct {
    Chunks []string `json:"chunks"`
}

type queryInput

queryInput represents the input for the query function.

type queryInput struct {
    CollectionName    string                `json:"collection_name" description:"Name of the collection to which the data objects will be added. Required for adding data." required:"true"`
    MaxRetrievalCount int                   `json:"max_retrieval_count" description:"Maximum number of results to be retrieved. If not specified, the default value is retrieve all database. If the number of results is too big for the database, the request will be cancelled. Optional." required:"false"`
    OutputFields      []string              `json:"output_fields" description:"Fields to be included in the output. If not specified all fields will be retrieved.Optional" required:"false"`
    Filters           sharedtypes.DbFilters `json:"filters" description:"Filter for the query. At least one filter must be defined." required:"true"`
}

type queryOutput

queryOutput represents the output for the query function.

type queryOutput struct {
    QueryResult []sharedtypes.DbResponse `json:"queryResult" description:"Returns the results of the query."`
}

type retrieveDependenciesInput

retrieveDependenciesInput represents the input for the retrieveDependencies function.

type retrieveDependenciesInput struct {
    CollectionName        string                    `json:"collection_name" description:"Name of the collection to which the data objects will be added. Required for adding data." required:"true"`
    RelationshipName      string                    `json:"relationship_name" description:"Name of the relationship to retrieve dependencies for. Required for retrieving dependencies." required:"true"`
    RelationshipDirection string                    `json:"relationship_direction" description:"Direction of the relationship to retrieve dependencies for. It can be either 'in', 'out' or 'both'. Required for retrieving dependencies." required:"true"`
    SourceDocumentId      string                    `json:"source_document_id" description:"Document ID of the source node. Required for retrieving dependencies." required:"true"`
    NodeTypesFilter       sharedtypes.DbArrayFilter `json:"node_types_filter" description:"Filter based on node types. Use MilvusArrayFilter for specifying node type filtering criteria. Optional." required:"false"`
    DocumentTypesFilter   []string                  `json:"document_types_filter" description:"Filter based on document types. Use MilvusArrayFilter for specifying document type filtering criteria. Optional." required:"false"`
    MaxHopsNumber         int                       `json:"max_hops_number" description:"Maximum number of hops to traverse. Optional." required:"true"`
}

type retrieveDependenciesOutput

retrieveDependenciesOutput represents the output for the retrieveDependencies function.

type retrieveDependenciesOutput struct {
    Success         bool     `json:"success" description:"Returns true if the collections were listed successfully. Returns false or an error if not."`
    DependenciesIds []string `json:"dependencies_ids" description:"A list of document IDs that are dependencies of the specified source node."`
}

type similarityElement

similarityElement represents a single element in the similarity search result.

type similarityElement struct {
    Score float64                `json:"distance"`
    Data  sharedtypes.DbResponse `json:"data"`
}

type similaritySearchInput

similaritySearchInput represents the input for the similarity search function.

type similaritySearchInput struct {
    CollectionName    string                `json:"collection_name" description:"Name of the collection to which the data objects will be added. Required for adding data." required:"true"`
    EmbeddedVector    []float32             `json:"embedded_vector" description:"Embedded vector used for searching. Required for retrieval." required:"true"`
    MaxRetrievalCount int                   `json:"max_retrieval_count" description:"Maximum number of results to be retrieved. If it is not specified, the default value is milvus.MaxSearchRetrievalCount. Optional." required:"false"`
    OutputFields      []string              `json:"output_fields" description:"Fields to be included in the output. If not specified all fields will be retrieved.Optional" required:"false"`
    Filters           sharedtypes.DbFilters `json:"filters" description:"Filter for the query. Optional." required:"false"`
    MinScore          float64               `json:"min_score" description:"Filter objects with a score higher than the specified minimum. Optional." required:"false"`
    GetLeafNodes      bool                  `json:"get_leaf_nodes" description:"Flag to indicate whether to retrieve all the leaf nodes in the result node branch. Set to true to include the leaf nodes. Optional." required:"false"`
    GetSiblings       bool                  `json:"get_siblings" description:"Flag to indicate whether to retrieve the previous and next node to the result nodes. Set to true to include the siblings. Optional." required:"false"`
    GetParent         bool                  `json:"get_parent" description:"Flag to indicate whether to retrieve the parent object. Set to true to include the parent object. Optional." required:"false"`
    GetChildren       bool                  `json:"get_children" description:"Flag to indicate whether to retrieve the children objects. Set to true to include the children objects. Optional." required:"false"`
}

type similaritySearchOutput

similaritySearchOutput represents the output for the similarity search function.

type similaritySearchOutput struct {
    SimilarityResult []similarityElement `json:"similarity_result" description:"Similarity Result"`
}

type summaryCounters

summaryCounters represents the summary counters structure for the Neo4j query.

type summaryCounters struct {
    NodesCreated         int `json:"nodes_created"`
    NodesDeleted         int `json:"nodes_deleted"`
    RelationshipsCreated int `json:"relationships_created"`
    RelationshipsDeleted int `json:"relationships_deleted"`
    PropertiesSet        int `json:"properties_set"`
    LabelsAdded          int `json:"labels_added"`
    LabelsRemoved        int `json:"labels_removed"`
    IndexesAdded         int `json:"indexes_added"`
    IndexesRemoved       int `json:"indexes_removed"`
    ConstraintsAdded     int `json:"constraints_added"`
    ConstraintsRemoved   int `json:"constraints_removed"`
}