Skip to content

Commit

Permalink
add panic catch to ACS request ansys gpt (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKuhnAnsys authored Jan 8, 2025
1 parent 20941a4 commit 3bdb399
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/externalfunctions/ansysgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,12 @@ func AisAcsSemanticHybridSearchs(
// Launch a goroutine for each index
for _, indexName := range indexList {
go func(idx string) {
defer func() {
r := recover()
if r != nil {
logging.Log.Errorf(&logging.ContextMap{}, "panic in paralell processing of ACS requests: %v", r)
}
}()
defer wg.Done()
// Run the search for this index
result, err := ansysGPTACSSemanticHybridSearch(acsEndpoint, acsApiKey, acsApiVersion, query, embeddedQuery, idx, nil, topK, true, physics)
Expand All @@ -665,6 +671,12 @@ func AisAcsSemanticHybridSearchs(

// Launch a goroutine to close the channel once all searches are complete
go func() {
defer func() {
r := recover()
if r != nil {
logging.Log.Errorf(&logging.ContextMap{}, "panic in closing ACS result channel: %v", r)
}
}()
wg.Wait()
close(resultChan)
}()
Expand Down
6 changes: 6 additions & 0 deletions pkg/externalfunctions/privatefunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,12 @@ func ansysGPTACSSemanticHybridSearch(
topK int,
isAis bool,
physics []string) (output []sharedtypes.ACSSearchResponse, err error) {
defer func() {
r := recover()
if r != nil {
err = fmt.Errorf("panic occured in ansysGPTACSSemanticHybridSearch: %v", r)
}
}()

// Create the URL
url := fmt.Sprintf("https://%s.search.windows.net/indexes/%s/docs/search?api-version=%s", acsEndpoint, indexName, acsApiVersion)
Expand Down

0 comments on commit 3bdb399

Please sign in to comment.