Skip to content

Commit

Permalink
fix: field values (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurasgkadri98 authored Oct 8, 2024
1 parent 9b1c618 commit 27f633c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
14 changes: 6 additions & 8 deletions pkg/externalfunctions/ansysgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
68 changes: 36 additions & 32 deletions pkg/externalfunctions/externalfunctions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""},
},
}

Expand Down

0 comments on commit 27f633c

Please sign in to comment.