llama-stack 0.4.3__py3-none-any.whl → 0.5.0__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 (311) hide show
  1. llama_stack/cli/stack/_list_deps.py +11 -7
  2. llama_stack/cli/stack/run.py +3 -25
  3. llama_stack/core/access_control/datatypes.py +78 -0
  4. llama_stack/core/configure.py +2 -2
  5. {llama_stack_api/internal → llama_stack/core/connectors}/__init__.py +2 -2
  6. llama_stack/core/connectors/connectors.py +162 -0
  7. llama_stack/core/conversations/conversations.py +61 -58
  8. llama_stack/core/datatypes.py +54 -8
  9. llama_stack/core/library_client.py +60 -13
  10. llama_stack/core/prompts/prompts.py +43 -42
  11. llama_stack/core/routers/datasets.py +20 -17
  12. llama_stack/core/routers/eval_scoring.py +143 -53
  13. llama_stack/core/routers/inference.py +20 -9
  14. llama_stack/core/routers/safety.py +30 -42
  15. llama_stack/core/routers/vector_io.py +15 -7
  16. llama_stack/core/routing_tables/models.py +42 -3
  17. llama_stack/core/routing_tables/scoring_functions.py +19 -19
  18. llama_stack/core/routing_tables/shields.py +20 -17
  19. llama_stack/core/routing_tables/vector_stores.py +8 -5
  20. llama_stack/core/server/auth.py +192 -17
  21. llama_stack/core/server/fastapi_router_registry.py +40 -5
  22. llama_stack/core/server/server.py +24 -5
  23. llama_stack/core/stack.py +54 -10
  24. llama_stack/core/storage/datatypes.py +9 -0
  25. llama_stack/core/store/registry.py +1 -1
  26. llama_stack/core/utils/exec.py +2 -2
  27. llama_stack/core/utils/type_inspection.py +16 -2
  28. llama_stack/distributions/dell/config.yaml +4 -1
  29. llama_stack/distributions/dell/doc_template.md +209 -0
  30. llama_stack/distributions/dell/run-with-safety.yaml +4 -1
  31. llama_stack/distributions/nvidia/config.yaml +4 -1
  32. llama_stack/distributions/nvidia/doc_template.md +170 -0
  33. llama_stack/distributions/nvidia/run-with-safety.yaml +4 -1
  34. llama_stack/distributions/oci/config.yaml +4 -1
  35. llama_stack/distributions/oci/doc_template.md +140 -0
  36. llama_stack/distributions/open-benchmark/config.yaml +9 -1
  37. llama_stack/distributions/postgres-demo/config.yaml +1 -1
  38. llama_stack/distributions/starter/build.yaml +62 -0
  39. llama_stack/distributions/starter/config.yaml +22 -3
  40. llama_stack/distributions/starter/run-with-postgres-store.yaml +22 -3
  41. llama_stack/distributions/starter/starter.py +13 -1
  42. llama_stack/distributions/starter-gpu/build.yaml +62 -0
  43. llama_stack/distributions/starter-gpu/config.yaml +22 -3
  44. llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml +22 -3
  45. llama_stack/distributions/template.py +10 -2
  46. llama_stack/distributions/watsonx/config.yaml +4 -1
  47. llama_stack/log.py +1 -0
  48. llama_stack/models/llama/resources/dog.jpg +0 -0
  49. llama_stack/models/llama/resources/pasta.jpeg +0 -0
  50. llama_stack/models/llama/resources/small_dog.jpg +0 -0
  51. llama_stack/providers/inline/agents/meta_reference/__init__.py +1 -0
  52. llama_stack/providers/inline/agents/meta_reference/agents.py +58 -61
  53. llama_stack/providers/inline/agents/meta_reference/responses/openai_responses.py +187 -60
  54. llama_stack/providers/inline/agents/meta_reference/responses/streaming.py +99 -22
  55. llama_stack/providers/inline/agents/meta_reference/responses/types.py +2 -1
  56. llama_stack/providers/inline/agents/meta_reference/responses/utils.py +4 -1
  57. llama_stack/providers/inline/agents/meta_reference/safety.py +2 -2
  58. llama_stack/providers/inline/batches/reference/batches.py +2 -1
  59. llama_stack/providers/inline/eval/meta_reference/eval.py +40 -32
  60. llama_stack/providers/inline/ios/inference/LocalInferenceImpl/LocalInference.h +9 -0
  61. llama_stack/providers/inline/ios/inference/LocalInferenceImpl/LocalInference.swift +189 -0
  62. llama_stack/providers/inline/ios/inference/LocalInferenceImpl/Parsing.swift +238 -0
  63. llama_stack/providers/inline/ios/inference/LocalInferenceImpl/PromptTemplate.swift +12 -0
  64. llama_stack/providers/inline/ios/inference/LocalInferenceImpl/SystemPrompts.swift +89 -0
  65. llama_stack/providers/inline/ios/inference/LocalInferenceImpl.xcodeproj/project.pbxproj +550 -0
  66. llama_stack/providers/inline/ios/inference/LocalInferenceImpl.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  67. llama_stack/providers/inline/ios/inference/LocalInferenceImpl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  68. llama_stack/providers/inline/post_training/huggingface/post_training.py +33 -38
  69. llama_stack/providers/inline/post_training/huggingface/utils.py +2 -5
  70. llama_stack/providers/inline/post_training/torchtune/common/utils.py +5 -9
  71. llama_stack/providers/inline/post_training/torchtune/post_training.py +28 -33
  72. llama_stack/providers/inline/post_training/torchtune/recipes/lora_finetuning_single_device.py +2 -4
  73. llama_stack/providers/inline/safety/code_scanner/code_scanner.py +12 -15
  74. llama_stack/providers/inline/safety/llama_guard/llama_guard.py +20 -24
  75. llama_stack/providers/inline/safety/prompt_guard/prompt_guard.py +11 -17
  76. llama_stack/providers/inline/scoring/basic/scoring.py +13 -17
  77. llama_stack/providers/inline/scoring/braintrust/braintrust.py +15 -15
  78. llama_stack/providers/inline/scoring/llm_as_judge/scoring.py +13 -17
  79. llama_stack/providers/inline/vector_io/sqlite_vec/sqlite_vec.py +1 -1
  80. llama_stack/providers/registry/agents.py +1 -0
  81. llama_stack/providers/registry/inference.py +1 -9
  82. llama_stack/providers/registry/vector_io.py +136 -16
  83. llama_stack/providers/remote/datasetio/nvidia/README.md +74 -0
  84. llama_stack/providers/remote/eval/nvidia/README.md +134 -0
  85. llama_stack/providers/remote/eval/nvidia/eval.py +22 -21
  86. llama_stack/providers/remote/files/s3/README.md +266 -0
  87. llama_stack/providers/remote/files/s3/config.py +5 -3
  88. llama_stack/providers/remote/files/s3/files.py +2 -2
  89. llama_stack/providers/remote/inference/gemini/gemini.py +4 -0
  90. llama_stack/providers/remote/inference/nvidia/NVIDIA.md +203 -0
  91. llama_stack/providers/remote/inference/openai/openai.py +2 -0
  92. llama_stack/providers/remote/inference/together/together.py +4 -0
  93. llama_stack/providers/remote/inference/vertexai/config.py +3 -3
  94. llama_stack/providers/remote/inference/vertexai/vertexai.py +5 -2
  95. llama_stack/providers/remote/inference/vllm/config.py +37 -18
  96. llama_stack/providers/remote/inference/vllm/vllm.py +0 -3
  97. llama_stack/providers/remote/inference/watsonx/watsonx.py +4 -0
  98. llama_stack/providers/remote/post_training/nvidia/README.md +151 -0
  99. llama_stack/providers/remote/post_training/nvidia/models.py +3 -11
  100. llama_stack/providers/remote/post_training/nvidia/post_training.py +31 -33
  101. llama_stack/providers/remote/safety/bedrock/bedrock.py +10 -27
  102. llama_stack/providers/remote/safety/nvidia/README.md +78 -0
  103. llama_stack/providers/remote/safety/nvidia/nvidia.py +9 -25
  104. llama_stack/providers/remote/safety/sambanova/sambanova.py +13 -11
  105. llama_stack/providers/remote/vector_io/elasticsearch/__init__.py +17 -0
  106. llama_stack/providers/remote/vector_io/elasticsearch/config.py +32 -0
  107. llama_stack/providers/remote/vector_io/elasticsearch/elasticsearch.py +463 -0
  108. llama_stack/providers/remote/vector_io/oci/__init__.py +22 -0
  109. llama_stack/providers/remote/vector_io/oci/config.py +41 -0
  110. llama_stack/providers/remote/vector_io/oci/oci26ai.py +595 -0
  111. llama_stack/providers/remote/vector_io/pgvector/config.py +69 -2
  112. llama_stack/providers/remote/vector_io/pgvector/pgvector.py +255 -6
  113. llama_stack/providers/remote/vector_io/qdrant/qdrant.py +62 -38
  114. llama_stack/providers/utils/bedrock/client.py +3 -3
  115. llama_stack/providers/utils/bedrock/config.py +7 -7
  116. llama_stack/providers/utils/inference/__init__.py +0 -25
  117. llama_stack/providers/utils/inference/embedding_mixin.py +4 -0
  118. llama_stack/providers/utils/inference/http_client.py +239 -0
  119. llama_stack/providers/utils/inference/litellm_openai_mixin.py +6 -0
  120. llama_stack/providers/utils/inference/model_registry.py +148 -2
  121. llama_stack/providers/utils/inference/openai_compat.py +1 -158
  122. llama_stack/providers/utils/inference/openai_mixin.py +42 -2
  123. llama_stack/providers/utils/inference/prompt_adapter.py +0 -209
  124. llama_stack/providers/utils/memory/openai_vector_store_mixin.py +92 -5
  125. llama_stack/providers/utils/memory/vector_store.py +46 -19
  126. llama_stack/providers/utils/responses/responses_store.py +40 -6
  127. llama_stack/providers/utils/safety.py +114 -0
  128. llama_stack/providers/utils/tools/mcp.py +44 -3
  129. llama_stack/testing/api_recorder.py +9 -3
  130. {llama_stack-0.4.3.dist-info → llama_stack-0.5.0.dist-info}/METADATA +14 -2
  131. {llama_stack-0.4.3.dist-info → llama_stack-0.5.0.dist-info}/RECORD +135 -279
  132. llama_stack-0.5.0.dist-info/top_level.txt +1 -0
  133. llama_stack/distributions/meta-reference-gpu/__init__.py +0 -7
  134. llama_stack/distributions/meta-reference-gpu/config.yaml +0 -140
  135. llama_stack/distributions/meta-reference-gpu/meta_reference.py +0 -163
  136. llama_stack/distributions/meta-reference-gpu/run-with-safety.yaml +0 -155
  137. llama_stack/models/llama/hadamard_utils.py +0 -88
  138. llama_stack/models/llama/llama3/args.py +0 -74
  139. llama_stack/models/llama/llama3/generation.py +0 -378
  140. llama_stack/models/llama/llama3/model.py +0 -304
  141. llama_stack/models/llama/llama3/multimodal/__init__.py +0 -12
  142. llama_stack/models/llama/llama3/multimodal/encoder_utils.py +0 -180
  143. llama_stack/models/llama/llama3/multimodal/image_transform.py +0 -409
  144. llama_stack/models/llama/llama3/multimodal/model.py +0 -1430
  145. llama_stack/models/llama/llama3/multimodal/utils.py +0 -26
  146. llama_stack/models/llama/llama3/quantization/__init__.py +0 -5
  147. llama_stack/models/llama/llama3/quantization/loader.py +0 -316
  148. llama_stack/models/llama/llama3_1/__init__.py +0 -12
  149. llama_stack/models/llama/llama3_1/prompt_format.md +0 -358
  150. llama_stack/models/llama/llama3_1/prompts.py +0 -258
  151. llama_stack/models/llama/llama3_2/__init__.py +0 -5
  152. llama_stack/models/llama/llama3_2/prompts_text.py +0 -229
  153. llama_stack/models/llama/llama3_2/prompts_vision.py +0 -126
  154. llama_stack/models/llama/llama3_2/text_prompt_format.md +0 -286
  155. llama_stack/models/llama/llama3_2/vision_prompt_format.md +0 -141
  156. llama_stack/models/llama/llama3_3/__init__.py +0 -5
  157. llama_stack/models/llama/llama3_3/prompts.py +0 -259
  158. llama_stack/models/llama/llama4/args.py +0 -107
  159. llama_stack/models/llama/llama4/ffn.py +0 -58
  160. llama_stack/models/llama/llama4/moe.py +0 -214
  161. llama_stack/models/llama/llama4/preprocess.py +0 -435
  162. llama_stack/models/llama/llama4/quantization/__init__.py +0 -5
  163. llama_stack/models/llama/llama4/quantization/loader.py +0 -226
  164. llama_stack/models/llama/llama4/vision/__init__.py +0 -5
  165. llama_stack/models/llama/llama4/vision/embedding.py +0 -210
  166. llama_stack/models/llama/llama4/vision/encoder.py +0 -412
  167. llama_stack/models/llama/quantize_impls.py +0 -316
  168. llama_stack/providers/inline/inference/meta_reference/__init__.py +0 -20
  169. llama_stack/providers/inline/inference/meta_reference/common.py +0 -24
  170. llama_stack/providers/inline/inference/meta_reference/config.py +0 -68
  171. llama_stack/providers/inline/inference/meta_reference/generators.py +0 -201
  172. llama_stack/providers/inline/inference/meta_reference/inference.py +0 -542
  173. llama_stack/providers/inline/inference/meta_reference/model_parallel.py +0 -77
  174. llama_stack/providers/inline/inference/meta_reference/parallel_utils.py +0 -353
  175. llama_stack-0.4.3.dist-info/top_level.txt +0 -2
  176. llama_stack_api/__init__.py +0 -945
  177. llama_stack_api/admin/__init__.py +0 -45
  178. llama_stack_api/admin/api.py +0 -72
  179. llama_stack_api/admin/fastapi_routes.py +0 -117
  180. llama_stack_api/admin/models.py +0 -113
  181. llama_stack_api/agents.py +0 -173
  182. llama_stack_api/batches/__init__.py +0 -40
  183. llama_stack_api/batches/api.py +0 -53
  184. llama_stack_api/batches/fastapi_routes.py +0 -113
  185. llama_stack_api/batches/models.py +0 -78
  186. llama_stack_api/benchmarks/__init__.py +0 -43
  187. llama_stack_api/benchmarks/api.py +0 -39
  188. llama_stack_api/benchmarks/fastapi_routes.py +0 -109
  189. llama_stack_api/benchmarks/models.py +0 -109
  190. llama_stack_api/common/__init__.py +0 -5
  191. llama_stack_api/common/content_types.py +0 -101
  192. llama_stack_api/common/errors.py +0 -95
  193. llama_stack_api/common/job_types.py +0 -38
  194. llama_stack_api/common/responses.py +0 -77
  195. llama_stack_api/common/training_types.py +0 -47
  196. llama_stack_api/common/type_system.py +0 -146
  197. llama_stack_api/connectors.py +0 -146
  198. llama_stack_api/conversations.py +0 -270
  199. llama_stack_api/datasetio.py +0 -55
  200. llama_stack_api/datasets/__init__.py +0 -61
  201. llama_stack_api/datasets/api.py +0 -35
  202. llama_stack_api/datasets/fastapi_routes.py +0 -104
  203. llama_stack_api/datasets/models.py +0 -152
  204. llama_stack_api/datatypes.py +0 -373
  205. llama_stack_api/eval.py +0 -137
  206. llama_stack_api/file_processors/__init__.py +0 -27
  207. llama_stack_api/file_processors/api.py +0 -64
  208. llama_stack_api/file_processors/fastapi_routes.py +0 -78
  209. llama_stack_api/file_processors/models.py +0 -42
  210. llama_stack_api/files/__init__.py +0 -35
  211. llama_stack_api/files/api.py +0 -51
  212. llama_stack_api/files/fastapi_routes.py +0 -124
  213. llama_stack_api/files/models.py +0 -107
  214. llama_stack_api/inference.py +0 -1169
  215. llama_stack_api/inspect_api/__init__.py +0 -37
  216. llama_stack_api/inspect_api/api.py +0 -25
  217. llama_stack_api/inspect_api/fastapi_routes.py +0 -76
  218. llama_stack_api/inspect_api/models.py +0 -28
  219. llama_stack_api/internal/kvstore.py +0 -28
  220. llama_stack_api/internal/sqlstore.py +0 -81
  221. llama_stack_api/llama_stack_api/__init__.py +0 -945
  222. llama_stack_api/llama_stack_api/admin/__init__.py +0 -45
  223. llama_stack_api/llama_stack_api/admin/api.py +0 -72
  224. llama_stack_api/llama_stack_api/admin/fastapi_routes.py +0 -117
  225. llama_stack_api/llama_stack_api/admin/models.py +0 -113
  226. llama_stack_api/llama_stack_api/agents.py +0 -173
  227. llama_stack_api/llama_stack_api/batches/__init__.py +0 -40
  228. llama_stack_api/llama_stack_api/batches/api.py +0 -53
  229. llama_stack_api/llama_stack_api/batches/fastapi_routes.py +0 -113
  230. llama_stack_api/llama_stack_api/batches/models.py +0 -78
  231. llama_stack_api/llama_stack_api/benchmarks/__init__.py +0 -43
  232. llama_stack_api/llama_stack_api/benchmarks/api.py +0 -39
  233. llama_stack_api/llama_stack_api/benchmarks/fastapi_routes.py +0 -109
  234. llama_stack_api/llama_stack_api/benchmarks/models.py +0 -109
  235. llama_stack_api/llama_stack_api/common/__init__.py +0 -5
  236. llama_stack_api/llama_stack_api/common/content_types.py +0 -101
  237. llama_stack_api/llama_stack_api/common/errors.py +0 -95
  238. llama_stack_api/llama_stack_api/common/job_types.py +0 -38
  239. llama_stack_api/llama_stack_api/common/responses.py +0 -77
  240. llama_stack_api/llama_stack_api/common/training_types.py +0 -47
  241. llama_stack_api/llama_stack_api/common/type_system.py +0 -146
  242. llama_stack_api/llama_stack_api/connectors.py +0 -146
  243. llama_stack_api/llama_stack_api/conversations.py +0 -270
  244. llama_stack_api/llama_stack_api/datasetio.py +0 -55
  245. llama_stack_api/llama_stack_api/datasets/__init__.py +0 -61
  246. llama_stack_api/llama_stack_api/datasets/api.py +0 -35
  247. llama_stack_api/llama_stack_api/datasets/fastapi_routes.py +0 -104
  248. llama_stack_api/llama_stack_api/datasets/models.py +0 -152
  249. llama_stack_api/llama_stack_api/datatypes.py +0 -373
  250. llama_stack_api/llama_stack_api/eval.py +0 -137
  251. llama_stack_api/llama_stack_api/file_processors/__init__.py +0 -27
  252. llama_stack_api/llama_stack_api/file_processors/api.py +0 -64
  253. llama_stack_api/llama_stack_api/file_processors/fastapi_routes.py +0 -78
  254. llama_stack_api/llama_stack_api/file_processors/models.py +0 -42
  255. llama_stack_api/llama_stack_api/files/__init__.py +0 -35
  256. llama_stack_api/llama_stack_api/files/api.py +0 -51
  257. llama_stack_api/llama_stack_api/files/fastapi_routes.py +0 -124
  258. llama_stack_api/llama_stack_api/files/models.py +0 -107
  259. llama_stack_api/llama_stack_api/inference.py +0 -1169
  260. llama_stack_api/llama_stack_api/inspect_api/__init__.py +0 -37
  261. llama_stack_api/llama_stack_api/inspect_api/api.py +0 -25
  262. llama_stack_api/llama_stack_api/inspect_api/fastapi_routes.py +0 -76
  263. llama_stack_api/llama_stack_api/inspect_api/models.py +0 -28
  264. llama_stack_api/llama_stack_api/internal/__init__.py +0 -9
  265. llama_stack_api/llama_stack_api/internal/kvstore.py +0 -28
  266. llama_stack_api/llama_stack_api/internal/sqlstore.py +0 -81
  267. llama_stack_api/llama_stack_api/models.py +0 -171
  268. llama_stack_api/llama_stack_api/openai_responses.py +0 -1468
  269. llama_stack_api/llama_stack_api/post_training.py +0 -370
  270. llama_stack_api/llama_stack_api/prompts.py +0 -203
  271. llama_stack_api/llama_stack_api/providers/__init__.py +0 -33
  272. llama_stack_api/llama_stack_api/providers/api.py +0 -16
  273. llama_stack_api/llama_stack_api/providers/fastapi_routes.py +0 -57
  274. llama_stack_api/llama_stack_api/providers/models.py +0 -24
  275. llama_stack_api/llama_stack_api/py.typed +0 -0
  276. llama_stack_api/llama_stack_api/rag_tool.py +0 -168
  277. llama_stack_api/llama_stack_api/resource.py +0 -37
  278. llama_stack_api/llama_stack_api/router_utils.py +0 -160
  279. llama_stack_api/llama_stack_api/safety.py +0 -132
  280. llama_stack_api/llama_stack_api/schema_utils.py +0 -208
  281. llama_stack_api/llama_stack_api/scoring.py +0 -93
  282. llama_stack_api/llama_stack_api/scoring_functions.py +0 -211
  283. llama_stack_api/llama_stack_api/shields.py +0 -93
  284. llama_stack_api/llama_stack_api/tools.py +0 -226
  285. llama_stack_api/llama_stack_api/vector_io.py +0 -941
  286. llama_stack_api/llama_stack_api/vector_stores.py +0 -53
  287. llama_stack_api/llama_stack_api/version.py +0 -9
  288. llama_stack_api/models.py +0 -171
  289. llama_stack_api/openai_responses.py +0 -1468
  290. llama_stack_api/post_training.py +0 -370
  291. llama_stack_api/prompts.py +0 -203
  292. llama_stack_api/providers/__init__.py +0 -33
  293. llama_stack_api/providers/api.py +0 -16
  294. llama_stack_api/providers/fastapi_routes.py +0 -57
  295. llama_stack_api/providers/models.py +0 -24
  296. llama_stack_api/py.typed +0 -0
  297. llama_stack_api/rag_tool.py +0 -168
  298. llama_stack_api/resource.py +0 -37
  299. llama_stack_api/router_utils.py +0 -160
  300. llama_stack_api/safety.py +0 -132
  301. llama_stack_api/schema_utils.py +0 -208
  302. llama_stack_api/scoring.py +0 -93
  303. llama_stack_api/scoring_functions.py +0 -211
  304. llama_stack_api/shields.py +0 -93
  305. llama_stack_api/tools.py +0 -226
  306. llama_stack_api/vector_io.py +0 -941
  307. llama_stack_api/vector_stores.py +0 -53
  308. llama_stack_api/version.py +0 -9
  309. {llama_stack-0.4.3.dist-info → llama_stack-0.5.0.dist-info}/WHEEL +0 -0
  310. {llama_stack-0.4.3.dist-info → llama_stack-0.5.0.dist-info}/entry_points.txt +0 -0
  311. {llama_stack-0.4.3.dist-info → llama_stack-0.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,42 +0,0 @@
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 File Processors API responses.
8
-
9
- This module defines the response models for the File Processors API
10
- using Pydantic with Field descriptions for OpenAPI schema generation.
11
-
12
- Request models are not needed for this API since it uses multipart form data
13
- with individual parameters rather than a JSON request body.
14
- """
15
-
16
- from typing import Any
17
-
18
- from pydantic import BaseModel, Field
19
-
20
- from llama_stack_api.schema_utils import json_schema_type
21
- from llama_stack_api.vector_io import Chunk
22
-
23
-
24
- @json_schema_type
25
- class ProcessFileResponse(BaseModel):
26
- """Response model for file processing operation.
27
-
28
- Returns a list of chunks ready for storage in vector databases.
29
- Each chunk contains the content and metadata.
30
- """
31
-
32
- chunks: list[Chunk] = Field(..., description="Processed chunks from the file. Always returns at least one chunk.")
33
-
34
- metadata: dict[str, Any] = Field(
35
- ...,
36
- description="Processing-run metadata such as processor name/version, processing_time_ms, page_count, extraction_method (e.g. docling/pypdf/ocr), confidence scores, plus provider-specific fields.",
37
- )
38
-
39
-
40
- __all__ = [
41
- "ProcessFileResponse",
42
- ]
@@ -1,35 +0,0 @@
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 . import fastapi_routes
8
- from .api import Files
9
- from .models import (
10
- DeleteFileRequest,
11
- ExpiresAfter,
12
- ListFilesRequest,
13
- ListOpenAIFileResponse,
14
- OpenAIFileDeleteResponse,
15
- OpenAIFileObject,
16
- OpenAIFilePurpose,
17
- RetrieveFileContentRequest,
18
- RetrieveFileRequest,
19
- UploadFileRequest,
20
- )
21
-
22
- __all__ = [
23
- "DeleteFileRequest",
24
- "ExpiresAfter",
25
- "fastapi_routes",
26
- "Files",
27
- "ListFilesRequest",
28
- "ListOpenAIFileResponse",
29
- "OpenAIFileDeleteResponse",
30
- "OpenAIFileObject",
31
- "OpenAIFilePurpose",
32
- "RetrieveFileContentRequest",
33
- "RetrieveFileRequest",
34
- "UploadFileRequest",
35
- ]
@@ -1,51 +0,0 @@
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 fastapi import Response, UploadFile
10
-
11
- from .models import (
12
- DeleteFileRequest,
13
- ListFilesRequest,
14
- ListOpenAIFileResponse,
15
- OpenAIFileDeleteResponse,
16
- OpenAIFileObject,
17
- RetrieveFileContentRequest,
18
- RetrieveFileRequest,
19
- UploadFileRequest,
20
- )
21
-
22
-
23
- @runtime_checkable
24
- class Files(Protocol):
25
- """Files API for managing file uploads and retrieval."""
26
-
27
- async def openai_upload_file(
28
- self,
29
- request: UploadFileRequest,
30
- file: UploadFile,
31
- ) -> OpenAIFileObject: ...
32
-
33
- async def openai_list_files(
34
- self,
35
- request: ListFilesRequest,
36
- ) -> ListOpenAIFileResponse: ...
37
-
38
- async def openai_retrieve_file(
39
- self,
40
- request: RetrieveFileRequest,
41
- ) -> OpenAIFileObject: ...
42
-
43
- async def openai_delete_file(
44
- self,
45
- request: DeleteFileRequest,
46
- ) -> OpenAIFileDeleteResponse: ...
47
-
48
- async def openai_retrieve_file_content(
49
- self,
50
- request: RetrieveFileContentRequest,
51
- ) -> Response: ...
@@ -1,124 +0,0 @@
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 Annotated
8
-
9
- from fastapi import APIRouter, Depends, UploadFile
10
- from fastapi.param_functions import File, Form
11
- from fastapi.responses import Response
12
-
13
- from llama_stack_api.router_utils import create_path_dependency, create_query_dependency, standard_responses
14
- from llama_stack_api.version import LLAMA_STACK_API_V1
15
-
16
- from .api import Files
17
- from .models import (
18
- DeleteFileRequest,
19
- ExpiresAfter,
20
- ListFilesRequest,
21
- ListOpenAIFileResponse,
22
- OpenAIFileDeleteResponse,
23
- OpenAIFileObject,
24
- OpenAIFilePurpose,
25
- RetrieveFileContentRequest,
26
- RetrieveFileRequest,
27
- UploadFileRequest,
28
- )
29
-
30
- # Automatically generate dependency functions from Pydantic models
31
- # This ensures the models are the single source of truth for descriptions
32
- get_list_files_request = create_query_dependency(ListFilesRequest)
33
- get_get_files_request = create_path_dependency(RetrieveFileRequest)
34
- get_delete_files_request = create_path_dependency(DeleteFileRequest)
35
- get_retrieve_file_content_request = create_path_dependency(RetrieveFileContentRequest)
36
-
37
-
38
- def create_router(impl: Files) -> APIRouter:
39
- router = APIRouter(
40
- prefix=f"/{LLAMA_STACK_API_V1}",
41
- tags=["Files"],
42
- responses=standard_responses,
43
- )
44
-
45
- @router.get(
46
- "/files",
47
- response_model=ListOpenAIFileResponse,
48
- summary="List files",
49
- description="List files",
50
- responses={
51
- 200: {"description": "The list of files."},
52
- },
53
- )
54
- async def list_files(
55
- request: Annotated[ListFilesRequest, Depends(get_list_files_request)],
56
- ) -> ListOpenAIFileResponse:
57
- return await impl.openai_list_files(request)
58
-
59
- @router.get(
60
- "/files/{file_id}",
61
- response_model=OpenAIFileObject,
62
- summary="Get file",
63
- description="Get file",
64
- responses={
65
- 200: {"description": "The file."},
66
- },
67
- )
68
- async def get_file(
69
- request: Annotated[RetrieveFileRequest, Depends(get_get_files_request)],
70
- ) -> OpenAIFileObject:
71
- return await impl.openai_retrieve_file(request)
72
-
73
- @router.delete(
74
- "/files/{file_id}",
75
- response_model=OpenAIFileDeleteResponse,
76
- summary="Delete file",
77
- description="Delete file",
78
- responses={
79
- 200: {"description": "The file was deleted."},
80
- },
81
- )
82
- async def delete_file(
83
- request: Annotated[DeleteFileRequest, Depends(get_delete_files_request)],
84
- ) -> OpenAIFileDeleteResponse:
85
- return await impl.openai_delete_file(request)
86
-
87
- @router.get(
88
- "/files/{file_id}/content",
89
- status_code=200,
90
- summary="Retrieve file content",
91
- description="Retrieve file content",
92
- responses={
93
- 200: {
94
- "description": "The raw file content as a binary response.",
95
- "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Response"}}},
96
- },
97
- },
98
- )
99
- async def retrieve_file_content(
100
- request: Annotated[RetrieveFileContentRequest, Depends(get_retrieve_file_content_request)],
101
- ) -> Response:
102
- return await impl.openai_retrieve_file_content(request)
103
-
104
- @router.post(
105
- "/files",
106
- response_model=OpenAIFileObject,
107
- summary="Upload file",
108
- description="Upload a file.",
109
- responses={
110
- 200: {"description": "The uploaded file."},
111
- },
112
- )
113
- async def upload_file(
114
- file: Annotated[UploadFile, File(description="The file to upload.")],
115
- purpose: Annotated[OpenAIFilePurpose, Form(description="The intended purpose of the uploaded file.")],
116
- expires_after: Annotated[ExpiresAfter | None, Form(description="Optional expiration settings.")] = None,
117
- ) -> OpenAIFileObject:
118
- request = UploadFileRequest(
119
- purpose=purpose,
120
- expires_after=expires_after,
121
- )
122
- return await impl.openai_upload_file(request, file)
123
-
124
- return router
@@ -1,107 +0,0 @@
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
- from typing import ClassVar, Literal
9
-
10
- from pydantic import BaseModel, Field
11
-
12
- from llama_stack_api.common.responses import Order
13
- from llama_stack_api.schema_utils import json_schema_type
14
-
15
-
16
- class OpenAIFilePurpose(StrEnum):
17
- """
18
- Valid purpose values for OpenAI Files API.
19
- """
20
-
21
- ASSISTANTS = "assistants"
22
- BATCH = "batch"
23
-
24
-
25
- @json_schema_type
26
- class OpenAIFileObject(BaseModel):
27
- """OpenAI File object as defined in the OpenAI Files API."""
28
-
29
- object: Literal["file"] = Field(default="file", description="The object type, which is always 'file'.")
30
- id: str = Field(..., description="The file identifier, which can be referenced in the API endpoints.")
31
- bytes: int = Field(..., description="The size of the file, in bytes.")
32
- created_at: int = Field(..., description="The Unix timestamp (in seconds) for when the file was created.")
33
- expires_at: int = Field(..., description="The Unix timestamp (in seconds) for when the file expires.")
34
- filename: str = Field(..., description="The name of the file.")
35
- purpose: OpenAIFilePurpose = Field(..., description="The intended purpose of the file.")
36
-
37
-
38
- @json_schema_type
39
- class ExpiresAfter(BaseModel):
40
- """Control expiration of uploaded files."""
41
-
42
- MIN: ClassVar[int] = 3600 # 1 hour
43
- MAX: ClassVar[int] = 2592000 # 30 days
44
-
45
- anchor: Literal["created_at"] = Field(..., description="The anchor point for expiration, must be 'created_at'.")
46
- seconds: int = Field(
47
- ..., ge=MIN, le=MAX, description="Seconds until expiration, between 3600 (1 hour) and 2592000 (30 days)."
48
- )
49
-
50
-
51
- @json_schema_type
52
- class ListOpenAIFileResponse(BaseModel):
53
- """Response for listing files in OpenAI Files API."""
54
-
55
- data: list[OpenAIFileObject] = Field(..., description="The list of files.")
56
- has_more: bool = Field(..., description="Whether there are more files available beyond this page.")
57
- first_id: str = Field(..., description="The ID of the first file in the list for pagination.")
58
- last_id: str = Field(..., description="The ID of the last file in the list for pagination.")
59
- object: Literal["list"] = Field(default="list", description="The object type, which is always 'list'.")
60
-
61
-
62
- @json_schema_type
63
- class OpenAIFileDeleteResponse(BaseModel):
64
- """Response for deleting a file in OpenAI Files API."""
65
-
66
- id: str = Field(..., description="The file identifier that was deleted.")
67
- object: Literal["file"] = Field(default="file", description="The object type, which is always 'file'.")
68
- deleted: bool = Field(..., description="Whether the file was successfully deleted.")
69
-
70
-
71
- @json_schema_type
72
- class ListFilesRequest(BaseModel):
73
- """Request model for listing files."""
74
-
75
- after: str | None = Field(default=None, description="A cursor for pagination. Returns files after this ID.")
76
- limit: int | None = Field(default=10000, description="Maximum number of files to return (1-10,000).")
77
- order: Order | None = Field(default=Order.desc, description="Sort order by created_at timestamp ('asc' or 'desc').")
78
- purpose: OpenAIFilePurpose | None = Field(default=None, description="Filter files by purpose.")
79
-
80
-
81
- @json_schema_type
82
- class RetrieveFileRequest(BaseModel):
83
- """Request model for retrieving a file."""
84
-
85
- file_id: str = Field(..., description="The ID of the file to retrieve.")
86
-
87
-
88
- @json_schema_type
89
- class DeleteFileRequest(BaseModel):
90
- """Request model for deleting a file."""
91
-
92
- file_id: str = Field(..., description="The ID of the file to delete.")
93
-
94
-
95
- @json_schema_type
96
- class RetrieveFileContentRequest(BaseModel):
97
- """Request model for retrieving file content."""
98
-
99
- file_id: str = Field(..., description="The ID of the file to retrieve content from.")
100
-
101
-
102
- @json_schema_type
103
- class UploadFileRequest(BaseModel):
104
- """Request model for uploading a file."""
105
-
106
- purpose: OpenAIFilePurpose = Field(..., description="The intended purpose of the uploaded file.")
107
- expires_after: ExpiresAfter | None = Field(default=None, description="Optional expiration settings for the file.")