Skip to content

Commit

Permalink
[docs] add openapi spec to docs (#508)
Browse files Browse the repository at this point in the history
# What does this PR do?
- modify openapi generator to add coming soon tag for unimplemented api
- sphinx-redocs extension for openapi spec to readthedocs page

## Test Plan



https://github.com/user-attachments/assets/b4c7eebc-2361-4198-a987-dbfbcff914cf






## Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the
other checks if that's the case).
- [ ] Ran pre-commit to handle lint / formatting issues.
- [ ] Read the [contributor
guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md),
      Pull Request section?
- [ ] Updated relevant documentation.
- [ ] Wrote necessary unit or integration tests.
  • Loading branch information
yanxi0830 authored Nov 23, 2024
1 parent 1b2b32f commit d97cfaa
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 44 deletions.
8 changes: 3 additions & 5 deletions docs/openapi_generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ def main(output_dir: str):
Options(
server=Server(url="http://any-hosted-llama-stack.com"),
info=Info(
title="[DRAFT] Llama Stack Specification",
title="Llama Stack Specification",
version=LLAMA_STACK_API_VERSION,
description="""This is the specification of the llama stack that provides
description="""This is the specification of the Llama Stack that provides
a set of endpoints and their corresponding interfaces that are tailored to
best leverage Llama Models. The specification is still in draft and subject to change.
Generated at """
+ now,
best leverage Llama Models.""",
),
),
)
Expand Down
8 changes: 8 additions & 0 deletions docs/openapi_generator/pyopenapi/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ def _build_extra_tag_groups(
return extra_tags

def _build_operation(self, op: EndpointOperation) -> Operation:
if op.defining_class.__name__ in [
"SyntheticDataGeneration",
"PostTraining",
"BatchInference",
]:
op.defining_class.__name__ = f"{op.defining_class.__name__} (Coming Soon)"
print(op.defining_class.__name__)

doc_string = parse_type(op.func_ref)
doc_params = dict(
(param.name, param.description) for param in doc_string.params.values()
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ sphinx-pdj-theme
sphinx-copybutton
sphinx-tabs
sphinx-design
sphinxcontrib-openapi
sphinxcontrib-redoc
39 changes: 20 additions & 19 deletions docs/resources/llama-stack-spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
spec = {
"openapi": "3.1.0",
"info": {
"title": "[DRAFT] Llama Stack Specification",
"title": "Llama Stack Specification",
"version": "alpha",
"description": "This is the specification of the llama stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models. The specification is still in draft and subject to change.\n Generated at 2024-11-19 09:14:01.145131"
"description": "This is the specification of the Llama Stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models. Generated at 2024-11-22 17:23:55.034164"
},
"servers": [
{
Expand All @@ -44,7 +44,7 @@
}
},
"tags": [
"BatchInference"
"BatchInference (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -84,7 +84,7 @@
}
},
"tags": [
"BatchInference"
"BatchInference (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -117,7 +117,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -1079,7 +1079,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -1117,7 +1117,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -1155,7 +1155,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -1193,7 +1193,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -1713,7 +1713,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -2161,7 +2161,7 @@
}
},
"tags": [
"PostTraining"
"PostTraining (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -2201,7 +2201,7 @@
}
},
"tags": [
"SyntheticDataGeneration"
"SyntheticDataGeneration (Coming Soon)"
],
"parameters": [
{
Expand Down Expand Up @@ -3861,7 +3861,8 @@
"type": "string",
"enum": [
"bing",
"brave"
"brave",
"tavily"
],
"default": "brave"
},
Expand Down Expand Up @@ -8002,7 +8003,7 @@
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/BatchCompletionResponse\" />"
},
{
"name": "BatchInference"
"name": "BatchInference (Coming Soon)"
},
{
"name": "BenchmarkEvalTaskConfig",
Expand Down Expand Up @@ -8256,7 +8257,7 @@
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/PhotogenToolDefinition\" />"
},
{
"name": "PostTraining"
"name": "PostTraining (Coming Soon)"
},
{
"name": "PostTrainingJob",
Expand Down Expand Up @@ -8447,7 +8448,7 @@
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/SyntheticDataGenerateRequest\" />"
},
{
"name": "SyntheticDataGeneration"
"name": "SyntheticDataGeneration (Coming Soon)"
},
{
"name": "SyntheticDataGenerationResponse",
Expand Down Expand Up @@ -8558,7 +8559,7 @@
"name": "Operations",
"tags": [
"Agents",
"BatchInference",
"BatchInference (Coming Soon)",
"DatasetIO",
"Datasets",
"Eval",
Expand All @@ -8568,12 +8569,12 @@
"Memory",
"MemoryBanks",
"Models",
"PostTraining",
"PostTraining (Coming Soon)",
"Safety",
"Scoring",
"ScoringFunctions",
"Shields",
"SyntheticDataGeneration",
"SyntheticDataGeneration (Coming Soon)",
"Telemetry"
]
},
Expand Down
40 changes: 20 additions & 20 deletions docs/resources/llama-stack-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,7 @@ components:
enum:
- bing
- brave
- tavily
type: string
input_shields:
items:
Expand Down Expand Up @@ -3397,11 +3398,10 @@ components:
- api_key
type: object
info:
description: "This is the specification of the llama stack that provides\n \
description: "This is the specification of the Llama Stack that provides\n \
\ a set of endpoints and their corresponding interfaces that are tailored\
\ to\n best leverage Llama Models. The specification is still in\
\ draft and subject to change.\n Generated at 2024-11-19 09:14:01.145131"
title: '[DRAFT] Llama Stack Specification'
\ to\n best leverage Llama Models. Generated at 2024-11-22 17:23:55.034164"
title: Llama Stack Specification
version: alpha
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
openapi: 3.1.0
Expand Down Expand Up @@ -3658,7 +3658,7 @@ paths:
$ref: '#/components/schemas/BatchChatCompletionResponse'
description: OK
tags:
- BatchInference
- BatchInference (Coming Soon)
/alpha/batch-inference/completion:
post:
parameters:
Expand All @@ -3683,7 +3683,7 @@ paths:
$ref: '#/components/schemas/BatchCompletionResponse'
description: OK
tags:
- BatchInference
- BatchInference (Coming Soon)
/alpha/datasetio/get-rows-paginated:
get:
parameters:
Expand Down Expand Up @@ -4337,7 +4337,7 @@ paths:
$ref: '#/components/schemas/PostTrainingJobArtifactsResponse'
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/post-training/job/cancel:
post:
parameters:
Expand All @@ -4358,7 +4358,7 @@ paths:
'200':
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/post-training/job/logs:
get:
parameters:
Expand All @@ -4382,7 +4382,7 @@ paths:
$ref: '#/components/schemas/PostTrainingJobLogStream'
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/post-training/job/status:
get:
parameters:
Expand All @@ -4406,7 +4406,7 @@ paths:
$ref: '#/components/schemas/PostTrainingJobStatusResponse'
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/post-training/jobs:
get:
parameters:
Expand All @@ -4425,7 +4425,7 @@ paths:
$ref: '#/components/schemas/PostTrainingJob'
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/post-training/preference-optimize:
post:
parameters:
Expand All @@ -4450,7 +4450,7 @@ paths:
$ref: '#/components/schemas/PostTrainingJob'
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/post-training/supervised-fine-tune:
post:
parameters:
Expand All @@ -4475,7 +4475,7 @@ paths:
$ref: '#/components/schemas/PostTrainingJob'
description: OK
tags:
- PostTraining
- PostTraining (Coming Soon)
/alpha/providers/list:
get:
parameters:
Expand Down Expand Up @@ -4755,7 +4755,7 @@ paths:
$ref: '#/components/schemas/SyntheticDataGenerationResponse'
description: OK
tags:
- SyntheticDataGeneration
- SyntheticDataGeneration (Coming Soon)
/alpha/telemetry/get-trace:
get:
parameters:
Expand Down Expand Up @@ -4863,7 +4863,7 @@ tags:
- description: <SchemaDefinition schemaRef="#/components/schemas/BatchCompletionResponse"
/>
name: BatchCompletionResponse
- name: BatchInference
- name: BatchInference (Coming Soon)
- description: <SchemaDefinition schemaRef="#/components/schemas/BenchmarkEvalTaskConfig"
/>
name: BenchmarkEvalTaskConfig
Expand Down Expand Up @@ -5044,7 +5044,7 @@ tags:
- description: <SchemaDefinition schemaRef="#/components/schemas/PhotogenToolDefinition"
/>
name: PhotogenToolDefinition
- name: PostTraining
- name: PostTraining (Coming Soon)
- description: <SchemaDefinition schemaRef="#/components/schemas/PostTrainingJob"
/>
name: PostTrainingJob
Expand Down Expand Up @@ -5179,7 +5179,7 @@ tags:
- description: <SchemaDefinition schemaRef="#/components/schemas/SyntheticDataGenerateRequest"
/>
name: SyntheticDataGenerateRequest
- name: SyntheticDataGeneration
- name: SyntheticDataGeneration (Coming Soon)
- description: 'Response from the synthetic data generation. Batch of (prompt, response,
score) tuples that pass the threshold.
Expand Down Expand Up @@ -5262,7 +5262,7 @@ x-tagGroups:
- name: Operations
tags:
- Agents
- BatchInference
- BatchInference (Coming Soon)
- DatasetIO
- Datasets
- Eval
Expand All @@ -5272,12 +5272,12 @@ x-tagGroups:
- Memory
- MemoryBanks
- Models
- PostTraining
- PostTraining (Coming Soon)
- Safety
- Scoring
- ScoringFunctions
- Shields
- SyntheticDataGeneration
- SyntheticDataGeneration (Coming Soon)
- Telemetry
- name: Types
tags:
Expand Down
16 changes: 16 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"sphinx_copybutton",
"sphinx_tabs.tabs",
"sphinx_design",
"sphinxcontrib.redoc",
]
myst_enable_extensions = ["colon_fence"]

Expand Down Expand Up @@ -82,3 +83,18 @@
html_static_path = ["../_static"]
# html_logo = "../_static/llama-stack-logo.png"
html_style = "../_static/css/my_theme.css"

redoc = [
{
"name": "Llama Stack API",
"page": "references/api_reference/index",
"spec": "../resources/llama-stack-spec.yaml",
"opts": {
"suppress-warnings": True,
# "expand-responses": ["200", "201"],
},
"embed": True,
},
]

redoc_uri = "https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"
7 changes: 7 additions & 0 deletions docs/source/references/api_reference/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# API Reference

```{eval-rst}
.. sphinxcontrib-redoc:: ../resources/llama-stack-spec.yaml
:page-title: API Reference
:expand-responses: all
```
Loading

0 comments on commit d97cfaa

Please sign in to comment.