Skip to content

Commit c2b5176

Browse files
author
Tayfun Sen
authored
Fix API docs (#10268)
* Fix http-api docs
1 parent 5376b15 commit c2b5176

File tree

2 files changed

+100
-126
lines changed

2 files changed

+100
-126
lines changed

docs/static/spec/rasa.yml

+100-98
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,61 @@ paths:
482482
description: >-
483483
The training data should be in YAML format.
484484
content:
485-
application/json:
486-
schema:
487-
$ref: '#/components/schemas/JSONTrainingRequest'
488-
application/x-yaml:
485+
application/yaml:
489486
schema:
490-
type: string
487+
$ref: '#/components/schemas/YAMLTrainingRequest'
488+
example: |
489+
pipeline: []
490+
491+
policies: []
492+
493+
intents:
494+
- greet
495+
- goodbye
496+
497+
entities: []
498+
slots: {}
499+
actions: []
500+
forms: {}
501+
e2e_actions: []
502+
503+
responses:
504+
utter_greet:
505+
- text: "Hey! How are you?"
506+
507+
utter_goodbye:
508+
- text: "Bye"
509+
510+
session_config:
511+
session_expiration_time: 60
512+
carry_over_slots_to_new_session: true
513+
514+
nlu:
515+
- intent: greet
516+
examples: |
517+
- hey
518+
- hello
519+
520+
- intent: goodbye
521+
examples: |
522+
- bye
523+
- goodbye
524+
525+
rules:
526+
527+
- rule: Say goodbye anytime the user says goodbye
528+
steps:
529+
- intent: goodbye
530+
- action: utter_goodbye
531+
532+
stories:
533+
534+
- story: happy path
535+
steps:
536+
- intent: greet
537+
- action: utter_greet
538+
- intent: goodbye
539+
- action: utter_goodbye
491540
492541
responses:
493542
200:
@@ -718,7 +767,8 @@ paths:
718767
summary: Replace the currently loaded model
719768
description: >-
720769
Updates the currently loaded model.
721-
First, tries to load the model from the local storage system.
770+
First, tries to load the model from the local (note: local to Rasa server)
771+
storage system.
722772
Secondly, tries to load the model from the provided model server configuration.
723773
Last, tries to load the model from the provided remote storage.
724774
requestBody:
@@ -1052,7 +1102,7 @@ components:
10521102
model_file:
10531103
type: string
10541104
description: Path to model file
1055-
example: "/models/20190512.tar.gz"
1105+
example: "/absolute-path-to-models-directory/models/20190512.tar.gz"
10561106
model_server:
10571107
$ref: '#/components/schemas/EndpointConfig'
10581108
remote_storage:
@@ -1407,19 +1457,53 @@ components:
14071457
type: integer
14081458
description: Time to wait between pulls from model server
14091459

1410-
JSONTrainingRequest:
1460+
YAMLTrainingRequest:
14111461
type: object
14121462
properties:
1413-
domain:
1414-
$ref: '#/components/schemas/DomainFile'
1415-
config:
1416-
$ref: '#/components/schemas/ConfigFile'
1417-
nlu:
1418-
$ref: '#/components/schemas/NLUTrainingData'
1463+
pipeline:
1464+
description: Pipeline list
1465+
type: array
1466+
policies:
1467+
description: Policies list
1468+
type: array
1469+
entities:
1470+
description: Entity list
1471+
type: array
1472+
slots:
1473+
description: Slots list
1474+
type: array
1475+
actions:
1476+
description: Action list
1477+
type: array
1478+
forms:
1479+
description: Forms list
1480+
type: array
1481+
e2e_actions:
1482+
description: E2E Action list
1483+
type: array
14191484
responses:
1420-
$ref: '#/components/schemas/RetrievalIntentsTrainingData'
1485+
description: Bot response templates
1486+
type: object
1487+
additionalProperties:
1488+
$ref: '#/components/schemas/TemplateDescription'
1489+
session_config:
1490+
description: Session configuration options
1491+
type: object
1492+
properties:
1493+
session_expiration_time:
1494+
type: integer
1495+
carry_over_slots_to_new_session:
1496+
type: boolean
1497+
nlu:
1498+
description: Rasa NLU data, array of intents
1499+
type: array
1500+
rules:
1501+
description: Rule list
1502+
type: array
14211503
stories:
1422-
$ref: '#/components/schemas/StoriesTrainingData'
1504+
description: Rasa Core stories in YAML format
1505+
type: array
1506+
14231507
force:
14241508
type: boolean
14251509
description: >-
@@ -1432,46 +1516,6 @@ components:
14321516
If `true` (default) the trained model will be saved in the default model
14331517
directory, if `false` it will be saved in a temporary directory
14341518
deprecated: True
1435-
required: ["config"]
1436-
1437-
NLUTrainingData:
1438-
type: string
1439-
description: Rasa NLU training data in YAML format
1440-
example: >-
1441-
- intent: greet
1442-
examples: |
1443-
- hey
1444-
- hello
1445-
- hi
1446-
1447-
- intent: goodbye
1448-
examples: |
1449-
- bye
1450-
- goodbye
1451-
- have a nice day
1452-
- see you
1453-
1454-
- intent: affirm
1455-
examples: |
1456-
- yes
1457-
- indeed
1458-
1459-
- intent: deny
1460-
examples: |
1461-
- no
1462-
- never
1463-
1464-
- intent: mood_great
1465-
examples: |
1466-
- perfect
1467-
- very good
1468-
- great
1469-
1470-
- intent: mood_unhappy
1471-
examples: |
1472-
- sad
1473-
- not good
1474-
- unhappy
14751519

14761520
RetrievalIntentsTrainingData:
14771521
type: string
@@ -1518,48 +1562,6 @@ components:
15181562
- intent: goodbye
15191563
- action: utter_goodbye
15201564
1521-
DomainFile:
1522-
type: string
1523-
description: Rasa domain in plain text
1524-
example: >-
1525-
intents:
1526-
- greet
1527-
- goodbye
1528-
- affirm
1529-
- deny
1530-
- mood_great
1531-
- mood_unhappy
1532-
1533-
responses:
1534-
utter_greet:
1535-
- text: "Hey! How are you?"
1536-
1537-
utter_cheer_up:
1538-
- text: "Here is something to cheer you up:"
1539-
image: "https://i.imgur.com/nGF1K8f.jpg"
1540-
1541-
utter_did_that_help:
1542-
- text: "Did that help you?"
1543-
1544-
utter_happy:
1545-
- text: "Great carry on!"
1546-
1547-
utter_goodbye:
1548-
- text: "Bye"
1549-
1550-
ConfigFile:
1551-
type: string
1552-
description: Rasa config in plain text
1553-
example: >-
1554-
recipe: default.v1
1555-
language: en
1556-
1557-
pipeline: supervised_embeddings
1558-
1559-
policies:
1560-
- name: MemoizationPolicy
1561-
- name: TEDPolicy
1562-
15631565
TrainingResult:
15641566
type: string
15651567
format: binary

rasa/server.py

-28
Original file line numberDiff line numberDiff line change
@@ -1422,34 +1422,6 @@ def _test_data_file_from_payload(request: Request, temporary_directory: Path) ->
14221422
)
14231423

14241424

1425-
def _validate_json_training_payload(rjs: Dict) -> None:
1426-
if "config" not in rjs:
1427-
raise ErrorResponse(
1428-
HTTPStatus.BAD_REQUEST,
1429-
"BadRequest",
1430-
"The training request is missing the required key `config`.",
1431-
{"parameter": "config", "in": "body"},
1432-
)
1433-
1434-
if "nlu" not in rjs and "stories" not in rjs:
1435-
raise ErrorResponse(
1436-
HTTPStatus.BAD_REQUEST,
1437-
"BadRequest",
1438-
"To train a Rasa model you need to specify at least one type of "
1439-
"training data. Add `nlu` and/or `stories` to the request.",
1440-
{"parameters": ["nlu", "stories"], "in": "body"},
1441-
)
1442-
1443-
if "stories" in rjs and "domain" not in rjs:
1444-
raise ErrorResponse(
1445-
HTTPStatus.BAD_REQUEST,
1446-
"BadRequest",
1447-
"To train a Rasa model with story training data, you also need to "
1448-
"specify the `domain`.",
1449-
{"parameter": "domain", "in": "body"},
1450-
)
1451-
1452-
14531425
def _training_payload_from_yaml(
14541426
request: Request, temp_dir: Path, file_name: Text = "data.yml"
14551427
) -> Dict[Text, Any]:

0 commit comments

Comments
 (0)