Model
Replace the currently loaded model
Updates the currently loaded model. First, tries to load the model from the local (note: local to Rasa server) storage system. Secondly, tries to load the model from the provided model server configuration. Last, tries to load the model from the provided remote storage.
PUT
/
model
Replace the currently loaded model
curl --request PUT \
--url 'http://localhost:5005/model?token=' \
--header 'Content-Type: application/json' \
--data '
{
"model_file": "/absolute-path-to-models-directory/models/20190512.tar.gz",
"model_server": {
"url": "<string>",
"params": {},
"headers": {},
"basic_auth": {},
"token": "<string>",
"token_name": "<string>",
"wait_time_between_pulls": 123
},
"remote_storage": "aws"
}
'import requests
url = "http://localhost:5005/model?token="
payload = {
"model_file": "/absolute-path-to-models-directory/models/20190512.tar.gz",
"model_server": {
"url": "<string>",
"params": {},
"headers": {},
"basic_auth": {},
"token": "<string>",
"token_name": "<string>",
"wait_time_between_pulls": 123
},
"remote_storage": "aws"
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model_file: '/absolute-path-to-models-directory/models/20190512.tar.gz',
model_server: {
url: '<string>',
params: {},
headers: {},
basic_auth: {},
token: '<string>',
token_name: '<string>',
wait_time_between_pulls: 123
},
remote_storage: 'aws'
})
};
fetch('http://localhost:5005/model?token=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "5005",
CURLOPT_URL => "http://localhost:5005/model?token=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'model_file' => '/absolute-path-to-models-directory/models/20190512.tar.gz',
'model_server' => [
'url' => '<string>',
'params' => [
],
'headers' => [
],
'basic_auth' => [
],
'token' => '<string>',
'token_name' => '<string>',
'wait_time_between_pulls' => 123
],
'remote_storage' => 'aws'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:5005/model?token="
payload := strings.NewReader("{\n \"model_file\": \"/absolute-path-to-models-directory/models/20190512.tar.gz\",\n \"model_server\": {\n \"url\": \"<string>\",\n \"params\": {},\n \"headers\": {},\n \"basic_auth\": {},\n \"token\": \"<string>\",\n \"token_name\": \"<string>\",\n \"wait_time_between_pulls\": 123\n },\n \"remote_storage\": \"aws\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("http://localhost:5005/model?token=")
.header("Content-Type", "application/json")
.body("{\n \"model_file\": \"/absolute-path-to-models-directory/models/20190512.tar.gz\",\n \"model_server\": {\n \"url\": \"<string>\",\n \"params\": {},\n \"headers\": {},\n \"basic_auth\": {},\n \"token\": \"<string>\",\n \"token_name\": \"<string>\",\n \"wait_time_between_pulls\": 123\n },\n \"remote_storage\": \"aws\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:5005/model?token=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_file\": \"/absolute-path-to-models-directory/models/20190512.tar.gz\",\n \"model_server\": {\n \"url\": \"<string>\",\n \"params\": {},\n \"headers\": {},\n \"basic_auth\": {},\n \"token\": \"<string>\",\n \"token_name\": \"<string>\",\n \"wait_time_between_pulls\": 123\n },\n \"remote_storage\": \"aws\"\n}"
response = http.request(request)
puts response.read_body{
"version": "1.0.0",
"status": "failure",
"reason": "BadRequest",
"code": 400
}{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthenticated",
"message": "User is not authenticated to access resource.",
"code": 401
}{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthorized",
"message": "User has insufficient permission to access resource.",
"code": 403
}{
"version": "1.0.0",
"status": "ServerError",
"message": "An unexpected error occurred.",
"code": 500
}Authorizations
TokenAuthJWT
A plaintext token to secure your server, specified at startup in the argument --auth-token thisismysecret
Body
application/json
Response
Model was successfully replaced.
⌘I
Replace the currently loaded model
curl --request PUT \
--url 'http://localhost:5005/model?token=' \
--header 'Content-Type: application/json' \
--data '
{
"model_file": "/absolute-path-to-models-directory/models/20190512.tar.gz",
"model_server": {
"url": "<string>",
"params": {},
"headers": {},
"basic_auth": {},
"token": "<string>",
"token_name": "<string>",
"wait_time_between_pulls": 123
},
"remote_storage": "aws"
}
'import requests
url = "http://localhost:5005/model?token="
payload = {
"model_file": "/absolute-path-to-models-directory/models/20190512.tar.gz",
"model_server": {
"url": "<string>",
"params": {},
"headers": {},
"basic_auth": {},
"token": "<string>",
"token_name": "<string>",
"wait_time_between_pulls": 123
},
"remote_storage": "aws"
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model_file: '/absolute-path-to-models-directory/models/20190512.tar.gz',
model_server: {
url: '<string>',
params: {},
headers: {},
basic_auth: {},
token: '<string>',
token_name: '<string>',
wait_time_between_pulls: 123
},
remote_storage: 'aws'
})
};
fetch('http://localhost:5005/model?token=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "5005",
CURLOPT_URL => "http://localhost:5005/model?token=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'model_file' => '/absolute-path-to-models-directory/models/20190512.tar.gz',
'model_server' => [
'url' => '<string>',
'params' => [
],
'headers' => [
],
'basic_auth' => [
],
'token' => '<string>',
'token_name' => '<string>',
'wait_time_between_pulls' => 123
],
'remote_storage' => 'aws'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:5005/model?token="
payload := strings.NewReader("{\n \"model_file\": \"/absolute-path-to-models-directory/models/20190512.tar.gz\",\n \"model_server\": {\n \"url\": \"<string>\",\n \"params\": {},\n \"headers\": {},\n \"basic_auth\": {},\n \"token\": \"<string>\",\n \"token_name\": \"<string>\",\n \"wait_time_between_pulls\": 123\n },\n \"remote_storage\": \"aws\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("http://localhost:5005/model?token=")
.header("Content-Type", "application/json")
.body("{\n \"model_file\": \"/absolute-path-to-models-directory/models/20190512.tar.gz\",\n \"model_server\": {\n \"url\": \"<string>\",\n \"params\": {},\n \"headers\": {},\n \"basic_auth\": {},\n \"token\": \"<string>\",\n \"token_name\": \"<string>\",\n \"wait_time_between_pulls\": 123\n },\n \"remote_storage\": \"aws\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:5005/model?token=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_file\": \"/absolute-path-to-models-directory/models/20190512.tar.gz\",\n \"model_server\": {\n \"url\": \"<string>\",\n \"params\": {},\n \"headers\": {},\n \"basic_auth\": {},\n \"token\": \"<string>\",\n \"token_name\": \"<string>\",\n \"wait_time_between_pulls\": 123\n },\n \"remote_storage\": \"aws\"\n}"
response = http.request(request)
puts response.read_body{
"version": "1.0.0",
"status": "failure",
"reason": "BadRequest",
"code": 400
}{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthenticated",
"message": "User is not authenticated to access resource.",
"code": 401
}{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthorized",
"message": "User has insufficient permission to access resource.",
"code": 403
}{
"version": "1.0.0",
"status": "ServerError",
"message": "An unexpected error occurred.",
"code": 500
}