From 27f633ce2542284fecf624ca7d31f0d0977d15db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20S=C3=A1nchez-Gallego=20Kadri?= <126669056+laurasgkadri98@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:27:29 +0200 Subject: [PATCH] fix: field values (#84) --- pkg/externalfunctions/ansysgpt.go | 14 ++-- .../externalfunctions_test.go | 68 ++++++++++--------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/pkg/externalfunctions/ansysgpt.go b/pkg/externalfunctions/ansysgpt.go index a342e24..8eb9bf1 100644 --- a/pkg/externalfunctions/ansysgpt.go +++ b/pkg/externalfunctions/ansysgpt.go @@ -128,15 +128,13 @@ func AnsysGPTExtractFieldsFromQuery(query string, fieldValues map[string][]strin // If no exact match found, use fuzzy matching if fields[field] == "" { - cutoff := 0.75 + cutoff := 0.76 for _, fieldValue := range values { - for _, fieldWord := range strings.Fields(fieldValue) { - for _, queryWord := range words { - distance := levenshtein.RatioForStrings([]rune(fieldWord), []rune(queryWord), levenshtein.DefaultOptions) - if distance >= cutoff { - fields[field] = fieldValue - break - } + for _, queryWord := range words { + distance := levenshtein.RatioForStrings([]rune(fieldValue), []rune(queryWord), levenshtein.DefaultOptions) + if distance >= cutoff { + fields[field] = fieldValue + break } } } diff --git a/pkg/externalfunctions/externalfunctions_test.go b/pkg/externalfunctions/externalfunctions_test.go index 96e70a6..0e5f06f 100644 --- a/pkg/externalfunctions/externalfunctions_test.go +++ b/pkg/externalfunctions/externalfunctions_test.go @@ -39,69 +39,73 @@ func TestExtractFieldsFromQuery(t *testing.T) { query: "The contact tool in which branch of the model tree informs the user whether the contact pair is initially open? Please choose from the following options: Geometry, Connections, Model, or Solution.", want: map[string]string{}, }, - { - query: "Which of the following controls/options are available under Analysis Setting in WB LS-DYNA documentation?", - want: map[string]string{"product": "ls-dyna", "type_of_asset": "documentation"}, - }, { query: "How does bonded contact differ from Shared Topology?", - want: map[string]string{}, + want: map[string]string{"product": "", "type_of_asset": "", "physics": ""}, }, { query: "I'm interested in understanding how the residual vectors help in MSUP Harmonic Analysis. Can you list the KM on this topic?", - want: map[string]string{"type_of_asset": "km"}, + want: map[string]string{"type_of_asset": "km", "physics": "", "product": ""}, }, { - query: "In the Mechanical Fatigue tool according to product documentaton, which option is used to specify the stress type for fatigue calculations ? Please choose the best option from the following: Equivalent Stress, Exposure Duration, Fatigue Strength Factor, or Stress Component.", - want: map[string]string{"product": "mechanical", "type_of_asset": "documentation"}, + query: "Is there any KMs on how to model turbulent fluid flow in Ansys Fluent?", + want: map[string]string{"product": "fluent", "physics": "fluids", "type_of_asset": "km"}, }, { - query: "Is there any courses available on Ansys Getting started with Mechanical?", - want: map[string]string{"product": "mechanical", "type_of_asset": "aic"}, + query: "Please provide information on materials used in semiconductors.", + want: map[string]string{"physics": "semiconductors", "type_of_asset": "", "product": ""}, }, { - query: "Is there any knowledge articles on how to define frictional contact in Ansys Mechanical?", - want: map[string]string{"product": "mechanical", "type_of_asset": "article"}, + query: "I need some documentation on the CFX solver.", + want: map[string]string{"product": "cfx solver", "type_of_asset": "documentation", "physics": ""}, }, { - query: "Is there any KMs on how to model turbulent fluid flow in Ansys Fluent?", - want: map[string]string{"product": "fluent", "physics": "fluids", "type_of_asset": "km"}, + query: "Are there any new articles on fluid dynamics?", + want: map[string]string{"physics": "fluid dynamics", "type_of_asset": "article", "product": ""}, }, { - query: "Please provide information on materials used in semiconductors.", - want: map[string]string{"physics": "semiconductors"}, + query: "Where can I find the general FAQ for DesignXplorer?", + want: map[string]string{"product": "designxplorer", "type_of_asset": "general_faq", "physics": ""}, }, { - query: "What are the new features in the latest SCADE release?", - want: map[string]string{"product": "scade"}, + query: "Any new documentation on the Additive Print tool?", + want: map[string]string{"product": "additive print", "type_of_asset": "documentation", "physics": ""}, }, { - query: "I need some documentation on the CFX solver.", - want: map[string]string{"product": "cfx solver", "type_of_asset": "documentation"}, + query: "Looking for a brochure on SpaceClaim.", + want: map[string]string{"product": "spaceclaim", "type_of_asset": "brochure", "physics": ""}, }, { - query: "Are there any new articles on fluid dynamics?", - want: map[string]string{"physics": "fluid dynamics", "type_of_asset": "article"}, + query: "Which of the following controls/options are available under Analysis Setting in WB LS-DYNA documentation?", + want: map[string]string{"product": "ls-dyna", "type_of_asset": "documentation", "physics": ""}, }, { - query: "Tell me more about the Mechanical APDL course.", - want: map[string]string{"product": "mechanical apdl", "type_of_asset": "aic"}, + query: "In the Mechanical Fatigue tool according to product documentaton, which option is used to specify the stress type for fatigue calculations ? Please choose the best option from the following: Equivalent Stress, Exposure Duration, Fatigue Strength Factor, or Stress Component.", + want: map[string]string{"product": "mechanical", "type_of_asset": "documentation", "physics": ""}, }, { - query: "Is there any training available for Discovery?", - want: map[string]string{"product": "discovery"}, + query: "Is there any courses available on Ansys Getting started with Mechanical?", + want: map[string]string{"product": "mechanical", "type_of_asset": "aic", "physics": ""}, }, { - query: "Where can I find the general FAQ for DesignXplorer?", - want: map[string]string{"product": "designxplorer", "type_of_asset": "general_faq"}, + query: "Is there any knowledge articles on how to define frictional contact in Ansys Mechanical?", + want: map[string]string{"product": "mechanical", "type_of_asset": "article", "physics": ""}, }, { - query: "Any new documentation on the Additive Print tool?", - want: map[string]string{"product": "additive print", "type_of_asset": "documentation"}, + query: "What are the new features in the latest SCADE release?", + want: map[string]string{"product": "scade", "type_of_asset": "", "physics": "scade"}, }, { - query: "Looking for a brochure on SpaceClaim.", - want: map[string]string{"product": "spaceclaim", "type_of_asset": "brochure"}, + query: "Tell me more about the Mechanical APDL course.", + want: map[string]string{"product": "mechanical apdl", "type_of_asset": "aic", "physics": ""}, + }, + { + query: "Is there any training available for Discovery?", + want: map[string]string{"product": "discovery", "type_of_asset": "", "physics": "discovery"}, + }, + { + query: "How can I import a 3D model from a CAD software into Ansys Workbench?", + want: map[string]string{"product": "", "type_of_asset": "", "physics": ""}, }, }