llama-stack-api 0.4.3__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.3.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.4.dist-info/top_level.txt +1 -0
  70. llama_stack_api-0.4.3.dist-info/RECORD +0 -4
  71. llama_stack_api-0.4.3.dist-info/top_level.txt +0 -1
  72. {llama_stack_api-0.4.3.dist-info → llama_stack_api-0.4.4.dist-info}/WHEEL +0 -0
@@ -0,0 +1,226 @@
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, Literal, Protocol
9
+
10
+ from pydantic import BaseModel
11
+ from typing_extensions import runtime_checkable
12
+
13
+ from llama_stack_api.common.content_types import URL, InterleavedContent
14
+ from llama_stack_api.resource import Resource, ResourceType
15
+ from llama_stack_api.schema_utils import json_schema_type, webmethod
16
+ from llama_stack_api.version import LLAMA_STACK_API_V1
17
+
18
+
19
+ @json_schema_type
20
+ class ToolDef(BaseModel):
21
+ """Tool definition used in runtime contexts.
22
+
23
+ :param name: Name of the tool
24
+ :param description: (Optional) Human-readable description of what the tool does
25
+ :param input_schema: (Optional) JSON Schema for tool inputs (MCP inputSchema)
26
+ :param output_schema: (Optional) JSON Schema for tool outputs (MCP outputSchema)
27
+ :param metadata: (Optional) Additional metadata about the tool
28
+ :param toolgroup_id: (Optional) ID of the tool group this tool belongs to
29
+ """
30
+
31
+ toolgroup_id: str | None = None
32
+ name: str
33
+ description: str | None = None
34
+ input_schema: dict[str, Any] | None = None
35
+ output_schema: dict[str, Any] | None = None
36
+ metadata: dict[str, Any] | None = None
37
+
38
+
39
+ @json_schema_type
40
+ class ToolGroupInput(BaseModel):
41
+ """Input data for registering a tool group.
42
+
43
+ :param toolgroup_id: Unique identifier for the tool group
44
+ :param provider_id: ID of the provider that will handle this tool group
45
+ :param args: (Optional) Additional arguments to pass to the provider
46
+ :param mcp_endpoint: (Optional) Model Context Protocol endpoint for remote tools
47
+ """
48
+
49
+ toolgroup_id: str
50
+ provider_id: str
51
+ args: dict[str, Any] | None = None
52
+ mcp_endpoint: URL | None = None
53
+
54
+
55
+ @json_schema_type
56
+ class ToolGroup(Resource):
57
+ """A group of related tools managed together.
58
+
59
+ :param type: Type of resource, always 'tool_group'
60
+ :param mcp_endpoint: (Optional) Model Context Protocol endpoint for remote tools
61
+ :param args: (Optional) Additional arguments for the tool group
62
+ """
63
+
64
+ type: Literal[ResourceType.tool_group] = ResourceType.tool_group
65
+ mcp_endpoint: URL | None = None
66
+ args: dict[str, Any] | None = None
67
+
68
+
69
+ @json_schema_type
70
+ class ToolInvocationResult(BaseModel):
71
+ """Result of a tool invocation.
72
+
73
+ :param content: (Optional) The output content from the tool execution
74
+ :param error_message: (Optional) Error message if the tool execution failed
75
+ :param error_code: (Optional) Numeric error code if the tool execution failed
76
+ :param metadata: (Optional) Additional metadata about the tool execution
77
+ """
78
+
79
+ content: InterleavedContent | None = None
80
+ error_message: str | None = None
81
+ error_code: int | None = None
82
+ metadata: dict[str, Any] | None = None
83
+
84
+
85
+ class ToolStore(Protocol):
86
+ async def get_tool(self, tool_name: str) -> ToolDef: ...
87
+ async def get_tool_group(self, toolgroup_id: str) -> ToolGroup: ...
88
+
89
+
90
+ @json_schema_type
91
+ class ListToolGroupsResponse(BaseModel):
92
+ """Response containing a list of tool groups.
93
+
94
+ :param data: List of tool groups
95
+ """
96
+
97
+ data: list[ToolGroup]
98
+
99
+
100
+ @json_schema_type
101
+ class ListToolDefsResponse(BaseModel):
102
+ """Response containing a list of tool definitions.
103
+
104
+ :param data: List of tool definitions
105
+ """
106
+
107
+ data: list[ToolDef]
108
+
109
+
110
+ @runtime_checkable
111
+ class ToolGroups(Protocol):
112
+ @webmethod(route="/toolgroups", method="POST", level=LLAMA_STACK_API_V1, deprecated=True)
113
+ async def register_tool_group(
114
+ self,
115
+ toolgroup_id: str,
116
+ provider_id: str,
117
+ mcp_endpoint: URL | None = None,
118
+ args: dict[str, Any] | None = None,
119
+ ) -> None:
120
+ """Register a tool group.
121
+
122
+ :param toolgroup_id: The ID of the tool group to register.
123
+ :param provider_id: The ID of the provider to use for the tool group.
124
+ :param mcp_endpoint: The MCP endpoint to use for the tool group.
125
+ :param args: A dictionary of arguments to pass to the tool group.
126
+ """
127
+ ...
128
+
129
+ @webmethod(route="/toolgroups/{toolgroup_id:path}", method="GET", level=LLAMA_STACK_API_V1, deprecated=True)
130
+ async def get_tool_group(
131
+ self,
132
+ toolgroup_id: str,
133
+ ) -> ToolGroup:
134
+ """Get a tool group by its ID.
135
+
136
+ :param toolgroup_id: The ID of the tool group to get.
137
+ :returns: A ToolGroup.
138
+ """
139
+ ...
140
+
141
+ @webmethod(route="/toolgroups", method="GET", level=LLAMA_STACK_API_V1, deprecated=True)
142
+ async def list_tool_groups(self) -> ListToolGroupsResponse:
143
+ """List tool groups with optional provider.
144
+
145
+ :returns: A ListToolGroupsResponse.
146
+ """
147
+ ...
148
+
149
+ @webmethod(route="/tools", method="GET", level=LLAMA_STACK_API_V1, deprecated=True)
150
+ async def list_tools(self, toolgroup_id: str | None = None) -> ListToolDefsResponse:
151
+ """List tools with optional tool group.
152
+
153
+ :param toolgroup_id: The ID of the tool group to list tools for.
154
+ :returns: A ListToolDefsResponse.
155
+ """
156
+ ...
157
+
158
+ @webmethod(route="/tools/{tool_name:path}", method="GET", level=LLAMA_STACK_API_V1, deprecated=True)
159
+ async def get_tool(
160
+ self,
161
+ tool_name: str,
162
+ ) -> ToolDef:
163
+ """Get a tool by its name.
164
+
165
+ :param tool_name: The name of the tool to get.
166
+ :returns: A ToolDef.
167
+ """
168
+ ...
169
+
170
+ @webmethod(route="/toolgroups/{toolgroup_id:path}", method="DELETE", level=LLAMA_STACK_API_V1, deprecated=True)
171
+ async def unregister_toolgroup(
172
+ self,
173
+ toolgroup_id: str,
174
+ ) -> None:
175
+ """Unregister a tool group.
176
+
177
+ :param toolgroup_id: The ID of the tool group to unregister.
178
+ """
179
+ ...
180
+
181
+
182
+ class SpecialToolGroup(Enum):
183
+ """Special tool groups with predefined functionality.
184
+
185
+ :cvar rag_tool: Retrieval-Augmented Generation tool group for document search and retrieval
186
+ """
187
+
188
+ rag_tool = "rag_tool"
189
+
190
+
191
+ @runtime_checkable
192
+ class ToolRuntime(Protocol):
193
+ tool_store: ToolStore | None = None
194
+
195
+ # TODO: This needs to be renamed once OPEN API generator name conflict issue is fixed.
196
+ @webmethod(route="/tool-runtime/list-tools", method="GET", level=LLAMA_STACK_API_V1, deprecated=True)
197
+ async def list_runtime_tools(
198
+ self,
199
+ tool_group_id: str | None = None,
200
+ mcp_endpoint: URL | None = None,
201
+ authorization: str | None = None,
202
+ ) -> ListToolDefsResponse:
203
+ """List all tools in the runtime.
204
+
205
+ :param tool_group_id: The ID of the tool group to list tools for.
206
+ :param mcp_endpoint: The MCP endpoint to use for the tool group.
207
+ :param authorization: (Optional) OAuth access token for authenticating with the MCP server.
208
+ :returns: A ListToolDefsResponse.
209
+ """
210
+ ...
211
+
212
+ @webmethod(route="/tool-runtime/invoke", method="POST", level=LLAMA_STACK_API_V1, deprecated=True)
213
+ async def invoke_tool(
214
+ self,
215
+ tool_name: str,
216
+ kwargs: dict[str, Any],
217
+ authorization: str | None = None,
218
+ ) -> ToolInvocationResult:
219
+ """Run a tool with the given arguments.
220
+
221
+ :param tool_name: The name of the tool to invoke.
222
+ :param kwargs: A dictionary of arguments to pass to the tool.
223
+ :param authorization: (Optional) OAuth access token for authenticating with the MCP server.
224
+ :returns: A ToolInvocationResult.
225
+ """
226
+ ...