diff --git a/docs/docs/providers/inference/remote_bedrock.mdx b/docs/docs/providers/inference/remote_bedrock.mdx index 61931643e..86bef3000 100644 --- a/docs/docs/providers/inference/remote_bedrock.mdx +++ b/docs/docs/providers/inference/remote_bedrock.mdx @@ -14,10 +14,10 @@ AWS Bedrock inference provider using OpenAI compatible endpoint. | Field | Type | Required | Default | Description | |-------|------|----------|---------|-------------| -| `allowed_models` | `list[str \| None` | No | | List of models that should be registered with the model registry. If None, all models are allowed. | -| `refresh_models` | `` | No | False | Whether to refresh models periodically from the provider | -| `api_key` | `pydantic.types.SecretStr \| None` | No | | Authentication credential for the provider | -| `region_name` | `` | No | us-east-2 | AWS Region for the Bedrock Runtime endpoint | +| `allowed_models` | `list[str] \| None` | No | | List of models that should be registered with the model registry. If None, all models are allowed. | +| `refresh_models` | `bool` | No | False | Whether to refresh models periodically from the provider | +| `api_key` | `SecretStr \| None` | No | | Authentication credential for the provider | +| `region_name` | `str` | No | us-east-2 | AWS Region for the Bedrock Runtime endpoint | ## Sample Configuration diff --git a/docs/docs/providers/inference/remote_oci.mdx b/docs/docs/providers/inference/remote_oci.mdx index 33a201a55..d448755bf 100644 --- a/docs/docs/providers/inference/remote_oci.mdx +++ b/docs/docs/providers/inference/remote_oci.mdx @@ -21,14 +21,14 @@ https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm | Field | Type | Required | Default | Description | |-------|------|----------|---------|-------------| -| `allowed_models` | `list[str \| None` | No | | List of models that should be registered with the model registry. If None, all models are allowed. | -| `refresh_models` | `` | No | False | Whether to refresh models periodically from the provider | -| `api_key` | `pydantic.types.SecretStr \| None` | No | | Authentication credential for the provider | -| `oci_auth_type` | `` | No | instance_principal | OCI authentication type (must be one of: instance_principal, config_file) | -| `oci_region` | `` | No | us-ashburn-1 | OCI region (e.g., us-ashburn-1) | -| `oci_compartment_id` | `` | No | | OCI compartment ID for the Generative AI service | -| `oci_config_file_path` | `` | No | ~/.oci/config | OCI config file path (required if oci_auth_type is config_file) | -| `oci_config_profile` | `` | No | DEFAULT | OCI config profile (required if oci_auth_type is config_file) | +| `allowed_models` | `list[str] \| None` | No | | List of models that should be registered with the model registry. If None, all models are allowed. | +| `refresh_models` | `bool` | No | False | Whether to refresh models periodically from the provider | +| `api_key` | `SecretStr \| None` | No | | Authentication credential for the provider | +| `oci_auth_type` | `str` | No | instance_principal | OCI authentication type (must be one of: instance_principal, config_file) | +| `oci_region` | `str` | No | us-ashburn-1 | OCI region (e.g., us-ashburn-1) | +| `oci_compartment_id` | `str` | No | | OCI compartment ID for the Generative AI service | +| `oci_config_file_path` | `str` | No | ~/.oci/config | OCI config file path (required if oci_auth_type is config_file) | +| `oci_config_profile` | `str` | No | DEFAULT | OCI config profile (required if oci_auth_type is config_file) | ## Sample Configuration diff --git a/docs/docs/providers/inference/remote_passthrough.mdx b/docs/docs/providers/inference/remote_passthrough.mdx index c339fef23..009961d49 100644 --- a/docs/docs/providers/inference/remote_passthrough.mdx +++ b/docs/docs/providers/inference/remote_passthrough.mdx @@ -16,7 +16,7 @@ Passthrough inference provider for connecting to any external inference service |-------|------|----------|---------|-------------| | `allowed_models` | `list[str] \| None` | No | | List of models that should be registered with the model registry. If None, all models are allowed. | | `refresh_models` | `bool` | No | False | Whether to refresh models periodically from the provider | -| `api_key` | `SecretStr \| None` | No | | API Key for the passthrouth endpoint | +| `api_key` | `SecretStr \| None` | No | | Authentication credential for the provider | | `url` | `str` | No | | The URL for the passthrough endpoint | ## Sample Configuration diff --git a/scripts/provider_codegen.py b/scripts/provider_codegen.py index cae1c1c3a..0eec46bc2 100755 --- a/scripts/provider_codegen.py +++ b/scripts/provider_codegen.py @@ -23,9 +23,7 @@ def get_api_docstring(api_name: str) -> str | None: """Extract docstring from the API protocol class.""" try: # Import the API module dynamically - api_module = __import__( - f"llama_stack_api.{api_name}", fromlist=[api_name.title()] - ) + api_module = __import__(f"llama_stack_api.{api_name}", fromlist=[api_name.title()]) # Get the main protocol class (usually capitalized API name) protocol_class_name = api_name.title() @@ -108,10 +106,7 @@ def get_config_class_info(config_class_path: str) -> dict[str, Any]: model_config = config_class.model_config if hasattr(model_config, "extra") and model_config.extra == "allow": accepts_extra_config = True - elif ( - isinstance(model_config, dict) - and model_config.get("extra") == "allow" - ): + elif isinstance(model_config, dict) and model_config.get("extra") == "allow": accepts_extra_config = True fields_info = {} @@ -129,10 +124,7 @@ def get_config_class_info(config_class_path: str) -> dict[str, Any]: # HACK ALERT: # If the default value contains a path that looks like it came from RUNTIME_BASE_DIR, # replace it with a generic ~/.llama/ path for documentation - if ( - isinstance(default_value, str) - and "/.llama/" in default_value - ): + if isinstance(default_value, str) and "/.llama/" in default_value: if ".llama/" in default_value: path_part = default_value.split(".llama/")[-1] default_value = f"~/.llama/{path_part}" @@ -161,11 +153,7 @@ def get_config_class_info(config_class_path: str) -> dict[str, Any]: lines = source.split("\n") for i, line in enumerate(lines): - if ( - "model_config" in line - and "ConfigDict" in line - and 'extra="allow"' in line - ): + if "model_config" in line and "ConfigDict" in line and 'extra="allow"' in line: comments = [] for j in range(i - 1, -1, -1): stripped = lines[j].strip() @@ -230,9 +218,7 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: # Create sidebar label (clean up provider_type for display) sidebar_label = provider_type.replace("::", " - ").replace("_", " ") if sidebar_label.startswith("inline - "): - sidebar_label = sidebar_label[ - 9: - ].title() # Remove "inline - " prefix and title case + sidebar_label = sidebar_label[9:].title() # Remove "inline - " prefix and title case else: sidebar_label = sidebar_label.title() @@ -275,9 +261,7 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: for field_name, field_info in config_info["fields"].items(): field_type = field_info["type"].replace("|", "\\|") required = "Yes" if field_info["required"] else "No" - default = ( - str(field_info["default"]) if field_info["default"] is not None else "" - ) + default = str(field_info["default"]) if field_info["default"] is not None else "" # Handle multiline default values and escape problematic characters for MDX if "\n" in default: @@ -287,9 +271,7 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: for line in lines: if line.strip(): # Escape angle brackets and wrap template tokens in backticks - escaped_line = ( - line.strip().replace("<", "<").replace(">", ">") - ) + escaped_line = line.strip().replace("<", "<").replace(">", ">") if ("{" in escaped_line and "}" in escaped_line) or ( "<|" in escaped_line and "|>" in escaped_line ): @@ -309,19 +291,13 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: default = f"`{escaped_default}`" else: # Apply additional escaping for curly braces - default = escaped_default.replace("{", "{").replace( - "}", "}" - ) + default = escaped_default.replace("{", "{").replace("}", "}") description_text = field_info["description"] or "" # Escape curly braces in description text for MDX compatibility - description_text = description_text.replace("{", "{").replace( - "}", "}" - ) + description_text = description_text.replace("{", "{").replace("}", "}") - md_lines.append( - f"| `{field_name}` | `{field_type}` | {required} | {default} | {description_text} |" - ) + md_lines.append(f"| `{field_name}` | `{field_type}` | {required} | {default} | {description_text} |") md_lines.append("") @@ -364,9 +340,7 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: sample_config_dict = convert_pydantic_to_dict(sample_config) # Strip trailing newlines from yaml.dump to prevent extra blank lines - yaml_output = yaml.dump( - sample_config_dict, default_flow_style=False, sort_keys=False - ).rstrip() + yaml_output = yaml.dump(sample_config_dict, default_flow_style=False, sort_keys=False).rstrip() md_lines.append(yaml_output) else: md_lines.append("# No sample configuration available.") @@ -374,10 +348,7 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: md_lines.append(f"# Error generating sample config: {str(e)}") md_lines.append("```") - if ( - hasattr(provider_spec, "deprecation_warning") - and provider_spec.deprecation_warning - ): + if hasattr(provider_spec, "deprecation_warning") and provider_spec.deprecation_warning: md_lines.append("## Deprecation Notice") md_lines.append("") md_lines.append(":::warning") @@ -394,9 +365,7 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str: return "\n".join(md_lines) + "\n" -def generate_index_docs( - api_name: str, api_docstring: str | None, provider_entries: list -) -> str: +def generate_index_docs(api_name: str, api_docstring: str | None, provider_entries: list) -> str: """Generate MDX documentation for the index file.""" # Create sidebar label for the API sidebar_label = api_name.replace("_", " ").title() @@ -432,9 +401,7 @@ def generate_index_docs( md_lines.append(f"{cleaned_docstring}") md_lines.append("") - md_lines.append( - f"This section contains documentation for all available providers for the **{api_name}** API." - ) + md_lines.append(f"This section contains documentation for all available providers for the **{api_name}** API.") return "\n".join(md_lines) + "\n" @@ -472,14 +439,10 @@ def process_provider_registry(progress, change_tracker: ChangedPathTracker) -> N else: display_name = display_name.title() - provider_entries.append( - {"filename": filename, "display_name": display_name} - ) + provider_entries.append({"filename": filename, "display_name": display_name}) # Generate index file with frontmatter - index_content = generate_index_docs( - api_name, api_docstring, provider_entries - ) + index_content = generate_index_docs(api_name, api_docstring, provider_entries) index_file = doc_output_dir / "index.mdx" index_file.write_text(index_content) change_tracker.add_paths(index_file)