Programmatic Data Ingestion for RAG API #7853
Replies: 2 comments
-
Moved to Discussions since the RAG API is not tested or developed to be used like this outside of its LibreChat integration. You are better off inspecting the RAG API codebase to understand it better, and possibly contribute something that would make this work more effectively: https://github.com/danny-avila/rag_api In your .env, you should also set |
Beta Was this translation helpful? Give feedback.
-
I wanted to follow up and ask if there have been any updates on this issue. I'm encountering the same scenario and would appreciate any insights. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal
I am trying to programmatically upload documents for ingestion into the RAG system using a Python script. The objective is to automate the batch processing of a large number of local files, bypassing the need for manual UI uploads.
Core Problem
Automated, script-based file ingestion appears to be broken for me, regardless of the method used. I have identified two primary paths for uploading files, and both fail in different ways:
Via the LibreChat Application (
/api/files
): When my script sends files to the main LibreChat application, it receives a200 OK
success status for every file. However, the request is never processed further. The files do not appear in the vector database, and there is zero log activity in either mylibrechat
pod or mylibrechat-rag-api
pod, even with debug logging enabled. It's a "silent failure" where the request effectively disappears.Directly to the RAG API (
/embed-upload
): When my script sends files directly to the RAG API (bypassing the main LibreChat app), the request fails with a500 Internal Server Error
. My RAG API logs show aRuntimeError: Stream consumed
, which points to a request validation error happening before the application's business logic is executed.My Environment
LibreChat
,librechat-rag-api
, a KServe embedding model, and a CNPG-managed PostgreSQL/pgvector database.Debugging Steps & Findings
I have exhaustively debugged my infrastructure and have confirmed the issue appears to lie within the applications themselves.
Path 1: The "Silent Failure" via LibreChat (
/api/files
)200 OK
: My script successfully uploads files to thelibrechat
pod and receives a success code.librechat-librechat-config
ConfigMap
to setlogLevel: debug
. This did not produce any new logs related to file uploads.kubectl describe pod
confirmed mylibrechat
pod has only one container.kubectl exec
to get a shell inside thelibrechat
pod and successfully usedwget
andnc
to connect to thelibrechat-rag-api
service on its internal cluster URL. This proves the two pods can communicate with each other.My Conclusion for Path 1: The
librechat
application is accepting the HTTP request but has an internal bug that prevents it from forwarding the file to the RAG API for processing. This failure is completely silent.Path 2: The "Validation Error" via RAG API (
/embed-upload
)500 Internal Server Error
: My script fails with a server error, and the logs show aRuntimeError: Stream consumed
.rag-api
source:async def embed_upload(files: List[UploadFile], user_id: str = Form(...))
.requests
that sends amultipart/form-data
payload matching this signature exactly (a list of files under the keyfiles
and the user ID as a simple form field).My Conclusion for Path 2: The RAG API's
/embed-upload
endpoint has a bug/intended feature that prevents it from correctly validatingmultipart/form-data
requests coming from a non-browser client like a Python script.Given these findings, could you please clarify:
Version Information
docker images | grep librechat
ghcr.io/danny-avila/librechat latest 6966cd37fc2d 4 weeks ago 1.01GB
Steps to Reproduce
Steps to Reproduce
Attempt 1: Upload via LibreChat (
/api/files
)kubectl port-forward svc/librechat-librechat 8080:3080
)../data-samples
).AUTH_TOKEN
variable with a fresh token.ingest_through_librechat.py
200 OK
success for every file, but no logs appear in thelibrechat
orrag-api
pods, and no data is ingested.Attempt 2: Upload Directly to RAG API (
/embed-upload
)kubectl port-forward svc/librechat-rag-api-librechat-rag-api 8001:8000
).AUTH_TOKEN
andUSER_ID
variables.direct_ingest.py
500 Internal Server Error
, and therag-api
pod logs aRuntimeError: Stream consumed
.Questions
Given these findings, could you please clarify:
Any guidance you could provide would be greatly appreciated. Thank you!
What browsers are you seeing the problem on?
No response
Relevant log output
Screenshots
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions