Skip to content

Conversation

@mfleader
Copy link
Contributor

@mfleader mfleader commented Dec 8, 2025

  • Add files/models.py, api.py, fastapi_routes.py
  • Update providers (localfs, s3, openai) to use request objects
  • Update calling code in vector_store_mixin, rag, batches

What does this PR do?

Converts the Files API to use the new FastAPI router pattern, matching the approach used for Batches API.

Test Plan

CI and curl http://localhost:8321/v1/inspect/routes | jq '.data[] | select(.route | contains("files"))'

@meta-cla
Copy link

meta-cla bot commented Dec 8, 2025

Hi @mfleader!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

✱ Stainless preview builds

This PR will update the llama-stack-client SDKs with the following commit message.

refactor(files): migrate Files API to FastAPI router-based pattern

Edit this comment to update it. It will appear in the SDK's changelogs.

llama-stack-client-kotlin studio · code · diff

Your SDK built successfully.
generate ⚠️lint ✅test ❗

llama-stack-client-node studio · code · diff

Your SDK built successfully.
generate ⚠️build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/llama-stack-client-node/89a4e62ec2eeb5cf5f05e77fa5b007e07ea20530/dist.tar.gz
llama-stack-client-python studio · conflict

There was a conflict between your custom code and your generated changes.
You don't need to resolve this conflict right now, but you will need to resolve it for your changes to be released to your users. Read more about why this happened here.

llama-stack-client-go studio · code · diff

Your SDK built successfully.
generate ❗lint ❗test ❗

go get github.com/stainless-sdks/llama-stack-client-go@e52333e730cf81a0d92fe1851792796342afcf8b

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
Last updated: 2025-12-19 19:52:18 UTC

@mfleader mfleader changed the title refactor(files): migrate Files API to FastAPI router-based pattern feat: convert Files API to use FastAPI router Dec 9, 2025
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 9, 2025
@meta-cla
Copy link

meta-cla bot commented Dec 9, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Collaborator

@leseb leseb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

@mfleader mfleader requested a review from leseb December 9, 2025 16:32
@mfleader mfleader force-pushed the migrate-files-api branch 2 times, most recently from 29df0be to 693b600 Compare December 10, 2025 15:36
@mfleader mfleader marked this pull request as draft December 10, 2025 19:08
@mfleader mfleader force-pushed the migrate-files-api branch 3 times, most recently from daa3380 to b25f520 Compare December 12, 2025 12:54
@mfleader mfleader requested a review from leseb December 12, 2025 13:59
@mfleader mfleader force-pushed the migrate-files-api branch 2 times, most recently from 21b4ce0 to 87b4d84 Compare December 16, 2025 19:54
cdoern pushed a commit that referenced this pull request Dec 16, 2025
# What does this PR do?
Consolidates provider data context handling into middleware, eliminating
duplication between FastAPI router routes and legacy @webmethod routes.

Closes #4366 

## Test Plan

Added unit test suite `test_test_context_middleware`, specifically
`test_middleware_extracts_test_id_from_header` to validate the expected
behavior.
```
❯ ./scripts/unit-tests.sh tests/unit/
```

Integration of the middleware test context with the `files` FastAPI
router migration from
[pull/4339](#4339).
```
❯ git switch migrate-files-api
Switched to branch 'migrate-files-api'
❯ git rebase fix-test-ctx-middleware
Successfully rebased and updated refs/heads/migrate-files-api.
❯ ./scripts/integration-tests.sh --inference-mode replay --suite base --setup ollama --stack-config server:starter --subdirs files
```

Signed-off-by: Matthew F Leader <mleader@redhat.com>
@mfleader mfleader marked this pull request as ready for review December 16, 2025 22:26
@mfleader mfleader force-pushed the migrate-files-api branch 4 times, most recently from 531b723 to 5b3fff0 Compare December 18, 2025 18:12
Order,
ResourceNotFoundError,
)
from llama_stack_api.files.models import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from llama_stack_api.files.models import (
from llama_stack_api import (

VectorStoreChunkingStrategyStatic,
VectorStoreChunkingStrategyStaticConfig,
)
from llama_stack_api.files.models import UploadFileRequest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from llama_stack_api.files.models import UploadFileRequest
from llama_stack_api import UploadFileRequest

Order,
ResourceNotFoundError,
)
from llama_stack_api.files.models import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from llama_stack_api.files.models import (
from llama_stack_api import (

r-bit-rry pushed a commit to r-bit-rry/llama-stack that referenced this pull request Dec 23, 2025
…stack#4367)

# What does this PR do?
Consolidates provider data context handling into middleware, eliminating
duplication between FastAPI router routes and legacy @webmethod routes.

Closes llamastack#4366 

## Test Plan

Added unit test suite `test_test_context_middleware`, specifically
`test_middleware_extracts_test_id_from_header` to validate the expected
behavior.
```
❯ ./scripts/unit-tests.sh tests/unit/
```

Integration of the middleware test context with the `files` FastAPI
router migration from
[pull/4339](llamastack#4339).
```
❯ git switch migrate-files-api
Switched to branch 'migrate-files-api'
❯ git rebase fix-test-ctx-middleware
Successfully rebased and updated refs/heads/migrate-files-api.
❯ ./scripts/integration-tests.sh --inference-mode replay --suite base --setup ollama --stack-config server:starter --subdirs files
```

Signed-off-by: Matthew F Leader <mleader@redhat.com>
@mfleader mfleader requested a review from cdoern January 5, 2026 14:48
Signed-off-by: Matthew F Leader <mleader@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants