Skip to content

Commit

Permalink
add index to ansysgpt (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKuhnAnsys authored Sep 12, 2024
1 parent bf095e3 commit 93dca50
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/externalfunctions/ansysgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,14 @@ func AnsysGPTReturnIndexList(indexGroups []string) (indexList []string) {
indexList = append(indexList, "ansysgpt-documentation-2023r2")
indexList = append(indexList, "scade-documentation-2023r2")
indexList = append(indexList, "ansys-dot-com-marketing")
indexList = append(indexList, "external-crtech-thermal-desktop")
// indexList = append(indexList, "ibp-app-brief")
// indexList = append(indexList, "pyansys_help_documentation")
// indexList = append(indexList, "pyansys-examples")
case "Ansys Semiconductor":
// indexList = append(indexList, "ansysgpt-scbu")
indexList = append(indexList, "ansysgpt-scbu")
default:
logging.Log.Warnf(internalstates.Ctx, "Invalid indexGroup: %v\n", indexGroup)
logging.Log.Errorf(internalstates.Ctx, "Invalid indexGroup: %v\n", indexGroup)
return
}
}
Expand Down
34 changes: 33 additions & 1 deletion pkg/externalfunctions/privatefunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ func getFieldsAndReturnProperties(indexName string) (searchedEmbeddedFields stri
case "lsdyna-documentation-r14":
searchedEmbeddedFields = "contentVector, titleVector"
returnedProperties = "title, url, token_size, physics, typeOFasset, content, product"
case "external-crtech-thermal-desktop":
searchedEmbeddedFields = "contentVector, sourceTitle_lvl1_vctr, sourceTitle_lvl2_vctr, sourceTitle_lvl3_vctr"
returnedProperties = "token_size, physics, typeOFasset, product, version, weight, bridge_id, content, sourceTitle_lvl2, sourceURL_lvl2, sourceTitle_lvl3, sourceURL_lvl3"
default:
errMessage := fmt.Sprintf("Index name not found: %s", indexName)
logging.Log.Error(internalstates.Ctx, errMessage)
Expand Down Expand Up @@ -716,6 +719,7 @@ func extractAndConvertACSResponse(body []byte, indexName string) (output []share
logging.Log.Error(internalstates.Ctx, errMessage)
panic(errMessage)
}
output = respObject.Value

case "ansysgpt-alh", "ansysgpt-scbu":
respObjectAlh := ACSSearchResponseStructALH{}
Expand Down Expand Up @@ -767,13 +771,41 @@ func extractAndConvertACSResponse(body []byte, indexName string) (output []share
})
}

case "external-crtech-thermal-desktop":
respObjectCrtech := ACSSearchResponseStructCrtech{}
err := json.Unmarshal(body, &respObjectCrtech)
if err != nil {
errMessage := fmt.Sprintf("failed to unmarshal response body from ACS to ACSSearchResponseStructCrtech: %v", err)
logging.Log.Error(internalstates.Ctx, errMessage)
panic(errMessage)
}

for _, item := range respObjectCrtech.Value {
fmt.Println("hashdsahdsha")
output = append(output, sharedtypes.ACSSearchResponse{
SourceTitleLvl2: item.SourceTitleLvl2,
SourceURLLvl2: item.SourceURLLvl2,
SourceTitleLvl3: item.SourceTitleLvl3,
SourceURLLvl3: item.SourceURLLvl3,
Content: item.Content,
TypeOFasset: item.TypeOFasset,
Physics: item.Physics,
Product: item.Product,
Version: item.Version,
Weight: item.Weight,
TokenSize: item.TokenSize,
SearchScore: item.SearchScore,
SearchRerankerScore: item.SearchRerankerScore,
})
}

default:
errMessage := fmt.Sprintf("Index name not found: %s", indexName)
logging.Log.Error(internalstates.Ctx, errMessage)
panic(errMessage)
}

return respObject.Value
return output
}

// dataExtractionFilterGithubTreeEntries filters the Github tree entries based on the specified filters.
Expand Down
25 changes: 25 additions & 0 deletions pkg/externalfunctions/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,31 @@ type ACSSearchResponseLSdyna struct {
SearchRerankerScore float64 `json:"@search.rerankerScore"`
}

// 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"`
}

// 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"`
}

// DataExtractionBranch represents the branch structure for the data extraction.
type DataExtractionBranch struct {
Text string
Expand Down
2 changes: 1 addition & 1 deletion pkg/functiontesting/functiontesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAnsysGPTACSSearchIndex(indexName string, query string) {
filedValues := map[string][]string{
"physics": {"structures", "fluids", "electronics", "structural mechanics", "discovery", "optics", "photonics", "python", "scade", "materials", "stem", "student", "fluid dynamics", "semiconductors"},
"type_of_asset": {"aic", "km", "documentation", "youtube", "general_faq", "alh", "article", "white-paper", "brochure"},
"product": {"forte", "scade", "mechanical", "mechanical apdl", "fluent", "embedded software", "avxcelerate", "designxplorer", "designmodeler", "cloud direct", "maxwell", "stk", "ls-dyna", "lsdyna", "gateway", "granta", "rocky", "icepak", "siwave", "cfx", "meshing", " lumerical", "motion", "autodyn", "minerva", "redhawk-sc", "totem", "totem-sc", "powerartist", "raptorx", "velocerf", "exalto", "pathfinder", "pathfinder-sc", "diakopto", "pragonx", "primex", "on-chip electromagnetics", "redhawk-sc electrothermal", "redhawk-sc security", "voltage-timing and clock jitter", "medini", "ensight", "forte", "discovery", "hfss", "sherlock", "spaceclaim", "twin builder", "additive prep", "additive print", "composite cure sim", "composite preppost", "ncode designlife", "spaceclaim directmodeler", "cfx pre", "cfx solver", "cfx turbogrid", "icem cfd", "workbench platform"},
"product": {"additive prep", "additive print", "autodyn", "avxcelerate", "cfx", "cfx pre", "cfx solver", "cfx turbogrid", "clock jitter flow", "cloud direct", "composite cure sim", "composite preppost", "designmodeler", "designxplorer", "diakopto", "discovery", "embedded software", "ensight", "exalto", "fluent", "forte", "gateway", "granta", "hfss", "icem cfd", "icepak", "ls-dyna", "lsdyna", "lumerical", "maxwell", "mechanical", "mechanical apdl", "medini", "meshing", "minerva", "motion", "ncode designlife", "pathfinder", "pathfinder-sc", "powerartist", "pragonx", "primex", "raptorh", "raptorx", "redhawk-sc", "redhawk-sc electrothermal", "redhawk-sc security", "rocky", "scade", "sherlock", "siwave", "spaceclaim", "spaceclaim directmodeler", "stk", "totem", "totem-sc", "twin builder", "velocerf", "voltage-timing", "workbench platform"},
}

// indexNames := []string{"granular-ansysgpt", "ansysgpt-documentation-2023r2", "scade-documentation-2023r2", "ansys-dot-com-marketing", "ibp-app-brief", "ansysgpt-alh", "ansysgpt-scbu", "lsdyna-documentation-r14"}
Expand Down

0 comments on commit 93dca50

Please sign in to comment.