Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove excess intent fetching on /training/intents page #731

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{
}
"[typescript][typescriptreact][json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
12 changes: 12 additions & 0 deletions DSL/DMapper/hbs/get_intent_by_id.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"id": "{{intents.intents.0._source.id}}",
"examples": [
{{#each intents.intents.0._source.examples}}
"{{{this}}}"{{#unless @last}},{{/unless}}
{{/each}}
],
"inModel": {{isInModel intents.intents.0._source.intent intents}},
"serviceId": "{{findConnectedServiceId intents.intents.0._source.intent intents}}",
"isForService": "{{getObjectKeyFromObjectArray intents/intentsModifiedAt 'intent' intents.intents.0._source.intent 'isforservice'}}",
"modifiedAt": "{{intents.intentsModifiedAt.0.created}}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"intents": [
{{#each hits}}
"{{key}}"{{#unless @last}},{{/unless}}
{{/each}}
]
}
2 changes: 1 addition & 1 deletion DSL/DMapper/hbs/get_intents_with_examples.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"intents": [
{{#each hits}}
{
"id": "{{_source._id}}",
"id": "{{_id}}",
"title": "{{_source.intent}}",
"examples": [
{{#each _source.examples}}
Expand Down
6 changes: 4 additions & 2 deletions DSL/DMapper/hbs/get_intents_with_examples_count.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"intents": [
{{#each buckets}}
{
"intent": "{{key}}",
"examples_count": {{examples_counts.value}}
"id": "{{key}}",
"examples_count": {{examples_counts.value}},
"inModel": {{isInModel key ../intents}},
"modifiedAt": "{{findModifiedAt key ../intents/intentsModifiedAt}}"
}{{#unless @last}},{{/unless}}
{{/each}}
]
Expand Down
23 changes: 11 additions & 12 deletions DSL/OpenSearch/templates/intents-with-examples-count.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,31 @@
"aggs": {
"hot": {
"terms": {
"field": "intent.keyword"
"field": "intent",
"size": 10000
},
"aggs": {
"examples_counts": {
"value_count": {
"field": "examples.raw"
"field": "examples"
}
}
}
}
},
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "*{{intent}}*",
"default_field": "intent"
}
}
]
{{#intent}}
"wildcard": {
"intent": "*{{intent}}*"
}
{{/intent}}
{{^intent}}
"match_all": {}
{{/intent}}
}
},
"params": {
"intent": ""
}
}
}
}
4 changes: 2 additions & 2 deletions DSL/Ruuter.private/GET/.guard
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process_request:
verify_header_nonce:
call: http.post
args:
url: [#TRAINING_RESQL]/use-nonce
url: "[#TRAINING_RESQL]/use-nonce"
body:
updated_nonce: ${incoming.headers['x-ruuter-nonce']}
result: nonce_response
Expand All @@ -18,7 +18,7 @@ verify_header_nonce:
verify_param_nonce:
call: http.post
args:
url: [#TRAINING_RESQL]/use-nonce
url: "[#TRAINING_RESQL]/use-nonce"
body:
updated_nonce: ${incoming.params['ruuter-nonce']}
result: nonce_response
Expand Down
90 changes: 90 additions & 0 deletions DSL/Ruuter.private/GET/rasa/intents/by-id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
declaration:
call: declare
version: 0.1
description: "Get intent with details by ID"
method: get
accepts: json
returns: json
namespace: training
allowlist:
headers:
- field: cookie
type: string
description: "Cookie field"
params:
- field: intent
type: string
description: "Intent ID"

assignValues:
assign:
intent: ${incoming.params.intent}

getIntent:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/intents/_search/template"
body:
id: "intent-with-name"
params:
intent: ${intent}
result: getIntentResult

getDomainFile:
call: http.get
args:
url: "[#TRAINING_PUBLIC_RUUTER]/internal/domain-file"
headers:
cookie: ${incoming.headers.cookie}
result: getDomainDataResult

checkIfIntentExists:
switch:
- condition: ${getIntentResult.response.body.hits.hits != null}
next: getServiceIntentConnections
next: returnNoIntentFound

getServiceIntentConnections:
call: http.post
args:
url: "[#TRAINING_RESQL]/get-service-intent-connections"
result: getServiceIntentConnectionsResult

# todo if not using full, maybe modify to return one value
getIntentListLastChanged:
call: http.post
args:
url: "[#TRAINING_RESQL]/get-intents-list-last-changed"
body:
intentsList: ${getIntentResult.response.body.hits.hits[0]._id}
result: getIntentListLastChangedResult

assignResults:
assign:
# TODO: Ideally, should use a single object, not array
intents:
intents: ${getIntentResult.response.body.hits.hits}
inmodel: ${getDomainDataResult.response.body.response.intents}
connections: ${getServiceIntentConnectionsResult.response.body}
intentsModifiedAt: ${getIntentListLastChangedResult.response.body}

mapIntentData:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_intent_by_id"
headers:
type: "json"
body:
intents: ${intents}
result: getIntentDataResult
next: returnSuccess

returnSuccess:
return: ${getIntentDataResult.response.body}
next: end

returnNoIntentFound:
return: "Error: no intent found"
wrapper: false
status: 404
next: end
33 changes: 0 additions & 33 deletions DSL/Ruuter.private/GET/rasa/intents/examples/count.yml

This file was deleted.

65 changes: 65 additions & 0 deletions DSL/Ruuter.private/GET/rasa/intents/with-examples-count.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
declaration:
call: declare
version: 0.1
description: "Decription placeholder for 'COUNT'"
method: get
accepts: json
returns: json
namespace: training
allowlist:
headers:
- field: cookie
type: string
description: "Cookie field"

getIntentsExampleCount:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/intents/_search/template"
body:
id: "intents-with-examples-count"
result: getIntentsResult

getDomainFile:
call: http.get
args:
url: "[#TRAINING_PUBLIC_RUUTER]/internal/domain-file"
headers:
cookie: ${incoming.headers.cookie}
result: getDomainDataResult

getIntentsNames:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_intent_names_from_example_counts"
headers:
type: "json"
body:
hits: ${getIntentsResult.response.body.aggregations.hot.buckets}
result: getIntentsNamesResult

getIntentListLastChanged:
call: http.post
args:
url: "[#TRAINING_RESQL]/get-intents-list-last-changed"
body:
intentsList: ${getIntentsNamesResult.response.body.intents}
result: getIntentsListLastChangedResult

mapIntentsData:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_intents_with_examples_count"
headers:
type: "json"
body:
buckets: ${getIntentsResult.response.body.aggregations.hot.buckets}
intents:
inmodel: ${getDomainDataResult.response.body.response.intents}
intentsModifiedAt: ${getIntentsListLastChangedResult.response.body}
result: intentsData
next: returnSuccess

returnSuccess:
return: ${intentsData.response.body}
next: end
36 changes: 0 additions & 36 deletions DSL/Ruuter.private/POST/rasa/intents/examples/count.yml

This file was deleted.

Loading