llama-stack-api 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. llama_stack_api/__init__.py +945 -0
  2. llama_stack_api/admin/__init__.py +45 -0
  3. llama_stack_api/admin/api.py +72 -0
  4. llama_stack_api/admin/fastapi_routes.py +117 -0
  5. llama_stack_api/admin/models.py +113 -0
  6. llama_stack_api/agents.py +173 -0
  7. llama_stack_api/batches/__init__.py +40 -0
  8. llama_stack_api/batches/api.py +53 -0
  9. llama_stack_api/batches/fastapi_routes.py +113 -0
  10. llama_stack_api/batches/models.py +78 -0
  11. llama_stack_api/benchmarks/__init__.py +43 -0
  12. llama_stack_api/benchmarks/api.py +39 -0
  13. llama_stack_api/benchmarks/fastapi_routes.py +109 -0
  14. llama_stack_api/benchmarks/models.py +109 -0
  15. llama_stack_api/common/__init__.py +5 -0
  16. llama_stack_api/common/content_types.py +101 -0
  17. llama_stack_api/common/errors.py +95 -0
  18. llama_stack_api/common/job_types.py +38 -0
  19. llama_stack_api/common/responses.py +77 -0
  20. llama_stack_api/common/training_types.py +47 -0
  21. llama_stack_api/common/type_system.py +146 -0
  22. llama_stack_api/connectors.py +146 -0
  23. llama_stack_api/conversations.py +270 -0
  24. llama_stack_api/datasetio.py +55 -0
  25. llama_stack_api/datasets/__init__.py +61 -0
  26. llama_stack_api/datasets/api.py +35 -0
  27. llama_stack_api/datasets/fastapi_routes.py +104 -0
  28. llama_stack_api/datasets/models.py +152 -0
  29. llama_stack_api/datatypes.py +373 -0
  30. llama_stack_api/eval.py +137 -0
  31. llama_stack_api/file_processors/__init__.py +27 -0
  32. llama_stack_api/file_processors/api.py +64 -0
  33. llama_stack_api/file_processors/fastapi_routes.py +78 -0
  34. llama_stack_api/file_processors/models.py +42 -0
  35. llama_stack_api/files/__init__.py +35 -0
  36. llama_stack_api/files/api.py +51 -0
  37. llama_stack_api/files/fastapi_routes.py +124 -0
  38. llama_stack_api/files/models.py +107 -0
  39. llama_stack_api/inference.py +1169 -0
  40. llama_stack_api/inspect_api/__init__.py +37 -0
  41. llama_stack_api/inspect_api/api.py +25 -0
  42. llama_stack_api/inspect_api/fastapi_routes.py +76 -0
  43. llama_stack_api/inspect_api/models.py +28 -0
  44. llama_stack_api/internal/__init__.py +9 -0
  45. llama_stack_api/internal/kvstore.py +28 -0
  46. llama_stack_api/internal/sqlstore.py +81 -0
  47. llama_stack_api/models.py +171 -0
  48. llama_stack_api/openai_responses.py +1468 -0
  49. llama_stack_api/post_training.py +370 -0
  50. llama_stack_api/prompts.py +203 -0
  51. llama_stack_api/providers/__init__.py +33 -0
  52. llama_stack_api/providers/api.py +16 -0
  53. llama_stack_api/providers/fastapi_routes.py +57 -0
  54. llama_stack_api/providers/models.py +24 -0
  55. llama_stack_api/rag_tool.py +168 -0
  56. llama_stack_api/resource.py +37 -0
  57. llama_stack_api/router_utils.py +160 -0
  58. llama_stack_api/safety.py +132 -0
  59. llama_stack_api/schema_utils.py +208 -0
  60. llama_stack_api/scoring.py +93 -0
  61. llama_stack_api/scoring_functions.py +211 -0
  62. llama_stack_api/shields.py +93 -0
  63. llama_stack_api/tools.py +226 -0
  64. llama_stack_api/vector_io.py +941 -0
  65. llama_stack_api/vector_stores.py +53 -0
  66. llama_stack_api/version.py +9 -0
  67. {llama_stack_api-0.4.2.dist-info → llama_stack_api-0.4.4.dist-info}/METADATA +1 -1
  68. llama_stack_api-0.4.4.dist-info/RECORD +70 -0
  69. {llama_stack_api-0.4.2.dist-info → llama_stack_api-0.4.4.dist-info}/WHEEL +1 -1
  70. llama_stack_api-0.4.4.dist-info/top_level.txt +1 -0
  71. llama_stack_api-0.4.2.dist-info/RECORD +0 -4
  72. llama_stack_api-0.4.2.dist-info/top_level.txt +0 -1
@@ -0,0 +1,24 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the terms described in the LICENSE file in
5
+ # the root directory of this source tree.
6
+
7
+ """Pydantic models for Providers API requests and responses.
8
+
9
+ This module re-exports models from llama_stack_api.admin.models to ensure
10
+ a single source of truth and avoid type conflicts.
11
+ """
12
+
13
+ # Import and re-export shared models from admin
14
+ from llama_stack_api.admin.models import (
15
+ InspectProviderRequest,
16
+ ListProvidersResponse,
17
+ ProviderInfo,
18
+ )
19
+
20
+ __all__ = [
21
+ "ProviderInfo",
22
+ "ListProvidersResponse",
23
+ "InspectProviderRequest",
24
+ ]
@@ -0,0 +1,168 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the terms described in the LICENSE file in
5
+ # the root directory of this source tree.
6
+
7
+ from enum import Enum, StrEnum
8
+ from typing import Annotated, Any, Literal
9
+
10
+ from pydantic import BaseModel, Field, field_validator
11
+
12
+ from llama_stack_api.common.content_types import URL, InterleavedContent
13
+
14
+
15
+ class RRFRanker(BaseModel):
16
+ """
17
+ Reciprocal Rank Fusion (RRF) ranker configuration.
18
+
19
+ :param type: The type of ranker, always "rrf"
20
+ :param impact_factor: The impact factor for RRF scoring. Higher values give more weight to higher-ranked results.
21
+ Must be greater than 0
22
+ """
23
+
24
+ type: Literal["rrf"] = "rrf"
25
+ impact_factor: float = Field(default=60.0, gt=0.0) # default of 60 for optimal performance
26
+
27
+
28
+ class WeightedRanker(BaseModel):
29
+ """
30
+ Weighted ranker configuration that combines vector and keyword scores.
31
+
32
+ :param type: The type of ranker, always "weighted"
33
+ :param alpha: Weight factor between 0 and 1.
34
+ 0 means only use keyword scores,
35
+ 1 means only use vector scores,
36
+ values in between blend both scores.
37
+ """
38
+
39
+ type: Literal["weighted"] = "weighted"
40
+ alpha: float = Field(
41
+ default=0.5,
42
+ ge=0.0,
43
+ le=1.0,
44
+ description="Weight factor between 0 and 1. 0 means only keyword scores, 1 means only vector scores.",
45
+ )
46
+
47
+
48
+ Ranker = Annotated[
49
+ RRFRanker | WeightedRanker,
50
+ Field(discriminator="type"),
51
+ ]
52
+
53
+
54
+ class RAGDocument(BaseModel):
55
+ """
56
+ A document to be used for document ingestion in the RAG Tool.
57
+
58
+ :param document_id: The unique identifier for the document.
59
+ :param content: The content of the document.
60
+ :param mime_type: The MIME type of the document.
61
+ :param metadata: Additional metadata for the document.
62
+ """
63
+
64
+ document_id: str
65
+ content: InterleavedContent | URL
66
+ mime_type: str | None = None
67
+ metadata: dict[str, Any] = Field(default_factory=dict)
68
+
69
+
70
+ class RAGQueryResult(BaseModel):
71
+ """Result of a RAG query containing retrieved content and metadata.
72
+
73
+ :param content: (Optional) The retrieved content from the query
74
+ :param metadata: Additional metadata about the query result
75
+ """
76
+
77
+ content: InterleavedContent | None = None
78
+ metadata: dict[str, Any] = Field(default_factory=dict)
79
+
80
+
81
+ class RAGQueryGenerator(Enum):
82
+ """Types of query generators for RAG systems.
83
+
84
+ :cvar default: Default query generator using simple text processing
85
+ :cvar llm: LLM-based query generator for enhanced query understanding
86
+ :cvar custom: Custom query generator implementation
87
+ """
88
+
89
+ default = "default"
90
+ llm = "llm"
91
+ custom = "custom"
92
+
93
+
94
+ class RAGSearchMode(StrEnum):
95
+ """
96
+ Search modes for RAG query retrieval:
97
+ - VECTOR: Uses vector similarity search for semantic matching
98
+ - KEYWORD: Uses keyword-based search for exact matching
99
+ - HYBRID: Combines both vector and keyword search for better results
100
+ """
101
+
102
+ VECTOR = "vector"
103
+ KEYWORD = "keyword"
104
+ HYBRID = "hybrid"
105
+
106
+
107
+ class DefaultRAGQueryGeneratorConfig(BaseModel):
108
+ """Configuration for the default RAG query generator.
109
+
110
+ :param type: Type of query generator, always 'default'
111
+ :param separator: String separator used to join query terms
112
+ """
113
+
114
+ type: Literal["default"] = "default"
115
+ separator: str = " "
116
+
117
+
118
+ class LLMRAGQueryGeneratorConfig(BaseModel):
119
+ """Configuration for the LLM-based RAG query generator.
120
+
121
+ :param type: Type of query generator, always 'llm'
122
+ :param model: Name of the language model to use for query generation
123
+ :param template: Template string for formatting the query generation prompt
124
+ """
125
+
126
+ type: Literal["llm"] = "llm"
127
+ model: str
128
+ template: str
129
+
130
+
131
+ RAGQueryGeneratorConfig = Annotated[
132
+ DefaultRAGQueryGeneratorConfig | LLMRAGQueryGeneratorConfig,
133
+ Field(discriminator="type"),
134
+ ]
135
+
136
+
137
+ class RAGQueryConfig(BaseModel):
138
+ """
139
+ Configuration for the RAG query generation.
140
+
141
+ :param query_generator_config: Configuration for the query generator.
142
+ :param max_tokens_in_context: Maximum number of tokens in the context.
143
+ :param max_chunks: Maximum number of chunks to retrieve.
144
+ :param chunk_template: Template for formatting each retrieved chunk in the context.
145
+ Available placeholders: {index} (1-based chunk ordinal), {chunk.content} (chunk content string), {metadata} (chunk metadata dict).
146
+ Default: "Result {index}\\nContent: {chunk.content}\\nMetadata: {metadata}\\n"
147
+ :param mode: Search mode for retrieval—either "vector", "keyword", or "hybrid". Default "vector".
148
+ :param ranker: Configuration for the ranker to use in hybrid search. Defaults to RRF ranker.
149
+ """
150
+
151
+ # This config defines how a query is generated using the messages
152
+ # for memory bank retrieval.
153
+ query_generator_config: RAGQueryGeneratorConfig = Field(default=DefaultRAGQueryGeneratorConfig())
154
+ max_tokens_in_context: int = 4096
155
+ max_chunks: int = 5
156
+ chunk_template: str = "Result {index}\nContent: {chunk.content}\nMetadata: {metadata}\n"
157
+ mode: RAGSearchMode | None = RAGSearchMode.VECTOR
158
+ ranker: Ranker | None = Field(default=None) # Only used for hybrid mode
159
+
160
+ @field_validator("chunk_template")
161
+ def validate_chunk_template(cls, v: str) -> str:
162
+ if "{chunk.content}" not in v:
163
+ raise ValueError("chunk_template must contain {chunk.content}")
164
+ if "{index}" not in v:
165
+ raise ValueError("chunk_template must contain {index}")
166
+ if len(v) == 0:
167
+ raise ValueError("chunk_template must not be empty")
168
+ return v
@@ -0,0 +1,37 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the terms described in the LICENSE file in
5
+ # the root directory of this source tree.
6
+
7
+ from enum import StrEnum
8
+
9
+ from pydantic import BaseModel, Field
10
+
11
+
12
+ class ResourceType(StrEnum):
13
+ model = "model"
14
+ shield = "shield"
15
+ vector_store = "vector_store"
16
+ dataset = "dataset"
17
+ scoring_function = "scoring_function"
18
+ benchmark = "benchmark"
19
+ tool = "tool"
20
+ tool_group = "tool_group"
21
+ prompt = "prompt"
22
+ connector = "connector"
23
+
24
+
25
+ class Resource(BaseModel):
26
+ """Base class for all Llama Stack resources"""
27
+
28
+ identifier: str = Field(description="Unique identifier for this resource in llama stack")
29
+
30
+ provider_resource_id: str | None = Field(
31
+ default=None,
32
+ description="Unique identifier for this resource in the provider",
33
+ )
34
+
35
+ provider_id: str = Field(description="ID of the provider that owns this resource")
36
+
37
+ type: ResourceType = Field(description="Type of resource (e.g. 'model', 'shield', 'vector_store', etc.)")
@@ -0,0 +1,160 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the terms described in the LICENSE file in
5
+ # the root directory of this source tree.
6
+
7
+ """Utilities for creating FastAPI routers with standard error responses.
8
+
9
+ This module provides standard error response definitions for FastAPI routers.
10
+ These responses use OpenAPI $ref references to component responses defined
11
+ in the OpenAPI specification.
12
+ """
13
+
14
+ import inspect
15
+ from collections.abc import Callable
16
+ from typing import Annotated, Any, TypeVar
17
+
18
+ from fastapi import Path, Query
19
+ from pydantic import BaseModel
20
+
21
+ # OpenAPI extension key to mark routes that don't require authentication.
22
+ # Use this in FastAPI route decorators: @router.get("/health", openapi_extra={PUBLIC_ROUTE_KEY: True})
23
+ PUBLIC_ROUTE_KEY = "x-public"
24
+
25
+
26
+ standard_responses: dict[int | str, dict[str, Any]] = {
27
+ 400: {"$ref": "#/components/responses/BadRequest400"},
28
+ 429: {"$ref": "#/components/responses/TooManyRequests429"},
29
+ 500: {"$ref": "#/components/responses/InternalServerError500"},
30
+ "default": {"$ref": "#/components/responses/DefaultError"},
31
+ }
32
+
33
+ T = TypeVar("T", bound=BaseModel)
34
+
35
+
36
+ def create_query_dependency[T: BaseModel](model_class: type[T]) -> Callable[..., T]:
37
+ """Create a FastAPI dependency function from a Pydantic model for query parameters.
38
+
39
+ FastAPI does not natively support using Pydantic models as query parameters
40
+ without a dependency function. Using a dependency function typically leads to
41
+ duplication: field types, default values, and descriptions must be repeated in
42
+ `Query(...)` annotations even though they already exist in the Pydantic model.
43
+
44
+ This function automatically generates a dependency function that extracts query parameters
45
+ from the request and constructs an instance of the Pydantic model. The descriptions and
46
+ defaults are automatically extracted from the model's Field definitions, making the model
47
+ the single source of truth.
48
+
49
+ Args:
50
+ model_class: The Pydantic model class to create a dependency for
51
+
52
+ Returns:
53
+ A dependency function that can be used with FastAPI's Depends()
54
+ ```
55
+ """
56
+ # Build function signature dynamically from model fields
57
+ annotations: dict[str, Any] = {}
58
+ defaults: dict[str, Any] = {}
59
+
60
+ for field_name, field_info in model_class.model_fields.items():
61
+ # Extract description from Field
62
+ description = field_info.description
63
+
64
+ # Create Query annotation with description from model
65
+ query_annotation = Query(description=description) if description else Query()
66
+
67
+ # Create Annotated type with Query
68
+ field_type = field_info.annotation
69
+ annotations[field_name] = Annotated[field_type, query_annotation]
70
+
71
+ # Set default value from model
72
+ if field_info.default is not inspect.Parameter.empty:
73
+ defaults[field_name] = field_info.default
74
+
75
+ # Create the dependency function dynamically
76
+ def dependency_func(**kwargs: Any) -> T:
77
+ return model_class(**kwargs)
78
+
79
+ # Set function signature
80
+ sig_params = []
81
+ for field_name, field_type in annotations.items():
82
+ default = defaults.get(field_name, inspect.Parameter.empty)
83
+ param = inspect.Parameter(
84
+ field_name,
85
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
86
+ default=default,
87
+ annotation=field_type,
88
+ )
89
+ sig_params.append(param)
90
+
91
+ # These attributes are set dynamically at runtime. While mypy can't verify them statically,
92
+ # they are standard Python function attributes that exist on all callable objects at runtime.
93
+ # Setting them allows FastAPI to properly introspect the function signature for dependency injection.
94
+ dependency_func.__signature__ = inspect.Signature(sig_params) # type: ignore[attr-defined]
95
+ dependency_func.__annotations__ = annotations # type: ignore[attr-defined]
96
+ dependency_func.__name__ = f"get_{model_class.__name__.lower()}_request" # type: ignore[attr-defined]
97
+
98
+ return dependency_func
99
+
100
+
101
+ def create_path_dependency[T: BaseModel](model_class: type[T]) -> Callable[..., T]:
102
+ """Create a FastAPI dependency function from a Pydantic model for path parameters.
103
+
104
+ FastAPI requires path parameters to be explicitly annotated with `Path()`. When using
105
+ a Pydantic model that contains path parameters, you typically need a dependency function
106
+ that extracts the path parameter and constructs the model. This leads to duplication:
107
+ the parameter name, type, and description must be repeated in `Path(...)` annotations
108
+ even though they already exist in the Pydantic model.
109
+
110
+ This function automatically generates a dependency function that extracts path parameters
111
+ from the request and constructs an instance of the Pydantic model. The descriptions are
112
+ automatically extracted from the model's Field definitions, making the model the single
113
+ source of truth.
114
+
115
+ Args:
116
+ model_class: The Pydantic model class to create a dependency for. The model should
117
+ have exactly one field that represents the path parameter.
118
+
119
+ Returns:
120
+ A dependency function that can be used with FastAPI's Depends()
121
+ ```
122
+ """
123
+ # Get the single field from the model (path parameter models typically have one field)
124
+ if len(model_class.model_fields) != 1:
125
+ raise ValueError(
126
+ f"Path parameter model {model_class.__name__} must have exactly one field, "
127
+ f"but has {len(model_class.model_fields)} fields"
128
+ )
129
+
130
+ field_name, field_info = next(iter(model_class.model_fields.items()))
131
+
132
+ # Extract description from Field
133
+ description = field_info.description
134
+
135
+ # Create Path annotation with description from model
136
+ path_annotation = Path(description=description) if description else Path()
137
+
138
+ # Create Annotated type with Path
139
+ field_type = field_info.annotation
140
+ annotations: dict[str, Any] = {field_name: Annotated[field_type, path_annotation]}
141
+
142
+ # Create the dependency function dynamically
143
+ def dependency_func(**kwargs: Any) -> T:
144
+ return model_class(**kwargs)
145
+
146
+ # Set function signature
147
+ param = inspect.Parameter(
148
+ field_name,
149
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
150
+ annotation=annotations[field_name],
151
+ )
152
+
153
+ # These attributes are set dynamically at runtime. While mypy can't verify them statically,
154
+ # they are standard Python function attributes that exist on all callable objects at runtime.
155
+ # Setting them allows FastAPI to properly introspect the function signature for dependency injection.
156
+ dependency_func.__signature__ = inspect.Signature([param]) # type: ignore[attr-defined]
157
+ dependency_func.__annotations__ = annotations # type: ignore[attr-defined]
158
+ dependency_func.__name__ = f"get_{model_class.__name__.lower()}_request" # type: ignore[attr-defined]
159
+
160
+ return dependency_func
@@ -0,0 +1,132 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the terms described in the LICENSE file in
5
+ # the root directory of this source tree.
6
+
7
+ from enum import Enum
8
+ from typing import Any, Protocol, runtime_checkable
9
+
10
+ from pydantic import BaseModel, Field
11
+
12
+ from llama_stack_api.inference import OpenAIMessageParam
13
+ from llama_stack_api.schema_utils import json_schema_type, webmethod
14
+ from llama_stack_api.shields import Shield
15
+ from llama_stack_api.version import LLAMA_STACK_API_V1
16
+
17
+
18
+ @json_schema_type
19
+ class ModerationObjectResults(BaseModel):
20
+ """A moderation object.
21
+ :param flagged: Whether any of the below categories are flagged.
22
+ :param categories: A list of the categories, and whether they are flagged or not.
23
+ :param category_applied_input_types: A list of the categories along with the input type(s) that the score applies to.
24
+ :param category_scores: A list of the categories along with their scores as predicted by model.
25
+ """
26
+
27
+ flagged: bool
28
+ categories: dict[str, bool] | None = None
29
+ category_applied_input_types: dict[str, list[str]] | None = None
30
+ category_scores: dict[str, float] | None = None
31
+ user_message: str | None = None
32
+ metadata: dict[str, Any] = Field(default_factory=dict)
33
+
34
+
35
+ @json_schema_type
36
+ class ModerationObject(BaseModel):
37
+ """A moderation object.
38
+ :param id: The unique identifier for the moderation request.
39
+ :param model: The model used to generate the moderation results.
40
+ :param results: A list of moderation objects
41
+ """
42
+
43
+ id: str
44
+ model: str
45
+ results: list[ModerationObjectResults]
46
+
47
+
48
+ @json_schema_type
49
+ class ViolationLevel(Enum):
50
+ """Severity level of a safety violation.
51
+
52
+ :cvar INFO: Informational level violation that does not require action
53
+ :cvar WARN: Warning level violation that suggests caution but allows continuation
54
+ :cvar ERROR: Error level violation that requires blocking or intervention
55
+ """
56
+
57
+ INFO = "info"
58
+ WARN = "warn"
59
+ ERROR = "error"
60
+
61
+
62
+ @json_schema_type
63
+ class SafetyViolation(BaseModel):
64
+ """Details of a safety violation detected by content moderation.
65
+
66
+ :param violation_level: Severity level of the violation
67
+ :param user_message: (Optional) Message to convey to the user about the violation
68
+ :param metadata: Additional metadata including specific violation codes for debugging and telemetry
69
+ """
70
+
71
+ violation_level: ViolationLevel
72
+
73
+ # what message should you convey to the user
74
+ user_message: str | None = None
75
+
76
+ # additional metadata (including specific violation codes) more for
77
+ # debugging, telemetry
78
+ metadata: dict[str, Any] = Field(default_factory=dict)
79
+
80
+
81
+ @json_schema_type
82
+ class RunShieldResponse(BaseModel):
83
+ """Response from running a safety shield.
84
+
85
+ :param violation: (Optional) Safety violation detected by the shield, if any
86
+ """
87
+
88
+ violation: SafetyViolation | None = None
89
+
90
+
91
+ class ShieldStore(Protocol):
92
+ async def get_shield(self, identifier: str) -> Shield: ...
93
+
94
+
95
+ @runtime_checkable
96
+ class Safety(Protocol):
97
+ """Safety
98
+
99
+ OpenAI-compatible Moderations API.
100
+ """
101
+
102
+ shield_store: ShieldStore
103
+
104
+ @webmethod(route="/safety/run-shield", method="POST", level=LLAMA_STACK_API_V1)
105
+ async def run_shield(
106
+ self,
107
+ shield_id: str,
108
+ messages: list[OpenAIMessageParam],
109
+ params: dict[str, Any],
110
+ ) -> RunShieldResponse:
111
+ """Run shield.
112
+
113
+ Run a shield.
114
+
115
+ :param shield_id: The identifier of the shield to run.
116
+ :param messages: The messages to run the shield on.
117
+ :param params: The parameters of the shield.
118
+ :returns: A RunShieldResponse.
119
+ """
120
+ ...
121
+
122
+ @webmethod(route="/moderations", method="POST", level=LLAMA_STACK_API_V1)
123
+ async def run_moderation(self, input: str | list[str], model: str | None = None) -> ModerationObject:
124
+ """Create moderation.
125
+
126
+ Classifies if text and/or image inputs are potentially harmful.
127
+ :param input: Input (or inputs) to classify.
128
+ Can be a single string, an array of strings, or an array of multi-modal input objects similar to other models.
129
+ :param model: (Optional) The content moderation model you would like to use.
130
+ :returns: A moderation object.
131
+ """
132
+ ...