Skip to content

Commit

Permalink
Use new config keys for LUIS classifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 5, 2021
1 parent 1f148e1 commit 75810e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
21 changes: 11 additions & 10 deletions core/models/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const (
BothubConfigAccessToken = "access_token"

// LUIS config options
LuisConfigAppID = "app_id"
LuisConfigVersion = "version"
LuisConfigEndpointURL = "endpoint_url"
LuisConfigPrimaryKey = "primary_key"
LuisConfigAppID = "app_id"
LuisConfigPredictionEndpoint = "prediction_endpoint"
LuisConfigPredictionKey = "prediction_key"
LuisConfigSlot = "slot"
)

// Register a classification service factory with the engine
Expand Down Expand Up @@ -102,14 +102,15 @@ func (c *Classifier) AsService(classifier *flows.Classifier) (flows.Classificati
return wit.NewService(httpClient, httpRetries, classifier, accessToken), nil

case ClassifierTypeLuis:
endpoint := c.c.Config[LuisConfigEndpointURL]
appID := c.c.Config[LuisConfigAppID]
key := c.c.Config[LuisConfigPrimaryKey]
if endpoint == "" || appID == "" || key == "" {
return nil, errors.Errorf("missing %s, %s or %s on LUIS classifier: %s",
LuisConfigEndpointURL, LuisConfigAppID, LuisConfigPrimaryKey, c.UUID())
endpoint := c.c.Config[LuisConfigPredictionEndpoint]
key := c.c.Config[LuisConfigPredictionKey]
slot := c.c.Config[LuisConfigSlot]
if endpoint == "" || appID == "" || key == "" || slot == "" {
return nil, errors.Errorf("missing %s, %s, %s or %s on LUIS classifier: %s",
LuisConfigAppID, LuisConfigPredictionEndpoint, LuisConfigPredictionKey, LuisConfigSlot, c.UUID())
}
return luis.NewService(httpClient, httpRetries, httpAccess, classifier, endpoint, "production", appID, key), nil
return luis.NewService(httpClient, httpRetries, httpAccess, classifier, endpoint, appID, key, slot), nil

case ClassifierTypeBothub:
accessToken := c.c.Config[BothubConfigAccessToken]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/nyaruka/ezconf v0.2.1
github.com/nyaruka/gocommon v1.13.0
github.com/nyaruka/goflow v0.131.0
github.com/nyaruka/goflow v0.131.1
github.com/nyaruka/librato v1.0.0
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d
github.com/nyaruka/null v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0=
github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw=
github.com/nyaruka/gocommon v1.13.0 h1:WPL//ekajA30KinYRr6IrdP1igNZpcUAfABleHCuxPQ=
github.com/nyaruka/gocommon v1.13.0/go.mod h1:Jn7UIE8zwIr4JaviDf4PZrrQlN8r6QGVhOuaF/JoKus=
github.com/nyaruka/goflow v0.131.0 h1:HV8kNH1XYkW2QjjibNqo6PLnZbd7pERgbpLun6zyGqA=
github.com/nyaruka/goflow v0.131.0/go.mod h1:Xp1p21TyYiMM/fVQNWQRok/fZ1ZeNoeQGUd//LvYxq4=
github.com/nyaruka/goflow v0.131.1 h1:jgwxO+A/FK1YtL7cDndiLpMIB15/IkI+hXnmuAIu41I=
github.com/nyaruka/goflow v0.131.1/go.mod h1:Xp1p21TyYiMM/fVQNWQRok/fZ1ZeNoeQGUd//LvYxq4=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg=
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d h1:hyp9u36KIwbTCo2JAJ+TuJcJBc+UZzEig7RI/S5Dvkc=
Expand Down

0 comments on commit 75810e2

Please sign in to comment.