From 2664aeee2a9705b6d34f650428d6043a96937acd Mon Sep 17 00:00:00 2001 From: Alina Ryan Date: Sat, 8 Nov 2025 23:50:49 -0500 Subject: [PATCH 1/2] feat(api): add file_processor API skeleton This change adds a file_processor API skeleton that provides a foundationfor converting files into structured content for vector store ingestionwith support for chunking strategies and optional embedding generation. Signed-off-by: Alina Ryan --- docs/docs/providers/file_processor/index.mdx | 10 ++ .../file_processor/inline_reference.mdx | 17 ++++ src/llama_stack/apis/datatypes.py | 1 + .../apis/file_processor/__init__.py | 7 ++ .../apis/file_processor/file_processor.py | 96 +++++++++++++++++++ src/llama_stack/core/resolver.py | 2 + .../distributions/ci-tests/build.yaml | 2 + .../distributions/ci-tests/run.yaml | 4 + .../distributions/starter-gpu/build.yaml | 2 + .../starter-gpu/run-with-postgres-store.yaml | 4 + .../distributions/starter-gpu/run.yaml | 4 + .../distributions/starter/build.yaml | 2 + .../starter/run-with-postgres-store.yaml | 4 + .../distributions/starter/run.yaml | 4 + .../distributions/starter/starter.py | 1 + src/llama_stack/log.py | 1 + .../inline/file_processor/__init__.py | 5 + .../file_processor/reference/__init__.py | 15 +++ .../inline/file_processor/reference/config.py | 15 +++ .../file_processor/reference/reference.py | 42 ++++++++ .../providers/registry/file_processor.py | 20 ++++ 21 files changed, 258 insertions(+) create mode 100644 docs/docs/providers/file_processor/index.mdx create mode 100644 docs/docs/providers/file_processor/inline_reference.mdx create mode 100644 src/llama_stack/apis/file_processor/__init__.py create mode 100644 src/llama_stack/apis/file_processor/file_processor.py create mode 100644 src/llama_stack/providers/inline/file_processor/__init__.py create mode 100644 src/llama_stack/providers/inline/file_processor/reference/__init__.py create mode 100644 src/llama_stack/providers/inline/file_processor/reference/config.py create mode 100644 src/llama_stack/providers/inline/file_processor/reference/reference.py create mode 100644 src/llama_stack/providers/registry/file_processor.py diff --git a/docs/docs/providers/file_processor/index.mdx b/docs/docs/providers/file_processor/index.mdx new file mode 100644 index 000000000..3355112f4 --- /dev/null +++ b/docs/docs/providers/file_processor/index.mdx @@ -0,0 +1,10 @@ +--- +sidebar_label: File Processor +title: File_Processor +--- + +# File_Processor + +## Overview + +This section contains documentation for all available providers for the **file_processor** API. diff --git a/docs/docs/providers/file_processor/inline_reference.mdx b/docs/docs/providers/file_processor/inline_reference.mdx new file mode 100644 index 000000000..9fe76f51f --- /dev/null +++ b/docs/docs/providers/file_processor/inline_reference.mdx @@ -0,0 +1,17 @@ +--- +description: "Reference file processor implementation (placeholder for development)" +sidebar_label: Reference +title: inline::reference +--- + +# inline::reference + +## Description + +Reference file processor implementation (placeholder for development) + +## Sample Configuration + +```yaml +{} +``` diff --git a/src/llama_stack/apis/datatypes.py b/src/llama_stack/apis/datatypes.py index ae01c5dfc..126dee1d7 100644 --- a/src/llama_stack/apis/datatypes.py +++ b/src/llama_stack/apis/datatypes.py @@ -127,6 +127,7 @@ class Api(Enum, metaclass=DynamicApiMeta): files = "files" prompts = "prompts" conversations = "conversations" + file_processor = "file_processor" # built-in API inspect = "inspect" diff --git a/src/llama_stack/apis/file_processor/__init__.py b/src/llama_stack/apis/file_processor/__init__.py new file mode 100644 index 000000000..295141a21 --- /dev/null +++ b/src/llama_stack/apis/file_processor/__init__.py @@ -0,0 +1,7 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from .file_processor import * diff --git a/src/llama_stack/apis/file_processor/file_processor.py b/src/llama_stack/apis/file_processor/file_processor.py new file mode 100644 index 000000000..a0785682f --- /dev/null +++ b/src/llama_stack/apis/file_processor/file_processor.py @@ -0,0 +1,96 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from typing import Any, Protocol, runtime_checkable + +from pydantic import BaseModel + +from llama_stack.apis.common.tracing import telemetry_traceable +from llama_stack.apis.vector_io.vector_io import Chunk, VectorStoreChunkingStrategy +from llama_stack.apis.version import LLAMA_STACK_API_V1ALPHA +from llama_stack.schema_utils import json_schema_type, webmethod + + +@json_schema_type +class ProcessFileRequest(BaseModel): + """Request for processing a file into structured content.""" + + file_data: bytes + """Raw file data to process.""" + + filename: str + """Original filename for format detection and processing hints.""" + + options: dict[str, Any] | None = None + """Optional processing options. Provider-specific parameters.""" + + chunking_strategy: VectorStoreChunkingStrategy | None = None + """Optional chunking strategy for splitting content into chunks.""" + + include_embeddings: bool = False + """Whether to generate embeddings for chunks.""" + + +@json_schema_type +class ProcessedContent(BaseModel): + """Result of file processing operation.""" + + content: str + """Extracted text content from the file.""" + + chunks: list[Chunk] | None = None + """Optional chunks if chunking strategy was provided.""" + + embeddings: list[list[float]] | None = None + """Optional embeddings for chunks if requested.""" + + metadata: dict[str, Any] + """Processing metadata including processor name, timing, and provider-specific data.""" + + +@telemetry_traceable +@runtime_checkable +class FileProcessor(Protocol): + """ + File Processor API for converting files into structured, processable content. + + This API provides a flexible interface for processing various file formats + (PDFs, documents, images, etc.) into text content that can be used for + vector store ingestion, RAG applications, or standalone content extraction. + + The API supports: + - Multiple file formats through extensible provider architecture + - Configurable processing options per provider + - Integration with vector store chunking strategies + - Optional embedding generation for chunks + - Rich metadata about processing results + + Future providers can extend this interface to support additional formats, + processing capabilities, and optimization strategies. + """ + + @webmethod(route="/file-processor/process", method="POST", level=LLAMA_STACK_API_V1ALPHA) + async def process_file( + self, + file_data: bytes, + filename: str, + options: dict[str, Any] | None = None, + chunking_strategy: VectorStoreChunkingStrategy | None = None, + include_embeddings: bool = False, + ) -> ProcessedContent: + """ + Process a file into structured content with optional chunking and embeddings. + + This method processes raw file data and converts it into text content for applications such as vector store ingestion. + + :param file_data: Raw bytes of the file to process. + :param filename: Original filename for format detection. + :param options: Provider-specific processing options (e.g., OCR settings, output format). + :param chunking_strategy: Optional strategy for splitting content into chunks. + :param include_embeddings: Whether to generate embeddings for chunks. + :returns: ProcessedContent with extracted text, optional chunks, and metadata. + """ + ... diff --git a/src/llama_stack/core/resolver.py b/src/llama_stack/core/resolver.py index 8bf371fed..e78bcc1fa 100644 --- a/src/llama_stack/core/resolver.py +++ b/src/llama_stack/core/resolver.py @@ -16,6 +16,7 @@ from llama_stack.apis.datasetio import DatasetIO from llama_stack.apis.datasets import Datasets from llama_stack.apis.datatypes import ExternalApiSpec from llama_stack.apis.eval import Eval +from llama_stack.apis.file_processor import FileProcessor from llama_stack.apis.files import Files from llama_stack.apis.inference import Inference, InferenceProvider from llama_stack.apis.inspect import Inspect @@ -96,6 +97,7 @@ def api_protocol_map(external_apis: dict[Api, ExternalApiSpec] | None = None) -> Api.files: Files, Api.prompts: Prompts, Api.conversations: Conversations, + Api.file_processor: FileProcessor, } if external_apis: diff --git a/src/llama_stack/distributions/ci-tests/build.yaml b/src/llama_stack/distributions/ci-tests/build.yaml index f29ac7712..ef2e552c0 100644 --- a/src/llama_stack/distributions/ci-tests/build.yaml +++ b/src/llama_stack/distributions/ci-tests/build.yaml @@ -29,6 +29,8 @@ distribution_spec: - provider_type: remote::weaviate files: - provider_type: inline::localfs + file_processor: + - provider_type: inline::reference safety: - provider_type: inline::llama-guard - provider_type: inline::code-scanner diff --git a/src/llama_stack/distributions/ci-tests/run.yaml b/src/llama_stack/distributions/ci-tests/run.yaml index 1118d2ad1..73af10001 100644 --- a/src/llama_stack/distributions/ci-tests/run.yaml +++ b/src/llama_stack/distributions/ci-tests/run.yaml @@ -5,6 +5,7 @@ apis: - batches - datasetio - eval +- file_processor - files - inference - post_training @@ -154,6 +155,9 @@ providers: metadata_store: table_name: files_metadata backend: sql_default + file_processor: + - provider_id: reference + provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter-gpu/build.yaml b/src/llama_stack/distributions/starter-gpu/build.yaml index 10cbb1389..e286bc3d8 100644 --- a/src/llama_stack/distributions/starter-gpu/build.yaml +++ b/src/llama_stack/distributions/starter-gpu/build.yaml @@ -30,6 +30,8 @@ distribution_spec: - provider_type: remote::weaviate files: - provider_type: inline::localfs + file_processor: + - provider_type: inline::reference safety: - provider_type: inline::llama-guard - provider_type: inline::code-scanner diff --git a/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml b/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml index 1920ebd9d..e0cab6618 100644 --- a/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml +++ b/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml @@ -5,6 +5,7 @@ apis: - batches - datasetio - eval +- file_processor - files - inference - post_training @@ -154,6 +155,9 @@ providers: metadata_store: table_name: files_metadata backend: sql_default + file_processor: + - provider_id: reference + provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter-gpu/run.yaml b/src/llama_stack/distributions/starter-gpu/run.yaml index 7149b8659..367788b3d 100644 --- a/src/llama_stack/distributions/starter-gpu/run.yaml +++ b/src/llama_stack/distributions/starter-gpu/run.yaml @@ -5,6 +5,7 @@ apis: - batches - datasetio - eval +- file_processor - files - inference - post_training @@ -154,6 +155,9 @@ providers: metadata_store: table_name: files_metadata backend: sql_default + file_processor: + - provider_id: reference + provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter/build.yaml b/src/llama_stack/distributions/starter/build.yaml index acd51f773..e673cc3e6 100644 --- a/src/llama_stack/distributions/starter/build.yaml +++ b/src/llama_stack/distributions/starter/build.yaml @@ -30,6 +30,8 @@ distribution_spec: - provider_type: remote::weaviate files: - provider_type: inline::localfs + file_processor: + - provider_type: inline::reference safety: - provider_type: inline::llama-guard - provider_type: inline::code-scanner diff --git a/src/llama_stack/distributions/starter/run-with-postgres-store.yaml b/src/llama_stack/distributions/starter/run-with-postgres-store.yaml index 702f95381..0f1616766 100644 --- a/src/llama_stack/distributions/starter/run-with-postgres-store.yaml +++ b/src/llama_stack/distributions/starter/run-with-postgres-store.yaml @@ -5,6 +5,7 @@ apis: - batches - datasetio - eval +- file_processor - files - inference - post_training @@ -154,6 +155,9 @@ providers: metadata_store: table_name: files_metadata backend: sql_default + file_processor: + - provider_id: reference + provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter/run.yaml b/src/llama_stack/distributions/starter/run.yaml index 0ce392810..3cf9f7d04 100644 --- a/src/llama_stack/distributions/starter/run.yaml +++ b/src/llama_stack/distributions/starter/run.yaml @@ -5,6 +5,7 @@ apis: - batches - datasetio - eval +- file_processor - files - inference - post_training @@ -154,6 +155,9 @@ providers: metadata_store: table_name: files_metadata backend: sql_default + file_processor: + - provider_id: reference + provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter/starter.py b/src/llama_stack/distributions/starter/starter.py index 88cd3a4fe..068c6ded8 100644 --- a/src/llama_stack/distributions/starter/starter.py +++ b/src/llama_stack/distributions/starter/starter.py @@ -128,6 +128,7 @@ def get_distribution_template(name: str = "starter") -> DistributionTemplate: BuildProvider(provider_type="remote::weaviate"), ], "files": [BuildProvider(provider_type="inline::localfs")], + "file_processor": [BuildProvider(provider_type="inline::reference")], "safety": [ BuildProvider(provider_type="inline::llama-guard"), BuildProvider(provider_type="inline::code-scanner"), diff --git a/src/llama_stack/log.py b/src/llama_stack/log.py index c11c2c06f..83e6b96b6 100644 --- a/src/llama_stack/log.py +++ b/src/llama_stack/log.py @@ -45,6 +45,7 @@ CATEGORIES = [ "providers", "models", "files", + "file_processor", "vector_io", "tool_runtime", "cli", diff --git a/src/llama_stack/providers/inline/file_processor/__init__.py b/src/llama_stack/providers/inline/file_processor/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/src/llama_stack/providers/inline/file_processor/__init__.py @@ -0,0 +1,5 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. diff --git a/src/llama_stack/providers/inline/file_processor/reference/__init__.py b/src/llama_stack/providers/inline/file_processor/reference/__init__.py new file mode 100644 index 000000000..3c8b6a7ec --- /dev/null +++ b/src/llama_stack/providers/inline/file_processor/reference/__init__.py @@ -0,0 +1,15 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from .config import ReferenceFileProcessorImplConfig + + +async def get_provider_impl(config: ReferenceFileProcessorImplConfig, deps): + from .reference import ReferenceFileProcessorImpl + + impl = ReferenceFileProcessorImpl(config, deps) + await impl.initialize() + return impl diff --git a/src/llama_stack/providers/inline/file_processor/reference/config.py b/src/llama_stack/providers/inline/file_processor/reference/config.py new file mode 100644 index 000000000..7c6de7483 --- /dev/null +++ b/src/llama_stack/providers/inline/file_processor/reference/config.py @@ -0,0 +1,15 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from pydantic import BaseModel + + +class ReferenceFileProcessorImplConfig(BaseModel): + """Configuration for the reference file processor implementation.""" + + @staticmethod + def sample_run_config(**kwargs): + return {} diff --git a/src/llama_stack/providers/inline/file_processor/reference/reference.py b/src/llama_stack/providers/inline/file_processor/reference/reference.py new file mode 100644 index 000000000..1aaf1efa3 --- /dev/null +++ b/src/llama_stack/providers/inline/file_processor/reference/reference.py @@ -0,0 +1,42 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from typing import Any + +from llama_stack.apis.file_processor import FileProcessor, ProcessedContent +from llama_stack.apis.vector_io import VectorStoreChunkingStrategy + +from .config import ReferenceFileProcessorImplConfig + + +class ReferenceFileProcessorImpl(FileProcessor): + """Reference implementation of the FileProcessor API.""" + + def __init__(self, config: ReferenceFileProcessorImplConfig, deps: dict[str, Any]): + self.config = config + self.deps = deps + + async def initialize(self) -> None: + pass + + async def process_file( + self, + file_data: bytes, + filename: str, + options: dict[str, Any] | None = None, + chunking_strategy: VectorStoreChunkingStrategy | None = None, + include_embeddings: bool = False, + ) -> ProcessedContent: + """Process a file into structured content.""" + return ProcessedContent( + content="Placeholder content", + chunks=None, + embeddings=None, + metadata={ + "processor": "reference", + "filename": filename, + }, + ) diff --git a/src/llama_stack/providers/registry/file_processor.py b/src/llama_stack/providers/registry/file_processor.py new file mode 100644 index 000000000..173e5a393 --- /dev/null +++ b/src/llama_stack/providers/registry/file_processor.py @@ -0,0 +1,20 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from llama_stack.providers.datatypes import Api, InlineProviderSpec, ProviderSpec + + +def available_providers() -> list[ProviderSpec]: + return [ + InlineProviderSpec( + api=Api.file_processor, + provider_type="inline::reference", + pip_packages=[], + module="llama_stack.providers.inline.file_processor.reference", + config_class="llama_stack.providers.inline.file_processor.reference.config.ReferenceFileProcessorImplConfig", + description="Reference file processor implementation (placeholder for development)", + ), + ] From c2f0db912843c0656863b11779d50bd79d5f327a Mon Sep 17 00:00:00 2001 From: Alina Ryan Date: Tue, 25 Nov 2025 19:44:59 -0500 Subject: [PATCH 2/2] fix: address first round of reviews Signed-off-by: Alina Ryan --- client-sdks/stainless/openapi.yml | 8 ++-- docs/docs/providers/file_processors/index.mdx | 10 +++++ docs/static/deprecated-llama-stack-spec.yaml | 2 +- .../static/experimental-llama-stack-spec.yaml | 8 ++-- docs/static/llama-stack-spec.yaml | 2 +- docs/static/stainless-llama-stack-spec.yaml | 8 ++-- src/llama_stack/core/resolver.py | 4 +- .../distributions/ci-tests/build.yaml | 2 - .../ci-tests/run-with-postgres-store.yaml | 4 -- .../distributions/ci-tests/run.yaml | 4 -- .../distributions/starter-gpu/build.yaml | 2 - .../starter-gpu/run-with-postgres-store.yaml | 4 -- .../distributions/starter-gpu/run.yaml | 4 -- .../distributions/starter/build.yaml | 2 - .../starter/run-with-postgres-store.yaml | 4 -- .../distributions/starter/run.yaml | 4 -- .../distributions/starter/starter.py | 1 - src/llama_stack/log.py | 2 +- .../file_processor/reference/__init__.py | 15 ------- .../inline/file_processor/reference/config.py | 15 ------- .../file_processor/reference/reference.py | 41 ------------------- .../providers/registry/file_processor.py | 20 --------- .../providers/registry/file_processors.py | 11 +++++ src/llama_stack_api/__init__.py | 4 +- src/llama_stack_api/datatypes.py | 4 +- .../{file_processor.py => file_processors.py} | 4 +- 26 files changed, 44 insertions(+), 145 deletions(-) create mode 100644 docs/docs/providers/file_processors/index.mdx delete mode 100644 src/llama_stack/providers/inline/file_processor/reference/__init__.py delete mode 100644 src/llama_stack/providers/inline/file_processor/reference/config.py delete mode 100644 src/llama_stack/providers/inline/file_processor/reference/reference.py delete mode 100644 src/llama_stack/providers/registry/file_processor.py create mode 100644 src/llama_stack/providers/registry/file_processors.py rename src/llama_stack_api/{file_processor.py => file_processors.py} (96%) diff --git a/client-sdks/stainless/openapi.yml b/client-sdks/stainless/openapi.yml index 359508f30..5e5982d8a 100644 --- a/client-sdks/stainless/openapi.yml +++ b/client-sdks/stainless/openapi.yml @@ -3887,7 +3887,7 @@ paths: schema: $ref: '#/components/schemas/SupervisedFineTuneRequest' required: true - /v1alpha/file-processor/process: + /v1alpha/file-processors/process: post: responses: '200': @@ -3909,13 +3909,13 @@ paths: description: Default Response $ref: '#/components/responses/DefaultError' tags: - - File Processor + - File Processors summary: Process File description: |- Process a file into structured content with optional chunking and embeddings. This method processes raw file data and converts it into text content for applications such as vector store ingestion. - operationId: process_file_v1alpha_file_processor_process_post + operationId: process_file_v1alpha_file_processors_process_post requestBody: content: application/json: @@ -13005,7 +13005,7 @@ components: - benchmarks - tool_groups - files - - file_processor + - file_processors - prompts - conversations - inspect diff --git a/docs/docs/providers/file_processors/index.mdx b/docs/docs/providers/file_processors/index.mdx new file mode 100644 index 000000000..e9119d40e --- /dev/null +++ b/docs/docs/providers/file_processors/index.mdx @@ -0,0 +1,10 @@ +--- +sidebar_label: File Processors +title: File_Processors +--- + +# File_Processors + +## Overview + +This section contains documentation for all available providers for the **file_processors** API. diff --git a/docs/static/deprecated-llama-stack-spec.yaml b/docs/static/deprecated-llama-stack-spec.yaml index 0c3a77bcb..c471cc39a 100644 --- a/docs/static/deprecated-llama-stack-spec.yaml +++ b/docs/static/deprecated-llama-stack-spec.yaml @@ -9813,7 +9813,7 @@ components: - benchmarks - tool_groups - files - - file_processor + - file_processors - prompts - conversations - inspect diff --git a/docs/static/experimental-llama-stack-spec.yaml b/docs/static/experimental-llama-stack-spec.yaml index 0a6493d65..89128f887 100644 --- a/docs/static/experimental-llama-stack-spec.yaml +++ b/docs/static/experimental-llama-stack-spec.yaml @@ -630,7 +630,7 @@ paths: schema: $ref: '#/components/schemas/SupervisedFineTuneRequest' required: true - /v1alpha/file-processor/process: + /v1alpha/file-processors/process: post: responses: '200': @@ -652,13 +652,13 @@ paths: description: Default Response $ref: '#/components/responses/DefaultError' tags: - - File Processor + - File Processors summary: Process File description: |- Process a file into structured content with optional chunking and embeddings. This method processes raw file data and converts it into text content for applications such as vector store ingestion. - operationId: process_file_v1alpha_file_processor_process_post + operationId: process_file_v1alpha_file_processors_process_post requestBody: content: application/json: @@ -8777,7 +8777,7 @@ components: - benchmarks - tool_groups - files - - file_processor + - file_processors - prompts - conversations - inspect diff --git a/docs/static/llama-stack-spec.yaml b/docs/static/llama-stack-spec.yaml index 2c6025f2e..132db6a44 100644 --- a/docs/static/llama-stack-spec.yaml +++ b/docs/static/llama-stack-spec.yaml @@ -11640,7 +11640,7 @@ components: - benchmarks - tool_groups - files - - file_processor + - file_processors - prompts - conversations - inspect diff --git a/docs/static/stainless-llama-stack-spec.yaml b/docs/static/stainless-llama-stack-spec.yaml index 359508f30..5e5982d8a 100644 --- a/docs/static/stainless-llama-stack-spec.yaml +++ b/docs/static/stainless-llama-stack-spec.yaml @@ -3887,7 +3887,7 @@ paths: schema: $ref: '#/components/schemas/SupervisedFineTuneRequest' required: true - /v1alpha/file-processor/process: + /v1alpha/file-processors/process: post: responses: '200': @@ -3909,13 +3909,13 @@ paths: description: Default Response $ref: '#/components/responses/DefaultError' tags: - - File Processor + - File Processors summary: Process File description: |- Process a file into structured content with optional chunking and embeddings. This method processes raw file data and converts it into text content for applications such as vector store ingestion. - operationId: process_file_v1alpha_file_processor_process_post + operationId: process_file_v1alpha_file_processors_process_post requestBody: content: application/json: @@ -13005,7 +13005,7 @@ components: - benchmarks - tool_groups - files - - file_processor + - file_processors - prompts - conversations - inspect diff --git a/src/llama_stack/core/resolver.py b/src/llama_stack/core/resolver.py index df6693338..f8a70f1ee 100644 --- a/src/llama_stack/core/resolver.py +++ b/src/llama_stack/core/resolver.py @@ -34,7 +34,7 @@ from llama_stack_api import ( DatasetsProtocolPrivate, Eval, ExternalApiSpec, - FileProcessor, + FileProcessors, Files, Inference, InferenceProvider, @@ -101,7 +101,7 @@ def api_protocol_map(external_apis: dict[Api, ExternalApiSpec] | None = None) -> Api.files: Files, Api.prompts: Prompts, Api.conversations: Conversations, - Api.file_processor: FileProcessor, + Api.file_processors: FileProcessors, } if external_apis: diff --git a/src/llama_stack/distributions/ci-tests/build.yaml b/src/llama_stack/distributions/ci-tests/build.yaml index ef2e552c0..f29ac7712 100644 --- a/src/llama_stack/distributions/ci-tests/build.yaml +++ b/src/llama_stack/distributions/ci-tests/build.yaml @@ -29,8 +29,6 @@ distribution_spec: - provider_type: remote::weaviate files: - provider_type: inline::localfs - file_processor: - - provider_type: inline::reference safety: - provider_type: inline::llama-guard - provider_type: inline::code-scanner diff --git a/src/llama_stack/distributions/ci-tests/run-with-postgres-store.yaml b/src/llama_stack/distributions/ci-tests/run-with-postgres-store.yaml index 62eb08b3d..7721138c7 100644 --- a/src/llama_stack/distributions/ci-tests/run-with-postgres-store.yaml +++ b/src/llama_stack/distributions/ci-tests/run-with-postgres-store.yaml @@ -5,7 +5,6 @@ apis: - batches - datasetio - eval -- file_processor - files - inference - post_training @@ -154,9 +153,6 @@ providers: metadata_store: table_name: files_metadata backend: sql_default - file_processor: - - provider_id: reference - provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/ci-tests/run.yaml b/src/llama_stack/distributions/ci-tests/run.yaml index e610c7601..b791e1488 100644 --- a/src/llama_stack/distributions/ci-tests/run.yaml +++ b/src/llama_stack/distributions/ci-tests/run.yaml @@ -5,7 +5,6 @@ apis: - batches - datasetio - eval -- file_processor - files - inference - post_training @@ -154,9 +153,6 @@ providers: metadata_store: table_name: files_metadata backend: sql_default - file_processor: - - provider_id: reference - provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter-gpu/build.yaml b/src/llama_stack/distributions/starter-gpu/build.yaml index e286bc3d8..10cbb1389 100644 --- a/src/llama_stack/distributions/starter-gpu/build.yaml +++ b/src/llama_stack/distributions/starter-gpu/build.yaml @@ -30,8 +30,6 @@ distribution_spec: - provider_type: remote::weaviate files: - provider_type: inline::localfs - file_processor: - - provider_type: inline::reference safety: - provider_type: inline::llama-guard - provider_type: inline::code-scanner diff --git a/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml b/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml index 37199a35a..9c250c05a 100644 --- a/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml +++ b/src/llama_stack/distributions/starter-gpu/run-with-postgres-store.yaml @@ -5,7 +5,6 @@ apis: - batches - datasetio - eval -- file_processor - files - inference - post_training @@ -154,9 +153,6 @@ providers: metadata_store: table_name: files_metadata backend: sql_default - file_processor: - - provider_id: reference - provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter-gpu/run.yaml b/src/llama_stack/distributions/starter-gpu/run.yaml index 14dbeb341..65f9ae326 100644 --- a/src/llama_stack/distributions/starter-gpu/run.yaml +++ b/src/llama_stack/distributions/starter-gpu/run.yaml @@ -5,7 +5,6 @@ apis: - batches - datasetio - eval -- file_processor - files - inference - post_training @@ -154,9 +153,6 @@ providers: metadata_store: table_name: files_metadata backend: sql_default - file_processor: - - provider_id: reference - provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter/build.yaml b/src/llama_stack/distributions/starter/build.yaml index e673cc3e6..acd51f773 100644 --- a/src/llama_stack/distributions/starter/build.yaml +++ b/src/llama_stack/distributions/starter/build.yaml @@ -30,8 +30,6 @@ distribution_spec: - provider_type: remote::weaviate files: - provider_type: inline::localfs - file_processor: - - provider_type: inline::reference safety: - provider_type: inline::llama-guard - provider_type: inline::code-scanner diff --git a/src/llama_stack/distributions/starter/run-with-postgres-store.yaml b/src/llama_stack/distributions/starter/run-with-postgres-store.yaml index a84a5a243..3314bb9e9 100644 --- a/src/llama_stack/distributions/starter/run-with-postgres-store.yaml +++ b/src/llama_stack/distributions/starter/run-with-postgres-store.yaml @@ -5,7 +5,6 @@ apis: - batches - datasetio - eval -- file_processor - files - inference - post_training @@ -154,9 +153,6 @@ providers: metadata_store: table_name: files_metadata backend: sql_default - file_processor: - - provider_id: reference - provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter/run.yaml b/src/llama_stack/distributions/starter/run.yaml index f2ebb4aef..e88539e6a 100644 --- a/src/llama_stack/distributions/starter/run.yaml +++ b/src/llama_stack/distributions/starter/run.yaml @@ -5,7 +5,6 @@ apis: - batches - datasetio - eval -- file_processor - files - inference - post_training @@ -154,9 +153,6 @@ providers: metadata_store: table_name: files_metadata backend: sql_default - file_processor: - - provider_id: reference - provider_type: inline::reference safety: - provider_id: llama-guard provider_type: inline::llama-guard diff --git a/src/llama_stack/distributions/starter/starter.py b/src/llama_stack/distributions/starter/starter.py index 9ce0eb799..32264eebb 100644 --- a/src/llama_stack/distributions/starter/starter.py +++ b/src/llama_stack/distributions/starter/starter.py @@ -123,7 +123,6 @@ def get_distribution_template(name: str = "starter") -> DistributionTemplate: BuildProvider(provider_type="remote::weaviate"), ], "files": [BuildProvider(provider_type="inline::localfs")], - "file_processor": [BuildProvider(provider_type="inline::reference")], "safety": [ BuildProvider(provider_type="inline::llama-guard"), BuildProvider(provider_type="inline::code-scanner"), diff --git a/src/llama_stack/log.py b/src/llama_stack/log.py index 83e6b96b6..92c137073 100644 --- a/src/llama_stack/log.py +++ b/src/llama_stack/log.py @@ -45,7 +45,7 @@ CATEGORIES = [ "providers", "models", "files", - "file_processor", + "file_processors", "vector_io", "tool_runtime", "cli", diff --git a/src/llama_stack/providers/inline/file_processor/reference/__init__.py b/src/llama_stack/providers/inline/file_processor/reference/__init__.py deleted file mode 100644 index 3c8b6a7ec..000000000 --- a/src/llama_stack/providers/inline/file_processor/reference/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. - -from .config import ReferenceFileProcessorImplConfig - - -async def get_provider_impl(config: ReferenceFileProcessorImplConfig, deps): - from .reference import ReferenceFileProcessorImpl - - impl = ReferenceFileProcessorImpl(config, deps) - await impl.initialize() - return impl diff --git a/src/llama_stack/providers/inline/file_processor/reference/config.py b/src/llama_stack/providers/inline/file_processor/reference/config.py deleted file mode 100644 index 7c6de7483..000000000 --- a/src/llama_stack/providers/inline/file_processor/reference/config.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. - -from pydantic import BaseModel - - -class ReferenceFileProcessorImplConfig(BaseModel): - """Configuration for the reference file processor implementation.""" - - @staticmethod - def sample_run_config(**kwargs): - return {} diff --git a/src/llama_stack/providers/inline/file_processor/reference/reference.py b/src/llama_stack/providers/inline/file_processor/reference/reference.py deleted file mode 100644 index c69675bdf..000000000 --- a/src/llama_stack/providers/inline/file_processor/reference/reference.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. - -from typing import Any - -from llama_stack_api import FileProcessor, ProcessedContent, VectorStoreChunkingStrategy - -from .config import ReferenceFileProcessorImplConfig - - -class ReferenceFileProcessorImpl(FileProcessor): - """Reference implementation of the FileProcessor API.""" - - def __init__(self, config: ReferenceFileProcessorImplConfig, deps: dict[str, Any]): - self.config = config - self.deps = deps - - async def initialize(self) -> None: - pass - - async def process_file( - self, - file_data: bytes, - filename: str, - options: dict[str, Any] | None = None, - chunking_strategy: VectorStoreChunkingStrategy | None = None, - include_embeddings: bool = False, - ) -> ProcessedContent: - """Process a file into structured content.""" - return ProcessedContent( - content="Placeholder content", - chunks=None, - embeddings=None, - metadata={ - "processor": "reference", - "filename": filename, - }, - ) diff --git a/src/llama_stack/providers/registry/file_processor.py b/src/llama_stack/providers/registry/file_processor.py deleted file mode 100644 index b930928a8..000000000 --- a/src/llama_stack/providers/registry/file_processor.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. - -from llama_stack_api import Api, InlineProviderSpec, ProviderSpec - - -def available_providers() -> list[ProviderSpec]: - return [ - InlineProviderSpec( - api=Api.file_processor, - provider_type="inline::reference", - pip_packages=[], - module="llama_stack.providers.inline.file_processor.reference", - config_class="llama_stack.providers.inline.file_processor.reference.config.ReferenceFileProcessorImplConfig", - description="Reference file processor implementation (placeholder for development)", - ), - ] diff --git a/src/llama_stack/providers/registry/file_processors.py b/src/llama_stack/providers/registry/file_processors.py new file mode 100644 index 000000000..fef58de51 --- /dev/null +++ b/src/llama_stack/providers/registry/file_processors.py @@ -0,0 +1,11 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + +from llama_stack_api import ProviderSpec + + +def available_providers() -> list[ProviderSpec]: + return [] diff --git a/src/llama_stack_api/__init__.py b/src/llama_stack_api/__init__.py index 139627cfa..758059047 100644 --- a/src/llama_stack_api/__init__.py +++ b/src/llama_stack_api/__init__.py @@ -112,7 +112,7 @@ from .datatypes import ( VectorStoresProtocolPrivate, ) from .eval import BenchmarkConfig, Eval, EvalCandidate, EvaluateResponse, ModelCandidate -from .file_processor import FileProcessor, ProcessedContent, ProcessFileRequest +from .file_processors import FileProcessors, ProcessedContent, ProcessFileRequest from .files import ( ExpiresAfter, Files, @@ -519,7 +519,7 @@ __all__ = [ "ExpiresAfter", "ExternalApiSpec", "ExtraBodyField", - "FileProcessor", + "FileProcessors", "Files", "Fp8QuantizationConfig", "clear_dynamic_schema_types", diff --git a/src/llama_stack_api/datatypes.py b/src/llama_stack_api/datatypes.py index 34bb8ddc2..fb8ed7039 100644 --- a/src/llama_stack_api/datatypes.py +++ b/src/llama_stack_api/datatypes.py @@ -110,7 +110,7 @@ class Api(Enum, metaclass=DynamicApiMeta): :cvar benchmarks: Benchmark suite management :cvar tool_groups: Tool group organization :cvar files: File storage and management - :cvar file_processor: File parsing and processing operations + :cvar file_processors: File parsing and processing operations :cvar prompts: Prompt versions and management :cvar inspect: Built-in system inspection and introspection """ @@ -135,7 +135,7 @@ class Api(Enum, metaclass=DynamicApiMeta): benchmarks = "benchmarks" tool_groups = "tool_groups" files = "files" - file_processor = "file_processor" + file_processors = "file_processors" prompts = "prompts" conversations = "conversations" diff --git a/src/llama_stack_api/file_processor.py b/src/llama_stack_api/file_processors.py similarity index 96% rename from src/llama_stack_api/file_processor.py rename to src/llama_stack_api/file_processors.py index eaa8f697a..157b31e15 100644 --- a/src/llama_stack_api/file_processor.py +++ b/src/llama_stack_api/file_processors.py @@ -53,7 +53,7 @@ class ProcessedContent(BaseModel): @telemetry_traceable @runtime_checkable -class FileProcessor(Protocol): +class FileProcessors(Protocol): """ File Processor API for converting files into structured, processable content. @@ -72,7 +72,7 @@ class FileProcessor(Protocol): processing capabilities, and optimization strategies. """ - @webmethod(route="/file-processor/process", method="POST", level=LLAMA_STACK_API_V1ALPHA) + @webmethod(route="/file-processors/process", method="POST", level=LLAMA_STACK_API_V1ALPHA) async def process_file( self, file_data: bytes,