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.
Files changed (117) hide show
  1. llama_stack_api/__init__.py +1100 -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/__init__.py +38 -0
  7. llama_stack_api/agents/api.py +52 -0
  8. llama_stack_api/agents/fastapi_routes.py +268 -0
  9. llama_stack_api/agents/models.py +181 -0
  10. llama_stack_api/batches/__init__.py +40 -0
  11. llama_stack_api/batches/api.py +53 -0
  12. llama_stack_api/batches/fastapi_routes.py +113 -0
  13. llama_stack_api/batches/models.py +78 -0
  14. llama_stack_api/benchmarks/__init__.py +43 -0
  15. llama_stack_api/benchmarks/api.py +39 -0
  16. llama_stack_api/benchmarks/fastapi_routes.py +109 -0
  17. llama_stack_api/benchmarks/models.py +109 -0
  18. llama_stack_api/common/__init__.py +5 -0
  19. llama_stack_api/common/content_types.py +101 -0
  20. llama_stack_api/common/errors.py +110 -0
  21. llama_stack_api/common/job_types.py +38 -0
  22. llama_stack_api/common/responses.py +77 -0
  23. llama_stack_api/common/training_types.py +47 -0
  24. llama_stack_api/common/type_system.py +146 -0
  25. llama_stack_api/connectors/__init__.py +38 -0
  26. llama_stack_api/connectors/api.py +50 -0
  27. llama_stack_api/connectors/fastapi_routes.py +103 -0
  28. llama_stack_api/connectors/models.py +103 -0
  29. llama_stack_api/conversations/__init__.py +61 -0
  30. llama_stack_api/conversations/api.py +44 -0
  31. llama_stack_api/conversations/fastapi_routes.py +177 -0
  32. llama_stack_api/conversations/models.py +245 -0
  33. llama_stack_api/datasetio/__init__.py +34 -0
  34. llama_stack_api/datasetio/api.py +42 -0
  35. llama_stack_api/datasetio/fastapi_routes.py +94 -0
  36. llama_stack_api/datasetio/models.py +48 -0
  37. llama_stack_api/datasets/__init__.py +61 -0
  38. llama_stack_api/datasets/api.py +35 -0
  39. llama_stack_api/datasets/fastapi_routes.py +104 -0
  40. llama_stack_api/datasets/models.py +152 -0
  41. llama_stack_api/datatypes.py +373 -0
  42. llama_stack_api/eval/__init__.py +55 -0
  43. llama_stack_api/eval/api.py +51 -0
  44. llama_stack_api/eval/compat.py +300 -0
  45. llama_stack_api/eval/fastapi_routes.py +126 -0
  46. llama_stack_api/eval/models.py +141 -0
  47. llama_stack_api/file_processors/__init__.py +27 -0
  48. llama_stack_api/file_processors/api.py +64 -0
  49. llama_stack_api/file_processors/fastapi_routes.py +78 -0
  50. llama_stack_api/file_processors/models.py +42 -0
  51. llama_stack_api/files/__init__.py +35 -0
  52. llama_stack_api/files/api.py +51 -0
  53. llama_stack_api/files/fastapi_routes.py +124 -0
  54. llama_stack_api/files/models.py +107 -0
  55. llama_stack_api/inference/__init__.py +207 -0
  56. llama_stack_api/inference/api.py +93 -0
  57. llama_stack_api/inference/fastapi_routes.py +243 -0
  58. llama_stack_api/inference/models.py +1035 -0
  59. llama_stack_api/inspect_api/__init__.py +37 -0
  60. llama_stack_api/inspect_api/api.py +25 -0
  61. llama_stack_api/inspect_api/fastapi_routes.py +76 -0
  62. llama_stack_api/inspect_api/models.py +28 -0
  63. llama_stack_api/internal/__init__.py +9 -0
  64. llama_stack_api/internal/kvstore.py +28 -0
  65. llama_stack_api/internal/sqlstore.py +81 -0
  66. llama_stack_api/models/__init__.py +47 -0
  67. llama_stack_api/models/api.py +38 -0
  68. llama_stack_api/models/fastapi_routes.py +104 -0
  69. llama_stack_api/models/models.py +157 -0
  70. llama_stack_api/openai_responses.py +1494 -0
  71. llama_stack_api/post_training/__init__.py +73 -0
  72. llama_stack_api/post_training/api.py +36 -0
  73. llama_stack_api/post_training/fastapi_routes.py +116 -0
  74. llama_stack_api/post_training/models.py +339 -0
  75. llama_stack_api/prompts/__init__.py +47 -0
  76. llama_stack_api/prompts/api.py +44 -0
  77. llama_stack_api/prompts/fastapi_routes.py +163 -0
  78. llama_stack_api/prompts/models.py +177 -0
  79. llama_stack_api/providers/__init__.py +33 -0
  80. llama_stack_api/providers/api.py +16 -0
  81. llama_stack_api/providers/fastapi_routes.py +57 -0
  82. llama_stack_api/providers/models.py +24 -0
  83. llama_stack_api/rag_tool.py +168 -0
  84. llama_stack_api/resource.py +36 -0
  85. llama_stack_api/router_utils.py +160 -0
  86. llama_stack_api/safety/__init__.py +37 -0
  87. llama_stack_api/safety/api.py +29 -0
  88. llama_stack_api/safety/datatypes.py +83 -0
  89. llama_stack_api/safety/fastapi_routes.py +55 -0
  90. llama_stack_api/safety/models.py +38 -0
  91. llama_stack_api/schema_utils.py +251 -0
  92. llama_stack_api/scoring/__init__.py +66 -0
  93. llama_stack_api/scoring/api.py +35 -0
  94. llama_stack_api/scoring/fastapi_routes.py +67 -0
  95. llama_stack_api/scoring/models.py +81 -0
  96. llama_stack_api/scoring_functions/__init__.py +50 -0
  97. llama_stack_api/scoring_functions/api.py +39 -0
  98. llama_stack_api/scoring_functions/fastapi_routes.py +108 -0
  99. llama_stack_api/scoring_functions/models.py +214 -0
  100. llama_stack_api/shields/__init__.py +41 -0
  101. llama_stack_api/shields/api.py +39 -0
  102. llama_stack_api/shields/fastapi_routes.py +104 -0
  103. llama_stack_api/shields/models.py +74 -0
  104. llama_stack_api/tools.py +226 -0
  105. llama_stack_api/validators.py +46 -0
  106. llama_stack_api/vector_io/__init__.py +88 -0
  107. llama_stack_api/vector_io/api.py +234 -0
  108. llama_stack_api/vector_io/fastapi_routes.py +447 -0
  109. llama_stack_api/vector_io/models.py +663 -0
  110. llama_stack_api/vector_stores.py +53 -0
  111. llama_stack_api/version.py +9 -0
  112. {llama_stack_api-0.4.3.dist-info → llama_stack_api-0.5.0rc1.dist-info}/METADATA +1 -1
  113. llama_stack_api-0.5.0rc1.dist-info/RECORD +115 -0
  114. llama_stack_api-0.5.0rc1.dist-info/top_level.txt +1 -0
  115. llama_stack_api-0.4.3.dist-info/RECORD +0 -4
  116. llama_stack_api-0.4.3.dist-info/top_level.txt +0 -1
  117. {llama_stack_api-0.4.3.dist-info → llama_stack_api-0.5.0rc1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,45 @@
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
+ """Admin API protocol and models.
8
+
9
+ This module contains the Admin protocol definition.
10
+ Pydantic models are defined in llama_stack_api.admin.models.
11
+ The FastAPI router is defined in llama_stack_api.admin.fastapi_routes.
12
+ """
13
+
14
+ # Import fastapi_routes for router factory access
15
+ from . import fastapi_routes
16
+
17
+ # Import protocol for re-export
18
+ from .api import Admin
19
+
20
+ # Import models for re-export
21
+ from .models import (
22
+ ApiFilter,
23
+ HealthInfo,
24
+ InspectProviderRequest,
25
+ ListProvidersResponse,
26
+ ListRoutesRequest,
27
+ ListRoutesResponse,
28
+ ProviderInfo,
29
+ RouteInfo,
30
+ VersionInfo,
31
+ )
32
+
33
+ __all__ = [
34
+ "Admin",
35
+ "ApiFilter",
36
+ "HealthInfo",
37
+ "InspectProviderRequest",
38
+ "ListProvidersResponse",
39
+ "ListRoutesRequest",
40
+ "ListRoutesResponse",
41
+ "ProviderInfo",
42
+ "RouteInfo",
43
+ "VersionInfo",
44
+ "fastapi_routes",
45
+ ]
@@ -0,0 +1,72 @@
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 .models import (
10
+ HealthInfo,
11
+ InspectProviderRequest,
12
+ ListProvidersResponse,
13
+ ListRoutesRequest,
14
+ ListRoutesResponse,
15
+ ProviderInfo,
16
+ VersionInfo,
17
+ )
18
+
19
+
20
+ @runtime_checkable
21
+ class Admin(Protocol):
22
+ """Admin
23
+
24
+ Admin API for stack operations only available to administrative users.
25
+ """
26
+
27
+ async def list_providers(self) -> ListProvidersResponse:
28
+ """List providers.
29
+
30
+ List all available providers.
31
+
32
+ :returns: A ListProvidersResponse containing information about all providers.
33
+ """
34
+ ...
35
+
36
+ async def inspect_provider(self, request: InspectProviderRequest) -> ProviderInfo:
37
+ """Get provider.
38
+
39
+ Get detailed information about a specific provider.
40
+
41
+ :param request: Request containing the provider ID to inspect
42
+ :returns: A ProviderInfo object containing the provider's details.
43
+ """
44
+ ...
45
+
46
+ async def list_routes(self, request: ListRoutesRequest) -> ListRoutesResponse:
47
+ """List routes.
48
+
49
+ List all available API routes with their methods and implementing providers.
50
+
51
+ :param request: Request containing optional filter parameters
52
+ :returns: Response containing information about all available routes.
53
+ """
54
+ ...
55
+
56
+ async def health(self) -> HealthInfo:
57
+ """Get health status.
58
+
59
+ Get the current health status of the service.
60
+
61
+ :returns: Health information indicating if the service is operational.
62
+ """
63
+ ...
64
+
65
+ async def version(self) -> VersionInfo:
66
+ """Get version.
67
+
68
+ Get the version of the service.
69
+
70
+ :returns: Version information containing the service version number.
71
+ """
72
+ ...
@@ -0,0 +1,117 @@
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
+ """FastAPI router for the Admin API.
8
+
9
+ This module defines the FastAPI router for the Admin API using standard
10
+ FastAPI route decorators. The router is defined in the API package to keep
11
+ all API-related code together.
12
+ """
13
+
14
+ from typing import Annotated
15
+
16
+ from fastapi import APIRouter, Depends
17
+
18
+ from llama_stack_api.router_utils import create_path_dependency, create_query_dependency, standard_responses
19
+ from llama_stack_api.version import LLAMA_STACK_API_V1ALPHA
20
+
21
+ from .api import Admin
22
+ from .models import (
23
+ HealthInfo,
24
+ InspectProviderRequest,
25
+ ListProvidersResponse,
26
+ ListRoutesRequest,
27
+ ListRoutesResponse,
28
+ ProviderInfo,
29
+ VersionInfo,
30
+ )
31
+
32
+ # Automatically generate dependency functions from Pydantic models
33
+ get_inspect_provider_request = create_path_dependency(InspectProviderRequest)
34
+ get_list_routes_request = create_query_dependency(ListRoutesRequest)
35
+
36
+
37
+ def create_router(impl: Admin) -> APIRouter:
38
+ """Create a FastAPI router for the Admin API.
39
+
40
+ Args:
41
+ impl: The Admin implementation instance
42
+
43
+ Returns:
44
+ APIRouter configured for the Admin API
45
+ """
46
+ router = APIRouter(
47
+ prefix=f"/{LLAMA_STACK_API_V1ALPHA}",
48
+ tags=["Admin"],
49
+ responses=standard_responses,
50
+ )
51
+
52
+ @router.get(
53
+ "/admin/providers",
54
+ response_model=ListProvidersResponse,
55
+ summary="List all available providers",
56
+ description="List all available providers with their configuration and health status.",
57
+ responses={
58
+ 200: {"description": "A list of provider information objects."},
59
+ },
60
+ )
61
+ async def list_providers() -> ListProvidersResponse:
62
+ return await impl.list_providers()
63
+
64
+ @router.get(
65
+ "/admin/providers/{provider_id}",
66
+ response_model=ProviderInfo,
67
+ summary="Get provider details",
68
+ description="Get detailed information about a specific provider.",
69
+ responses={
70
+ 200: {"description": "The provider information object."},
71
+ 404: {"description": "Provider not found."},
72
+ },
73
+ )
74
+ async def inspect_provider(
75
+ request: Annotated[InspectProviderRequest, Depends(get_inspect_provider_request)],
76
+ ) -> ProviderInfo:
77
+ return await impl.inspect_provider(request)
78
+
79
+ @router.get(
80
+ "/admin/inspect/routes",
81
+ response_model=ListRoutesResponse,
82
+ summary="List all available API routes",
83
+ description="List all available API routes with their methods and implementing providers.",
84
+ responses={
85
+ 200: {"description": "A list of route information objects."},
86
+ },
87
+ )
88
+ async def list_routes(
89
+ request: Annotated[ListRoutesRequest, Depends(get_list_routes_request)],
90
+ ) -> ListRoutesResponse:
91
+ return await impl.list_routes(request)
92
+
93
+ @router.get(
94
+ "/admin/health",
95
+ response_model=HealthInfo,
96
+ summary="Get service health status",
97
+ description="Get the current health status of the service.",
98
+ responses={
99
+ 200: {"description": "Health information object."},
100
+ },
101
+ )
102
+ async def health() -> HealthInfo:
103
+ return await impl.health()
104
+
105
+ @router.get(
106
+ "/admin/version",
107
+ response_model=VersionInfo,
108
+ summary="Get service version",
109
+ description="Get the version of the service.",
110
+ responses={
111
+ 200: {"description": "Version information object."},
112
+ },
113
+ )
114
+ async def version() -> VersionInfo:
115
+ return await impl.version()
116
+
117
+ return router
@@ -0,0 +1,113 @@
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 Any, Literal
8
+
9
+ from pydantic import BaseModel, Field
10
+
11
+ from llama_stack_api.datatypes import HealthResponse, HealthStatus
12
+ from llama_stack_api.schema_utils import json_schema_type
13
+
14
+ # Valid values for the route filter parameter.
15
+ # Actual API levels: v1, v1alpha, v1beta (filters by level, excludes deprecated)
16
+ # Special filter value: "deprecated" (shows deprecated routes regardless of level)
17
+ ApiFilter = Literal["v1", "v1alpha", "v1beta", "deprecated"]
18
+
19
+
20
+ @json_schema_type
21
+ class RouteInfo(BaseModel):
22
+ """Information about an API route including its path, method, and implementing providers.
23
+
24
+ :param route: The API endpoint path
25
+ :param method: HTTP method for the route
26
+ :param provider_types: List of provider types that implement this route
27
+ """
28
+
29
+ route: str = Field(description="The API route path")
30
+ method: str = Field(description="The HTTP method for the route")
31
+ provider_types: list[str] = Field(description="List of provider types implementing this route")
32
+
33
+
34
+ @json_schema_type
35
+ class HealthInfo(BaseModel):
36
+ """Health status information for the service.
37
+
38
+ :param status: Current health status of the service
39
+ """
40
+
41
+ status: HealthStatus = Field(description="The health status of the service")
42
+
43
+
44
+ @json_schema_type
45
+ class VersionInfo(BaseModel):
46
+ """Version information for the service.
47
+
48
+ :param version: Version number of the service
49
+ """
50
+
51
+ version: str = Field(description="The version string of the service")
52
+
53
+
54
+ @json_schema_type
55
+ class ListRoutesResponse(BaseModel):
56
+ """Response containing a list of all available API routes.
57
+
58
+ :param data: List of available route information objects
59
+ """
60
+
61
+ data: list[RouteInfo] = Field(description="List of available API routes")
62
+
63
+
64
+ @json_schema_type
65
+ class ProviderInfo(BaseModel):
66
+ """Information about a registered provider including its configuration and health status.
67
+
68
+ :param api: The API name this provider implements
69
+ :param provider_id: Unique identifier for the provider
70
+ :param provider_type: The type of provider implementation
71
+ :param config: Configuration parameters for the provider
72
+ :param health: Current health status of the provider
73
+ """
74
+
75
+ api: str = Field(..., description="The API name this provider implements")
76
+ provider_id: str = Field(..., description="Unique identifier for the provider")
77
+ provider_type: str = Field(..., description="The type of provider implementation")
78
+ config: dict[str, Any] = Field(..., description="Configuration parameters for the provider")
79
+ health: HealthResponse = Field(..., description="Current health status of the provider")
80
+
81
+
82
+ @json_schema_type
83
+ class ListProvidersResponse(BaseModel):
84
+ """Response containing a list of all available providers.
85
+
86
+ :param data: List of provider information objects
87
+ """
88
+
89
+ data: list[ProviderInfo] = Field(..., description="List of provider information objects")
90
+
91
+
92
+ # Request models for FastAPI
93
+ @json_schema_type
94
+ class ListRoutesRequest(BaseModel):
95
+ """Request to list API routes.
96
+
97
+ :param api_filter: Optional filter to control which routes are returned
98
+ """
99
+
100
+ api_filter: ApiFilter | None = Field(
101
+ default=None,
102
+ description="Filter to control which routes are returned. Can be an API level ('v1', 'v1alpha', 'v1beta') to show non-deprecated routes at that level, or 'deprecated' to show deprecated routes across all levels. If not specified, returns all non-deprecated routes.",
103
+ )
104
+
105
+
106
+ @json_schema_type
107
+ class InspectProviderRequest(BaseModel):
108
+ """Request to inspect a specific provider.
109
+
110
+ :param provider_id: The ID of the provider to inspect
111
+ """
112
+
113
+ provider_id: str = Field(..., description="The ID of the provider to inspect.")
@@ -0,0 +1,38 @@
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
+ """Agents API protocol and models.
8
+
9
+ This module contains the Agents protocol definition for the OpenAI Responses API.
10
+ Pydantic models are defined in llama_stack_api.agents.models.
11
+ The FastAPI router is defined in llama_stack_api.agents.fastapi_routes.
12
+ """
13
+
14
+ from . import fastapi_routes
15
+ from .api import Agents
16
+ from .models import (
17
+ CreateResponseRequest,
18
+ DeleteResponseRequest,
19
+ ListResponseInputItemsRequest,
20
+ ListResponsesRequest,
21
+ ResponseGuardrail,
22
+ ResponseGuardrailSpec,
23
+ ResponseItemInclude,
24
+ RetrieveResponseRequest,
25
+ )
26
+
27
+ __all__ = [
28
+ "Agents",
29
+ "CreateResponseRequest",
30
+ "DeleteResponseRequest",
31
+ "ListResponseInputItemsRequest",
32
+ "ListResponsesRequest",
33
+ "ResponseGuardrail",
34
+ "ResponseGuardrailSpec",
35
+ "ResponseItemInclude",
36
+ "RetrieveResponseRequest",
37
+ "fastapi_routes",
38
+ ]
@@ -0,0 +1,52 @@
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 collections.abc import AsyncIterator
8
+ from typing import Protocol, runtime_checkable
9
+
10
+ from llama_stack_api.openai_responses import (
11
+ ListOpenAIResponseInputItem,
12
+ ListOpenAIResponseObject,
13
+ OpenAIDeleteResponseObject,
14
+ OpenAIResponseObject,
15
+ OpenAIResponseObjectStream,
16
+ )
17
+
18
+ from .models import (
19
+ CreateResponseRequest,
20
+ DeleteResponseRequest,
21
+ ListResponseInputItemsRequest,
22
+ ListResponsesRequest,
23
+ RetrieveResponseRequest,
24
+ )
25
+
26
+
27
+ @runtime_checkable
28
+ class Agents(Protocol):
29
+ async def get_openai_response(
30
+ self,
31
+ request: RetrieveResponseRequest,
32
+ ) -> OpenAIResponseObject: ...
33
+
34
+ async def create_openai_response(
35
+ self,
36
+ request: CreateResponseRequest,
37
+ ) -> OpenAIResponseObject | AsyncIterator[OpenAIResponseObjectStream]: ...
38
+
39
+ async def list_openai_responses(
40
+ self,
41
+ request: ListResponsesRequest,
42
+ ) -> ListOpenAIResponseObject: ...
43
+
44
+ async def list_openai_response_input_items(
45
+ self,
46
+ request: ListResponseInputItemsRequest,
47
+ ) -> ListOpenAIResponseInputItem: ...
48
+
49
+ async def delete_openai_response(
50
+ self,
51
+ request: DeleteResponseRequest,
52
+ ) -> OpenAIDeleteResponseObject: ...