Skip to content

Commit 01ededd

Browse files
[WIP]feat: add API level information to distro docs
Signed-off-by: Nathan Weinberg <nweinber@redhat.com>
1 parent aacd140 commit 01ededd

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ repos:
6767
files: ^distribution/run\.yaml$
6868
additional_dependencies:
6969
- pyyaml==6.0.2
70+
- git+https://github.com/opendatahub-io/llama-stack.git@v0.3.0rc3+rhai0

scripts/gen_distro_docs.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import re
55
import subprocess
66
from pathlib import Path
7+
from llama_stack.core.library_client import LlamaStackAsLibraryClient
78

89

910
REPO_ROOT = Path(__file__).parent.parent
@@ -32,6 +33,12 @@ def resolve_main_commit_hash(repo_url):
3233
print(f"Warning: Could not resolve commit hash from main: {e}")
3334
return None
3435

36+
def extract_llama_stack_routes(distro_path: str):
37+
"""Extract Llama Stack route information"""
38+
client = LlamaStackAsLibraryClient(str(distro_path))
39+
routes = client.routes.list()
40+
return routes
41+
3542

3643
def extract_llama_stack_version():
3744
"""Extract Llama Stack version and repo owner from the Containerfile.
@@ -130,11 +137,11 @@ def load_external_providers_info():
130137
exit(1)
131138

132139

133-
def gen_distro_table(providers_data):
140+
def gen_distro_table(providers_data, routes):
134141
# Start with table header
135142
table_lines = [
136-
"| API | Provider | External? | Enabled by default? | How to enable |",
137-
"|-----|----------|-----------|---------------------|---------------|",
143+
"| Provider API | Provider | REST APIs | External? | Enabled by default? | How to enable |",
144+
"|--------------|----------|-----------|-----------|---------------------|---------------|",
138145
]
139146

140147
# Load external provider information from build.yaml
@@ -151,6 +158,17 @@ def gen_distro_table(providers_data):
151158
provider_type = provider["provider_type"]
152159
provider_id = provider.get("provider_id", "")
153160

161+
rest_api_pairs = []
162+
for route in routes:
163+
if (provider_type != "inline::meta-reference") and \
164+
(provider_type in route.provider_types) and \
165+
(len(route.route.split("/")) < 4 ) and \
166+
(route.route not in rest_api_pairs):
167+
rest_api_pairs.append(
168+
route.route
169+
)
170+
rest_apis = "<br>".join(rest_api_pairs)
171+
154172
# Check if provider_id contains the conditional syntax ${<something>:+<something>}
155173
# This regex matches the pattern ${...} containing :+
156174
conditional_match = re.search(
@@ -176,6 +194,7 @@ def gen_distro_table(providers_data):
176194
(
177195
api_name,
178196
provider_type,
197+
rest_apis,
179198
external_status,
180199
enabled_by_default,
181200
how_to_enable,
@@ -189,12 +208,13 @@ def gen_distro_table(providers_data):
189208
for (
190209
api_name,
191210
provider_type,
211+
rest_apis,
192212
external_status,
193213
enabled_by_default,
194214
how_to_enable,
195215
) in api_provider_pairs:
196216
table_lines.append(
197-
f"| {api_name} | {provider_type} | {external_status} | {enabled_by_default} | {how_to_enable} |"
217+
f"| {api_name} | {provider_type} | {rest_apis} | {external_status} | {enabled_by_default} | {how_to_enable} |"
198218
)
199219

200220
return "\n".join(table_lines)
@@ -253,13 +273,15 @@ def gen_distro_docs():
253273

254274
# Extract providers section
255275
providers = run_yaml_data.get("providers", {})
256-
257276
if not providers:
258277
print("Error: No providers found in run.yaml")
259278
return 1
260279

280+
# Extract routes info
281+
routes = extract_llama_stack_routes(str(run_yaml_path))
282+
261283
# Generate the Markdown table
262-
table_content = gen_distro_table(providers)
284+
table_content = gen_distro_table(providers, routes)
263285

264286
# Write to README.md
265287
with open(readme_path, "w") as readme_file:

0 commit comments

Comments
 (0)