From d88d97055294e9cff13077d411fa85276de0bf1e Mon Sep 17 00:00:00 2001 From: Robi9 Date: Tue, 22 Aug 2023 16:42:49 -0300 Subject: [PATCH] Rename token variable --- flows/routers/smart.go | 10 +++++----- flows/routers/testdata/smart.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flows/routers/smart.go b/flows/routers/smart.go index 46e729e86..3936d7b9e 100644 --- a/flows/routers/smart.go +++ b/flows/routers/smart.go @@ -141,10 +141,10 @@ type errorResponse struct { } `json:"errors"` } -var validationToken string +var token string func SetToken(t string) { - validationToken = t + token = t } func SetAPIURL(url string) { @@ -160,7 +160,7 @@ func (r *SmartRouter) classifyText(run flows.FlowRun, step flows.Step, operand s Option string `json:"option"` Synonyms []string `json:"synonyms"` } `json:"categories"` - ValidationToken string `json:"validation_token"` + Token string `json:"token"` }{ Text: r.operand, } @@ -177,8 +177,8 @@ func (r *SmartRouter) classifyText(run flows.FlowRun, step flows.Step, operand s } } - if validationToken != "" { - body.ValidationToken = validationToken + if token != "" { + body.Token = token } else { run.LogError(step, fmt.Errorf("validation token cannot be empty")) status = flows.CallStatusConnectionError diff --git a/flows/routers/testdata/smart.json b/flows/routers/testdata/smart.json index c7c6468de..e03a877f2 100644 --- a/flows/routers/testdata/smart.json +++ b/flows/routers/testdata/smart.json @@ -57,7 +57,7 @@ "created_on": "2018-10-18T14:20:30.000123456Z", "elapsed_ms": 0, "extraction": "valid", - "request": "POST /v2/repository/nlp/zeroshot/zeroshot-fast-predict HTTP/1.1\r\nHost: api.bothub.it\r\nUser-Agent: Go-http-client/1.1\r\nContent-Length: 168\r\nAccept-Encoding: gzip\r\n\r\n{\"text\":\"@(\\\"How much does it cost?\\\")\",\"categories\":[{\"option\":\"Price\",\"synonyms\":[\"price\"]},{\"option\":\"Delivery\",\"synonyms\":[\"delivery\"]}],\"validation_token\":\"token\"}", + "request": "POST /v2/repository/nlp/zeroshot/zeroshot-fast-predict HTTP/1.1\r\nHost: api.bothub.it\r\nUser-Agent: Go-http-client/1.1\r\nContent-Length: 157\r\nAccept-Encoding: gzip\r\n\r\n{\"text\":\"@(\\\"How much does it cost?\\\")\",\"categories\":[{\"option\":\"Price\",\"synonyms\":[\"price\"]},{\"option\":\"Delivery\",\"synonyms\":[\"delivery\"]}],\"token\":\"token\"}", "response": "HTTP/1.0 200 OK\r\nContent-Length: 16\r\n\r\n{\"text\":\"Price\"}", "retries": 0, "status": "success",