danny-avila / rag_api

ID-based RAG FastAPI: Integration with Langchain and PostgreSQL/pgvector
https://librechat.ai/
143 stars 60 forks source link

The RAG API does not seem to be able to reach LocalAI instance #45

Closed Mithrillion closed 4 weeks ago

Mithrillion commented 4 weeks ago

using the ghcr.io/danny-avila/librechat-rag-api-dev:latest image, I have configured the RAG-related section in .env as follows:

RAG_OPENAI_BASEURL=http://host.docker.internal:8080/v1
RAG_OPENAI_API_KEY=localai
EMBEDDINGS_PROVIDER=openai
EMBEDDINGS_MODEL=mxbai-embed-large-v1

I have tested with LocalAI API that using curl on localhost:8080/v1/embeddings does work. However, it appears that LibreChat returns the following log sequence when attempting to upload a file:

rag_api           | 2024-06-09 13:24:03,043 - openai._base_client - INFO - Retrying request to /embeddings in 0.894302 seconds
rag_api           | 2024-06-09 13:24:03,941 - openai._base_client - INFO - Retrying request to /embeddings in 1.911483 seconds
rag_api           | 2024-06-09 13:24:05,857 - root - ERROR - Connection error.
rag_api           | 2024-06-09 13:24:05,857 - root - INFO - Request POST http://rag_api:8000/embed - 200
LibreChat         | 2024-06-09 13:24:05 error: Error embedding file File embedding failed.
LibreChat         | 2024-06-09 13:24:05 error: [/files] Error processing file: File embedding failed.

I have attempted to change the base url to without the v1, or ...v1/, all without success. As I have successfully set up the LLM and TTS API using the same LocalAI instance, I think this might be an issue with rag_api not posting to the right address or posting with incompatible format with LocalAI.

I guess the issue might be easier to diagnose if I can see exactly what request is posted. However this does not seem to be visible even in the logs.

Mithrillion commented 4 weeks ago

Nevermind, the problem appears to be resolved after configuring rag_api image for host access in docker-compose.override.yaml:

extra_hosts:
      - "host.docker.internal:host-gateway"

It appears that unlike the main librechat container, rag_api is not configured for host network access by default.