llama-stack-api 0.4.3__py3-none-any.whl → 0.5.0rc1__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.
- llama_stack_api/__init__.py +1100 -0
- llama_stack_api/admin/__init__.py +45 -0
- llama_stack_api/admin/api.py +72 -0
- llama_stack_api/admin/fastapi_routes.py +117 -0
- llama_stack_api/admin/models.py +113 -0
- llama_stack_api/agents/__init__.py +38 -0
- llama_stack_api/agents/api.py +52 -0
- llama_stack_api/agents/fastapi_routes.py +268 -0
- llama_stack_api/agents/models.py +181 -0
- llama_stack_api/batches/__init__.py +40 -0
- llama_stack_api/batches/api.py +53 -0
- llama_stack_api/batches/fastapi_routes.py +113 -0
- llama_stack_api/batches/models.py +78 -0
- llama_stack_api/benchmarks/__init__.py +43 -0
- llama_stack_api/benchmarks/api.py +39 -0
- llama_stack_api/benchmarks/fastapi_routes.py +109 -0
- llama_stack_api/benchmarks/models.py +109 -0
- llama_stack_api/common/__init__.py +5 -0
- llama_stack_api/common/content_types.py +101 -0
- llama_stack_api/common/errors.py +110 -0
- llama_stack_api/common/job_types.py +38 -0
- llama_stack_api/common/responses.py +77 -0
- llama_stack_api/common/training_types.py +47 -0
- llama_stack_api/common/type_system.py +146 -0
- llama_stack_api/connectors/__init__.py +38 -0
- llama_stack_api/connectors/api.py +50 -0
- llama_stack_api/connectors/fastapi_routes.py +103 -0
- llama_stack_api/connectors/models.py +103 -0
- llama_stack_api/conversations/__init__.py +61 -0
- llama_stack_api/conversations/api.py +44 -0
- llama_stack_api/conversations/fastapi_routes.py +177 -0
- llama_stack_api/conversations/models.py +245 -0
- llama_stack_api/datasetio/__init__.py +34 -0
- llama_stack_api/datasetio/api.py +42 -0
- llama_stack_api/datasetio/fastapi_routes.py +94 -0
- llama_stack_api/datasetio/models.py +48 -0
- llama_stack_api/datasets/__init__.py +61 -0
- llama_stack_api/datasets/api.py +35 -0
- llama_stack_api/datasets/fastapi_routes.py +104 -0
- llama_stack_api/datasets/models.py +152 -0
- llama_stack_api/datatypes.py +373 -0
- llama_stack_api/eval/__init__.py +55 -0
- llama_stack_api/eval/api.py +51 -0
- llama_stack_api/eval/compat.py +300 -0
- llama_stack_api/eval/fastapi_routes.py +126 -0
- llama_stack_api/eval/models.py +141 -0
- llama_stack_api/file_processors/__init__.py +27 -0
- llama_stack_api/file_processors/api.py +64 -0
- llama_stack_api/file_processors/fastapi_routes.py +78 -0
- llama_stack_api/file_processors/models.py +42 -0
- llama_stack_api/files/__init__.py +35 -0
- llama_stack_api/files/api.py +51 -0
- llama_stack_api/files/fastapi_routes.py +124 -0
- llama_stack_api/files/models.py +107 -0
- llama_stack_api/inference/__init__.py +207 -0
- llama_stack_api/inference/api.py +93 -0
- llama_stack_api/inference/fastapi_routes.py +243 -0
- llama_stack_api/inference/models.py +1035 -0
- llama_stack_api/inspect_api/__init__.py +37 -0
- llama_stack_api/inspect_api/api.py +25 -0
- llama_stack_api/inspect_api/fastapi_routes.py +76 -0
- llama_stack_api/inspect_api/models.py +28 -0
- llama_stack_api/internal/__init__.py +9 -0
- llama_stack_api/internal/kvstore.py +28 -0
- llama_stack_api/internal/sqlstore.py +81 -0
- llama_stack_api/models/__init__.py +47 -0
- llama_stack_api/models/api.py +38 -0
- llama_stack_api/models/fastapi_routes.py +104 -0
- llama_stack_api/models/models.py +157 -0
- llama_stack_api/openai_responses.py +1494 -0
- llama_stack_api/post_training/__init__.py +73 -0
- llama_stack_api/post_training/api.py +36 -0
- llama_stack_api/post_training/fastapi_routes.py +116 -0
- llama_stack_api/post_training/models.py +339 -0
- llama_stack_api/prompts/__init__.py +47 -0
- llama_stack_api/prompts/api.py +44 -0
- llama_stack_api/prompts/fastapi_routes.py +163 -0
- llama_stack_api/prompts/models.py +177 -0
- llama_stack_api/providers/__init__.py +33 -0
- llama_stack_api/providers/api.py +16 -0
- llama_stack_api/providers/fastapi_routes.py +57 -0
- llama_stack_api/providers/models.py +24 -0
- llama_stack_api/rag_tool.py +168 -0
- llama_stack_api/resource.py +36 -0
- llama_stack_api/router_utils.py +160 -0
- llama_stack_api/safety/__init__.py +37 -0
- llama_stack_api/safety/api.py +29 -0
- llama_stack_api/safety/datatypes.py +83 -0
- llama_stack_api/safety/fastapi_routes.py +55 -0
- llama_stack_api/safety/models.py +38 -0
- llama_stack_api/schema_utils.py +251 -0
- llama_stack_api/scoring/__init__.py +66 -0
- llama_stack_api/scoring/api.py +35 -0
- llama_stack_api/scoring/fastapi_routes.py +67 -0
- llama_stack_api/scoring/models.py +81 -0
- llama_stack_api/scoring_functions/__init__.py +50 -0
- llama_stack_api/scoring_functions/api.py +39 -0
- llama_stack_api/scoring_functions/fastapi_routes.py +108 -0
- llama_stack_api/scoring_functions/models.py +214 -0
- llama_stack_api/shields/__init__.py +41 -0
- llama_stack_api/shields/api.py +39 -0
- llama_stack_api/shields/fastapi_routes.py +104 -0
- llama_stack_api/shields/models.py +74 -0
- llama_stack_api/tools.py +226 -0
- llama_stack_api/validators.py +46 -0
- llama_stack_api/vector_io/__init__.py +88 -0
- llama_stack_api/vector_io/api.py +234 -0
- llama_stack_api/vector_io/fastapi_routes.py +447 -0
- llama_stack_api/vector_io/models.py +663 -0
- llama_stack_api/vector_stores.py +53 -0
- llama_stack_api/version.py +9 -0
- {llama_stack_api-0.4.3.dist-info → llama_stack_api-0.5.0rc1.dist-info}/METADATA +1 -1
- llama_stack_api-0.5.0rc1.dist-info/RECORD +115 -0
- llama_stack_api-0.5.0rc1.dist-info/top_level.txt +1 -0
- llama_stack_api-0.4.3.dist-info/RECORD +0 -4
- llama_stack_api-0.4.3.dist-info/top_level.txt +0 -1
- {llama_stack_api-0.4.3.dist-info → llama_stack_api-0.5.0rc1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,373 @@
|
|
|
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, EnumMeta, StrEnum
|
|
8
|
+
from typing import Any, Protocol
|
|
9
|
+
from urllib.parse import urlparse
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel, Field
|
|
12
|
+
|
|
13
|
+
from llama_stack_api.benchmarks import Benchmark
|
|
14
|
+
from llama_stack_api.datasets import Dataset
|
|
15
|
+
from llama_stack_api.models import Model
|
|
16
|
+
from llama_stack_api.schema_utils import json_schema_type
|
|
17
|
+
from llama_stack_api.scoring_functions import ScoringFn
|
|
18
|
+
from llama_stack_api.shields import Shield
|
|
19
|
+
from llama_stack_api.tools import ToolGroup
|
|
20
|
+
from llama_stack_api.vector_stores import VectorStore
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DynamicApiMeta(EnumMeta):
|
|
24
|
+
def __new__(cls, name, bases, namespace):
|
|
25
|
+
# Store the original enum values
|
|
26
|
+
original_values = {k: v for k, v in namespace.items() if not k.startswith("_")}
|
|
27
|
+
|
|
28
|
+
# Create the enum class
|
|
29
|
+
cls = super().__new__(cls, name, bases, namespace)
|
|
30
|
+
|
|
31
|
+
# Store the original values for reference
|
|
32
|
+
cls._original_values = original_values
|
|
33
|
+
# Initialize _dynamic_values
|
|
34
|
+
cls._dynamic_values = {}
|
|
35
|
+
|
|
36
|
+
return cls
|
|
37
|
+
|
|
38
|
+
def __call__(cls, value):
|
|
39
|
+
try:
|
|
40
|
+
return super().__call__(value)
|
|
41
|
+
except ValueError as e:
|
|
42
|
+
# If this value was already dynamically added, return it
|
|
43
|
+
if value in cls._dynamic_values:
|
|
44
|
+
return cls._dynamic_values[value]
|
|
45
|
+
|
|
46
|
+
# If the value doesn't exist, create a new enum member
|
|
47
|
+
# Create a new member name from the value
|
|
48
|
+
member_name = value.lower().replace("-", "_")
|
|
49
|
+
|
|
50
|
+
# If this member name already exists in the enum, return the existing member
|
|
51
|
+
if member_name in cls._member_map_:
|
|
52
|
+
return cls._member_map_[member_name]
|
|
53
|
+
|
|
54
|
+
# Instead of creating a new member, raise ValueError to force users to use Api.add() to
|
|
55
|
+
# register new APIs explicitly
|
|
56
|
+
raise ValueError(f"API '{value}' does not exist. Use Api.add() to register new APIs.") from e
|
|
57
|
+
|
|
58
|
+
def __iter__(cls):
|
|
59
|
+
# Allow iteration over both static and dynamic members
|
|
60
|
+
yield from super().__iter__()
|
|
61
|
+
if hasattr(cls, "_dynamic_values"):
|
|
62
|
+
yield from cls._dynamic_values.values()
|
|
63
|
+
|
|
64
|
+
def add(cls, value):
|
|
65
|
+
"""
|
|
66
|
+
Add a new API to the enum.
|
|
67
|
+
Used to register external APIs.
|
|
68
|
+
"""
|
|
69
|
+
member_name = value.lower().replace("-", "_")
|
|
70
|
+
|
|
71
|
+
# If this member name already exists in the enum, return it
|
|
72
|
+
if member_name in cls._member_map_:
|
|
73
|
+
return cls._member_map_[member_name]
|
|
74
|
+
|
|
75
|
+
# Create a new enum member
|
|
76
|
+
member = object.__new__(cls)
|
|
77
|
+
member._name_ = member_name
|
|
78
|
+
member._value_ = value
|
|
79
|
+
|
|
80
|
+
# Add it to the enum class
|
|
81
|
+
cls._member_map_[member_name] = member
|
|
82
|
+
cls._member_names_.append(member_name)
|
|
83
|
+
cls._member_type_ = str
|
|
84
|
+
|
|
85
|
+
# Store it in our dynamic values
|
|
86
|
+
cls._dynamic_values[value] = member
|
|
87
|
+
|
|
88
|
+
return member
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@json_schema_type
|
|
92
|
+
class Api(Enum, metaclass=DynamicApiMeta):
|
|
93
|
+
"""Enumeration of all available APIs in the Llama Stack system.
|
|
94
|
+
:cvar providers: Provider management and configuration
|
|
95
|
+
:cvar inference: Text generation, chat completions, and embeddings
|
|
96
|
+
:cvar safety: Content moderation and safety shields
|
|
97
|
+
:cvar agents: Agent orchestration and execution
|
|
98
|
+
:cvar batches: Batch processing for asynchronous API requests
|
|
99
|
+
:cvar vector_io: Vector database operations and queries
|
|
100
|
+
:cvar datasetio: Dataset input/output operations
|
|
101
|
+
:cvar scoring: Model output evaluation and scoring
|
|
102
|
+
:cvar eval: Model evaluation and benchmarking framework
|
|
103
|
+
:cvar post_training: Fine-tuning and model training
|
|
104
|
+
:cvar tool_runtime: Tool execution and management
|
|
105
|
+
:cvar telemetry: Observability and system monitoring
|
|
106
|
+
:cvar models: Model metadata and management
|
|
107
|
+
:cvar shields: Safety shield implementations
|
|
108
|
+
:cvar datasets: Dataset creation and management
|
|
109
|
+
:cvar scoring_functions: Scoring function definitions
|
|
110
|
+
:cvar benchmarks: Benchmark suite management
|
|
111
|
+
:cvar tool_groups: Tool group organization
|
|
112
|
+
:cvar files: File storage and management
|
|
113
|
+
:cvar file_processors: File parsing and processing operations
|
|
114
|
+
:cvar prompts: Prompt versions and management
|
|
115
|
+
:cvar connectors: External connector management (e.g., MCP servers)
|
|
116
|
+
:cvar inspect: Built-in system inspection and introspection
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
providers = "providers"
|
|
120
|
+
inference = "inference"
|
|
121
|
+
safety = "safety"
|
|
122
|
+
agents = "agents"
|
|
123
|
+
batches = "batches"
|
|
124
|
+
vector_io = "vector_io"
|
|
125
|
+
datasetio = "datasetio"
|
|
126
|
+
scoring = "scoring"
|
|
127
|
+
eval = "eval"
|
|
128
|
+
post_training = "post_training"
|
|
129
|
+
tool_runtime = "tool_runtime"
|
|
130
|
+
|
|
131
|
+
models = "models"
|
|
132
|
+
shields = "shields"
|
|
133
|
+
vector_stores = "vector_stores" # only used for routing table
|
|
134
|
+
datasets = "datasets"
|
|
135
|
+
scoring_functions = "scoring_functions"
|
|
136
|
+
benchmarks = "benchmarks"
|
|
137
|
+
tool_groups = "tool_groups"
|
|
138
|
+
files = "files"
|
|
139
|
+
file_processors = "file_processors"
|
|
140
|
+
prompts = "prompts"
|
|
141
|
+
conversations = "conversations"
|
|
142
|
+
connectors = "connectors"
|
|
143
|
+
|
|
144
|
+
# built-in API
|
|
145
|
+
inspect = "inspect"
|
|
146
|
+
admin = "admin"
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@json_schema_type
|
|
150
|
+
class Error(BaseModel):
|
|
151
|
+
"""
|
|
152
|
+
Error response from the API. Roughly follows RFC 7807.
|
|
153
|
+
|
|
154
|
+
:param status: HTTP status code
|
|
155
|
+
:param title: Error title, a short summary of the error which is invariant for an error type
|
|
156
|
+
:param detail: Error detail, a longer human-readable description of the error
|
|
157
|
+
:param instance: (Optional) A URL which can be used to retrieve more information about the specific occurrence of the error
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
status: int
|
|
161
|
+
title: str
|
|
162
|
+
detail: str
|
|
163
|
+
instance: str | None = None
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class ExternalApiSpec(BaseModel):
|
|
167
|
+
"""Specification for an external API implementation."""
|
|
168
|
+
|
|
169
|
+
module: str = Field(..., description="Python module containing the API implementation")
|
|
170
|
+
name: str = Field(..., description="Name of the API")
|
|
171
|
+
pip_packages: list[str] = Field(default=[], description="List of pip packages to install the API")
|
|
172
|
+
protocol: str = Field(..., description="Name of the protocol class for the API")
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
# Provider-related types (merged from providers/datatypes.py)
|
|
176
|
+
# NOTE: These imports are forward references to avoid circular dependencies
|
|
177
|
+
# They will be resolved at runtime when the classes are used
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class ModelsProtocolPrivate(Protocol):
|
|
181
|
+
"""
|
|
182
|
+
Protocol for model management.
|
|
183
|
+
|
|
184
|
+
This allows users to register their preferred model identifiers.
|
|
185
|
+
|
|
186
|
+
Model registration requires -
|
|
187
|
+
- a provider, used to route the registration request
|
|
188
|
+
- a model identifier, user's intended name for the model during inference
|
|
189
|
+
- a provider model identifier, a model identifier supported by the provider
|
|
190
|
+
|
|
191
|
+
Providers will only accept registration for provider model ids they support.
|
|
192
|
+
|
|
193
|
+
Example,
|
|
194
|
+
register: provider x my-model-id x provider-model-id
|
|
195
|
+
-> Error if provider does not support provider-model-id
|
|
196
|
+
-> Error if my-model-id is already registered
|
|
197
|
+
-> Success if provider supports provider-model-id
|
|
198
|
+
inference: my-model-id x ...
|
|
199
|
+
-> Provider uses provider-model-id for inference
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
# this should be called `on_model_register` or something like that.
|
|
203
|
+
# the provider should _not_ be able to change the object in this
|
|
204
|
+
# callback
|
|
205
|
+
async def register_model(self, model: Model) -> Model: ...
|
|
206
|
+
|
|
207
|
+
async def unregister_model(self, model_id: str) -> None: ...
|
|
208
|
+
|
|
209
|
+
# the Stack router will query each provider for their list of models
|
|
210
|
+
# if a `refresh_interval_seconds` is provided, this method will be called
|
|
211
|
+
# periodically to refresh the list of models
|
|
212
|
+
#
|
|
213
|
+
# NOTE: each model returned will be registered with the model registry. this means
|
|
214
|
+
# a callback to the `register_model()` method will be made. this is duplicative and
|
|
215
|
+
# may be removed in the future.
|
|
216
|
+
async def list_models(self) -> list[Model] | None: ...
|
|
217
|
+
|
|
218
|
+
async def should_refresh_models(self) -> bool: ...
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class ShieldsProtocolPrivate(Protocol):
|
|
222
|
+
async def register_shield(self, shield: Shield) -> None: ...
|
|
223
|
+
|
|
224
|
+
async def unregister_shield(self, identifier: str) -> None: ...
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class VectorStoresProtocolPrivate(Protocol):
|
|
228
|
+
async def register_vector_store(self, vector_store: VectorStore) -> None: ...
|
|
229
|
+
|
|
230
|
+
async def unregister_vector_store(self, vector_store_id: str) -> None: ...
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class DatasetsProtocolPrivate(Protocol):
|
|
234
|
+
async def register_dataset(self, dataset: Dataset) -> None: ...
|
|
235
|
+
|
|
236
|
+
async def unregister_dataset(self, dataset_id: str) -> None: ...
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class ScoringFunctionsProtocolPrivate(Protocol):
|
|
240
|
+
async def list_scoring_functions(self) -> list[ScoringFn]: ...
|
|
241
|
+
|
|
242
|
+
async def register_scoring_function(self, scoring_fn: ScoringFn) -> None: ...
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class BenchmarksProtocolPrivate(Protocol):
|
|
246
|
+
async def register_benchmark(self, benchmark: Benchmark) -> None: ...
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class ToolGroupsProtocolPrivate(Protocol):
|
|
250
|
+
async def register_toolgroup(self, toolgroup: ToolGroup) -> None: ...
|
|
251
|
+
|
|
252
|
+
async def unregister_toolgroup(self, toolgroup_id: str) -> None: ...
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@json_schema_type
|
|
256
|
+
class ProviderSpec(BaseModel):
|
|
257
|
+
api: Api
|
|
258
|
+
provider_type: str
|
|
259
|
+
config_class: str = Field(
|
|
260
|
+
...,
|
|
261
|
+
description="Fully-qualified classname of the config for this provider",
|
|
262
|
+
)
|
|
263
|
+
api_dependencies: list[Api] = Field(
|
|
264
|
+
default_factory=list,
|
|
265
|
+
description="Higher-level API surfaces may depend on other providers to provide their functionality",
|
|
266
|
+
)
|
|
267
|
+
optional_api_dependencies: list[Api] = Field(
|
|
268
|
+
default_factory=list,
|
|
269
|
+
)
|
|
270
|
+
deprecation_warning: str | None = Field(
|
|
271
|
+
default=None,
|
|
272
|
+
description="If this provider is deprecated, specify the warning message here",
|
|
273
|
+
)
|
|
274
|
+
deprecation_error: str | None = Field(
|
|
275
|
+
default=None,
|
|
276
|
+
description="If this provider is deprecated and does NOT work, specify the error message here",
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
module: str | None = Field(
|
|
280
|
+
default=None,
|
|
281
|
+
description="""
|
|
282
|
+
Fully-qualified name of the module to import. The module is expected to have:
|
|
283
|
+
|
|
284
|
+
- `get_adapter_impl(config, deps)`: returns the adapter implementation
|
|
285
|
+
|
|
286
|
+
Example: `module: ramalama_stack`
|
|
287
|
+
""",
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
pip_packages: list[str] = Field(
|
|
291
|
+
default_factory=list,
|
|
292
|
+
description="The pip dependencies needed for this implementation",
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
provider_data_validator: str | None = Field(
|
|
296
|
+
default=None,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
is_external: bool = Field(default=False, description="Notes whether this provider is an external provider.")
|
|
300
|
+
|
|
301
|
+
# used internally by the resolver; this is a hack for now
|
|
302
|
+
deps__: list[str] = Field(default_factory=list)
|
|
303
|
+
|
|
304
|
+
@property
|
|
305
|
+
def is_sample(self) -> bool:
|
|
306
|
+
return self.provider_type in ("sample", "remote::sample")
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class RoutingTable(Protocol):
|
|
310
|
+
async def get_provider_impl(self, routing_key: str) -> Any: ...
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
@json_schema_type
|
|
314
|
+
class InlineProviderSpec(ProviderSpec):
|
|
315
|
+
container_image: str | None = Field(
|
|
316
|
+
default=None,
|
|
317
|
+
description="""
|
|
318
|
+
The container image to use for this implementation. If one is provided, pip_packages will be ignored.
|
|
319
|
+
If a provider depends on other providers, the dependencies MUST NOT specify a container image.
|
|
320
|
+
""",
|
|
321
|
+
)
|
|
322
|
+
description: str | None = Field(
|
|
323
|
+
default=None,
|
|
324
|
+
description="""
|
|
325
|
+
A description of the provider. This is used to display in the documentation.
|
|
326
|
+
""",
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class RemoteProviderConfig(BaseModel):
|
|
331
|
+
host: str = "localhost"
|
|
332
|
+
port: int | None = None
|
|
333
|
+
protocol: str = "http"
|
|
334
|
+
|
|
335
|
+
@property
|
|
336
|
+
def url(self) -> str:
|
|
337
|
+
if self.port is None:
|
|
338
|
+
return f"{self.protocol}://{self.host}"
|
|
339
|
+
return f"{self.protocol}://{self.host}:{self.port}"
|
|
340
|
+
|
|
341
|
+
@classmethod
|
|
342
|
+
def from_url(cls, url: str) -> "RemoteProviderConfig":
|
|
343
|
+
parsed = urlparse(url)
|
|
344
|
+
attrs = {k: v for k, v in parsed._asdict().items() if v is not None}
|
|
345
|
+
return cls(**attrs)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
@json_schema_type
|
|
349
|
+
class RemoteProviderSpec(ProviderSpec):
|
|
350
|
+
adapter_type: str = Field(
|
|
351
|
+
...,
|
|
352
|
+
description="Unique identifier for this adapter",
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
description: str | None = Field(
|
|
356
|
+
default=None,
|
|
357
|
+
description="""
|
|
358
|
+
A description of the provider. This is used to display in the documentation.
|
|
359
|
+
""",
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
@property
|
|
363
|
+
def container_image(self) -> str | None:
|
|
364
|
+
return None
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class HealthStatus(StrEnum):
|
|
368
|
+
OK = "OK"
|
|
369
|
+
ERROR = "Error"
|
|
370
|
+
NOT_IMPLEMENTED = "Not Implemented"
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
HealthResponse = dict[str, Any]
|
|
@@ -0,0 +1,55 @@
|
|
|
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 llama_stack_api.common.job_types import Job
|
|
8
|
+
|
|
9
|
+
from . import fastapi_routes
|
|
10
|
+
from .api import Eval
|
|
11
|
+
from .compat import (
|
|
12
|
+
resolve_evaluate_rows_request,
|
|
13
|
+
resolve_job_cancel_request,
|
|
14
|
+
resolve_job_result_request,
|
|
15
|
+
resolve_job_status_request,
|
|
16
|
+
resolve_run_eval_request,
|
|
17
|
+
)
|
|
18
|
+
from .models import (
|
|
19
|
+
BenchmarkConfig,
|
|
20
|
+
BenchmarkIdRequest,
|
|
21
|
+
EvalCandidate,
|
|
22
|
+
EvaluateResponse,
|
|
23
|
+
EvaluateRowsBodyRequest,
|
|
24
|
+
EvaluateRowsRequest,
|
|
25
|
+
JobCancelRequest,
|
|
26
|
+
JobResultRequest,
|
|
27
|
+
JobStatusRequest,
|
|
28
|
+
ModelCandidate,
|
|
29
|
+
RunEvalBodyRequest,
|
|
30
|
+
RunEvalRequest,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
"Eval",
|
|
35
|
+
"BenchmarkConfig",
|
|
36
|
+
"BenchmarkIdRequest",
|
|
37
|
+
"EvalCandidate",
|
|
38
|
+
"EvaluateResponse",
|
|
39
|
+
"EvaluateRowsBodyRequest",
|
|
40
|
+
"EvaluateRowsRequest",
|
|
41
|
+
"Job",
|
|
42
|
+
"JobCancelRequest",
|
|
43
|
+
"JobResultRequest",
|
|
44
|
+
"JobStatusRequest",
|
|
45
|
+
"ModelCandidate",
|
|
46
|
+
"RunEvalBodyRequest",
|
|
47
|
+
"RunEvalRequest",
|
|
48
|
+
"fastapi_routes",
|
|
49
|
+
# Backward compatibility helpers
|
|
50
|
+
"resolve_run_eval_request",
|
|
51
|
+
"resolve_evaluate_rows_request",
|
|
52
|
+
"resolve_job_status_request",
|
|
53
|
+
"resolve_job_cancel_request",
|
|
54
|
+
"resolve_job_result_request",
|
|
55
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
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 typing import Protocol, runtime_checkable
|
|
8
|
+
|
|
9
|
+
from llama_stack_api.common.job_types import Job
|
|
10
|
+
|
|
11
|
+
from .models import (
|
|
12
|
+
EvaluateResponse,
|
|
13
|
+
EvaluateRowsRequest,
|
|
14
|
+
JobCancelRequest,
|
|
15
|
+
JobResultRequest,
|
|
16
|
+
JobStatusRequest,
|
|
17
|
+
RunEvalRequest,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@runtime_checkable
|
|
22
|
+
class Eval(Protocol):
|
|
23
|
+
"""Evaluations
|
|
24
|
+
|
|
25
|
+
Llama Stack Evaluation API for running evaluations on model and agent candidates."""
|
|
26
|
+
|
|
27
|
+
async def run_eval(
|
|
28
|
+
self,
|
|
29
|
+
request: RunEvalRequest,
|
|
30
|
+
) -> Job:
|
|
31
|
+
"""Run an evaluation on a benchmark."""
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
async def evaluate_rows(
|
|
35
|
+
self,
|
|
36
|
+
request: EvaluateRowsRequest,
|
|
37
|
+
) -> EvaluateResponse:
|
|
38
|
+
"""Evaluate a list of rows on a benchmark."""
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
async def job_status(self, request: JobStatusRequest) -> Job:
|
|
42
|
+
"""Get the status of a job."""
|
|
43
|
+
...
|
|
44
|
+
|
|
45
|
+
async def job_cancel(self, request: JobCancelRequest) -> None:
|
|
46
|
+
"""Cancel a job."""
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
async def job_result(self, request: JobResultRequest) -> EvaluateResponse:
|
|
50
|
+
"""Get the result of a job."""
|
|
51
|
+
...
|