Skip to content

Commit

Permalink
Rename token variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Aug 22, 2023
1 parent e8d845f commit d88d970
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions flows/routers/smart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flows/routers/testdata/smart.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d88d970

Please sign in to comment.