Archon icon indicating copy to clipboard operation
Archon copied to clipboard

🐛 [Bug]: Knowledge Base Malfunction

Open esd100 opened this issue 4 months ago • 20 comments

Archon Version

Beta

Bug Severity

🟠 High - Blocks important features

Bug Description

On my knowledge base, the documents that have been webcrawled don't seem to be saved anywhere. I saw in the live stream you were able to click a little icon that brought up the documents so you could view them, but I don't have that on mine.

My settings are for Gemini LLM provider, gemini-embedding-001 embedding, and gemini-2.5-flash-lite chat, with GEMINI_API_KEY

Affected Component

🔍 Knowledge Base / RAG

Browser & OS

Chrome 138 & mac os 15.6

esd100 avatar Aug 16 '25 17:08 esd100

Same issue. Same system and os

dangieschen avatar Aug 16 '25 19:08 dangieschen

Looks like it's an openAI api key error on my end. This showed up in the docker logs:

2025-08-16 19:32:50 | src.server.services.llm_provider_service | ERROR   | Error creating LLM client for provider openai: OpenAI API key not found
2025-08-16 19:32:50 | search                             | ERROR   | Catastrophic failure in batch embedding: OpenAI API key not found

Traceback (most recent call last):
  File "/app/src/server/services/embeddings/embedding_service.py", line 184, in create_embeddings_batch
    async with get_llm_client(provider=provider, use_embedding_provider=True) as client:
  File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/server/services/llm_provider_service.py", line 98, in get_llm_client
    raise ValueError("OpenAI API key not found")
ValueError: OpenAI API key not found

2025-08-16 19:32:50 | search | ERROR   | Batch 1: Failed to create 23 embeddings. 
                                         Successful: 0. 
                                         Errors: [
                                           'Catastrophic failure: OpenAI API key not found',
                                           'Catastrophic failure: OpenAI API key not found',
                                           'Catastrophic failure: OpenAI API key not found'
                                         ]
2025-08-16 19:32:50 | search | WARNING | Skipping batch 1 - no successful embeddings created

I fixed it by updating the openaI API key in settings and restarting the docker container. Then recrawl the knowledge bases.

dangieschen avatar Aug 16 '25 19:08 dangieschen

I'm not using the openAI. My settings are for Gemini LLM provider, gemini-embedding-001 embedding, and gemini-2.5-flash-lite chat, with GEMINI_API_KEY.

I don't know where to see those terminal outputs to find out what's wrong. where do you find the docker logs?

esd100 avatar Aug 16 '25 21:08 esd100

I'm not using the openAI. My settings are for Gemini LLM provider, gemini-embedding-001 embedding, and gemini-2.5-flash-lite chat, with GEMINI_API_KEY.

I don't know where to see those terminal outputs to find out what's wrong. where do you find the docker logs?

docker logs Archon-Server --tail=100

adjust tail number to fit your needs

ogrodev avatar Aug 16 '25 21:08 ogrodev

in docker desktop you can also click on "containers" in the main menu on the left, click the container name, then select logs (top left tab). you can see the output there

dangieschen avatar Aug 16 '25 22:08 dangieschen

Thanks for showing me how to find the log. I'm getting a few errors, but I think this may be the culprit.

It seems like no Google API is found, but I have put them into the settings tab in the server and saved.

2025-08-17 00:38:35 | src.server.services.llm_provider_service | INFO | Creating LLM client for provider: google 2025-08-17 00:38:35 | src.server.services.llm_provider_service | ERROR | Error creating LLM client for provider google: Google API key not found 2025-08-17 00:38:35 | search | ERROR | Catastrophic failure in batch embedding: Google API key not found Traceback (most recent call last): File "/app/src/server/services/embeddings/embedding_service.py", line 184, in create_embeddings_batch async with get_llm_client(provider=provider, use_embedding_provider=True) as client: File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__ return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/app/src/server/services/llm_provider_service.py", line 113, in get_llm_client raise ValueError("Google API key not found") ValueError: Google API key not found 2025-08-17 00:38:35 | search | ERROR | Batch 3: Failed to create 25 embeddings. Successful: 0. Errors: ['Catastrophic failure: Google API key not found', 'Catastrophic failure: Google API key not found', 'Catastrophic failure: Google API key not found'] 2025-08-17 00:38:35 | search | WARNING | Skipping batch 3 - no successful embeddings created

esd100 avatar Aug 17 '25 00:08 esd100

did you restart the docker container? It won't pick up the change until it's restarted

dangieschen avatar Aug 17 '25 01:08 dangieschen

Yeah, I've restarted a few times. I did it again for good measure and got the same error. 2025-08-17 01:19:15 | src.server.services.llm_provider_service | INFO | Creating LLM client for provider: google 2025-08-17 01:19:15 | src.server.services.llm_provider_service | ERROR | Error creating LLM client for provider google: Google API key not found 2025-08-17 01:19:15 | search | ERROR | Catastrophic failure in batch embedding: Google API key not found Traceback (most recent call last): File "/app/src/server/services/embeddings/embedding_service.py", line 184, in create_embeddings_batch async with get_llm_client(provider=provider, use_embedding_provider=True) as client: File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__ return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/app/src/server/services/llm_provider_service.py", line 113, in get_llm_client raise ValueError("Google API key not found") ValueError: Google API key not found 2025-08-17 01:19:15 | search | ERROR | Batch 3: Failed to create 23 embeddings. Successful: 0. Errors: ['Catastrophic failure: Google API key not found', 'Catastrophic failure: Google API key not found', 'Catastrophic failure: Google API key not found'] 2025-08-17 01:19:15 | search | WARNING | Skipping batch 3 - no successful embeddings created

esd100 avatar Aug 17 '25 01:08 esd100

Yeah, I've restarted a few times. I did it again for good measure and got the same error. 2025-08-17 01:19:15 | src.server.services.llm_provider_service | INFO | Creating LLM client for provider: google 2025-08-17 01:19:15 | src.server.services.llm_provider_service | ERROR | Error creating LLM client for provider google: Google API key not found 2025-08-17 01:19:15 | search | ERROR | Catastrophic failure in batch embedding: Google API key not found Traceback (most recent call last): File "/app/src/server/services/embeddings/embedding_service.py", line 184, in create_embeddings_batch async with get_llm_client(provider=provider, use_embedding_provider=True) as client: File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__ return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/app/src/server/services/llm_provider_service.py", line 113, in get_llm_client raise ValueError("Google API key not found") ValueError: Google API key not found 2025-08-17 01:19:15 | search | ERROR | Batch 3: Failed to create 23 embeddings. Successful: 0. Errors: ['Catastrophic failure: Google API key not found', 'Catastrophic failure: Google API key not found', 'Catastrophic failure: Google API key not found'] 2025-08-17 01:19:15 | search | WARNING | Skipping batch 3 - no successful embeddings created

Verified Gemini is working for me... could you share how you added your GEMINI API key in the settings? Also, please check the archon_settings table in Supabase and see if you have an encrypted value for GEMINI_API_KEY there.

coleam00 avatar Aug 18 '25 14:08 coleam00

Same problem with OpenAI key.

My issue was related to #362 - I must accidentally put an OpenAI key that does not have credits and checking Supabase the OpenAI key was unencrypted. Decided to blow away Supabase with reset script and start from scratch putting in proper OpenAI key with CREDITS and then OpenAI key got stored in Supabase correctly/encrypted and all my URL crawlings and documents got RAG properly with storage retrieval from Supabase. All working now !

bmanns24x7 avatar Aug 19 '25 11:08 bmanns24x7

I deleted the entire field for open AI api key and put in my gemini api key and saved settings.

I checked the Supabase archon_settings table and I had an encrypted value for GEMINI_API_KEY.

Image

esd100 avatar Aug 19 '25 23:08 esd100

I'm not sure if this has anything to do with this problem but the docker-compose.yml file doesn't say anything about gemini.

`services:

Server Service (FastAPI + Socket.IO + Crawling)

archon-server: build: context: ./python dockerfile: Dockerfile.server args: BUILDKIT_INLINE_CACHE: 1 ARCHON_SERVER_PORT: ${ARCHON_SERVER_PORT:-8181} container_name: Archon-Server ports: - "${ARCHON_SERVER_PORT:-8181}:${ARCHON_SERVER_PORT:-8181}" environment: - SUPABASE_URL=${SUPABASE_URL} - SUPABASE_SERVICE_KEY=${SUPABASE_SERVICE_KEY} - OPENAI_API_KEY=${OPENAI_API_KEY:-} - LOGFIRE_TOKEN=${LOGFIRE_TOKEN:-} - SERVICE_DISCOVERY_MODE=docker_compose - LOG_LEVEL=${LOG_LEVEL:-INFO} - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} - ARCHON_MCP_PORT=${ARCHON_MCP_PORT:-8051} - ARCHON_AGENTS_PORT=${ARCHON_AGENTS_PORT:-8052} networks: - app-network volumes: - /var/run/docker.sock:/var/run/docker.sock # Docker socket for MCP container control - ./python/src:/app/src # Mount source code for hot reload - ./python/tests:/app/tests # Mount tests for UI test execution command: ["python", "-m", "uvicorn", "src.server.main:socket_app", "--host", "0.0.0.0", "--port", "${ARCHON_SERVER_PORT:-8181}", "--reload"] healthcheck: test: ["CMD", "sh", "-c", "python -c "import urllib.request; urllib.request.urlopen('http://localhost:${ARCHON_SERVER_PORT:-8181}/health')""] interval: 30s timeout: 10s retries: 3 start_period: 40s

Lightweight MCP Server Service (HTTP-based)

archon-mcp: build: context: ./python dockerfile: Dockerfile.mcp args: BUILDKIT_INLINE_CACHE: 1 ARCHON_MCP_PORT: ${ARCHON_MCP_PORT:-8051} container_name: Archon-MCP ports: - "${ARCHON_MCP_PORT:-8051}:${ARCHON_MCP_PORT:-8051}" environment: - SUPABASE_URL=${SUPABASE_URL} - SUPABASE_SERVICE_KEY=${SUPABASE_SERVICE_KEY} - LOGFIRE_TOKEN=${LOGFIRE_TOKEN:-} - SERVICE_DISCOVERY_MODE=docker_compose - TRANSPORT=sse - LOG_LEVEL=${LOG_LEVEL:-INFO} # MCP needs to know where to find other services - API_SERVICE_URL=http://archon-server:${ARCHON_SERVER_PORT:-8181} - AGENTS_SERVICE_URL=http://archon-agents:${ARCHON_AGENTS_PORT:-8052} - ARCHON_MCP_PORT=${ARCHON_MCP_PORT:-8051} - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} - ARCHON_AGENTS_PORT=${ARCHON_AGENTS_PORT:-8052} networks: - app-network depends_on: - archon-server - archon-agents healthcheck: test: ["CMD", "sh", "-c", "python -c "import socket; s=socket.socket(); s.connect(('localhost', ${ARCHON_MCP_PORT:-8051})); s.close()""] interval: 30s timeout: 10s retries: 3 start_period: 60s # Give dependencies time to start

AI Agents Service (ML/Reranking)

archon-agents: build: context: ./python dockerfile: Dockerfile.agents args: BUILDKIT_INLINE_CACHE: 1 ARCHON_AGENTS_PORT: ${ARCHON_AGENTS_PORT:-8052} container_name: Archon-Agents ports: - "${ARCHON_AGENTS_PORT:-8052}:${ARCHON_AGENTS_PORT:-8052}" environment: - SUPABASE_URL=${SUPABASE_URL} - SUPABASE_SERVICE_KEY=${SUPABASE_SERVICE_KEY} - OPENAI_API_KEY=${OPENAI_API_KEY:-} - LOGFIRE_TOKEN=${LOGFIRE_TOKEN:-} - SERVICE_DISCOVERY_MODE=docker_compose - LOG_LEVEL=${LOG_LEVEL:-INFO} - ARCHON_AGENTS_PORT=${ARCHON_AGENTS_PORT:-8052} networks: - app-network healthcheck: test: ["CMD", "sh", "-c", "python -c "import urllib.request; urllib.request.urlopen('http://localhost:${ARCHON_AGENTS_PORT:-8052}/health')""] interval: 30s timeout: 10s retries: 3 start_period: 40s

Frontend

frontend: build: ./archon-ui-main container_name: Archon-UI ports: - "${ARCHON_UI_PORT:-3737}:5173" environment: - VITE_API_URL=http://${HOST:-localhost}:${ARCHON_SERVER_PORT:-8181} - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} - HOST=${HOST:-localhost} networks: - app-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5173"] interval: 30s timeout: 10s retries: 3 volumes: - ./archon-ui-main/src:/app/src - ./archon-ui-main/public:/app/public depends_on: - archon-server

networks: app-network: driver: bridge`

esd100 avatar Aug 19 '25 23:08 esd100

@bmanns24x7 Can you clarify what exactly do you mean that your OpenAI key was unencrypted. when I checked my supabase there is something in the encrypted value column cell in the gemini api key row, but it's not "encrypted" like with asterisks showing, but it's letters and numbers and it doesn't match my actual key, so I'm assuming it's encrypted and just showing...am I wrong or misunderstandin?

esd100 avatar Aug 20 '25 17:08 esd100

@esd100 it was late at night sorry of excitement of Archon and troubleshooting. I thought I saw is_encypted as FALSE and raw OpenAI key (that had no credits) in encrypted_value, but I mistaken. Today blew away database and use same no credits Open AI key and it encypted with letters and numbers and is_encrypted = TRUE. Sorry my bad.

So that just leaves the known #362 (OpenAI key with no credits) which looks to be being worked on for fix.

bmanns24x7 avatar Aug 21 '25 01:08 bmanns24x7

@esd100 Instead of using GEMINI_API_KEY use GOOGLE_API_KEY in Key Name. For some reason GEMINI_API_KEY doesn't work well when using gemini-embedding-001. I'm using the same embedding model. Don't forget to change your embedding dimensions in your .env file. The embedding dimensions for gemini-embedding-001 is 3072.

Also, for SUPABASE_SERVICE_KEY make sure you are using a legacy API key. It's super long.

StreamDemon avatar Aug 21 '25 19:08 StreamDemon

Closing this issue, let me know if anyone here still is having issues

Wirasm avatar Aug 22 '25 13:08 Wirasm

Hi @Wirasm , I'm not sure why this was marked as closed. StreamDemon just posted a possible solution yesterday and now you are closing it without confirmation. I don't know what other people might think but that doesn't seem right.

I would like to know why GEMINI_API_KEY doesn't work. That is the one that I get from Google cloud. I'm not even sure that the GOOGLE_API_KEY would work or where to get it.

Also, what are the instructions for setting the embedding dimension in the .env file? Is that anywhere in the documentation?

esd100 avatar Aug 23 '25 04:08 esd100

I deleted everything and started from scratch. It still doesn't work.

Image Image

esd100 avatar Aug 23 '25 06:08 esd100

Hi @Wirasm , I'm not sure why this was marked as closed. StreamDemon just posted a possible solution yesterday and now you are closing it without confirmation. I don't know what other people might think but that doesn't seem right.

I would like to know why GEMINI_API_KEY doesn't work. That is the one that I get from Google cloud. I'm not even sure that the GOOGLE_API_KEY would work or where to get it.

Also, what are the instructions for setting the embedding dimension in the .env file? Is that anywhere in the documentation?

I got my Gemini API through Google AI Studio, which is where you can create Gemini API keys. Think of GOOGLE_API_KEY as a main router for all of Google's APIs, including Gemini. The embedding model gemini-embedding-01 is actually from Google's Vertex AI service, and in order to access that, you need to specifically use GOOGLE_API_KEY in Key Names.

From what you've mentioned so far, you're issue can be one or two things.

  1. Your environment configuration isn't set up for properly handling gemini-embedding-01 as an embedding model. To fix this, go to the root folder of Archon and look for the .env file. Open it through your editor of choice, and go to line 41:

EMBEDDING_DIMENSIONS=1536

Change the number 1536 to 3072 (which is the correct dimensions for gemini-embedding-01. Save the file and rebuild Archon on docker.

  1. You're using a newer version of the Supabase API key. You need to be using a legacy API key. To get the legacy API key for your database, go to your Supabase dashboard. Go to Project Settings (left menu bar), then API Keys (left menu). This should bring you to the API Key configurations window. The first tab that the window will load on is the Legacy API Keys tab. Copy the API key that is tagged anon public. Paste that API key into your Archon .env file, it should be on line 24:

SUPABASE_SERVICE_KEY=

Just to be concise, let's make sure you also have your Supabase URL set up correctly as well. Go back to your Supabase dashboard, go to Project Settings, then go to Data API. You should see a section at the very top of the window that says Project URL. Copy that URL and paste it into your Archon .env file, on line 6:

SUPABASE_URL=

Last step is to rebuild Archon on docker.

StreamDemon avatar Aug 23 '25 14:08 StreamDemon

@StreamDemon Thanks for your input, but everything you listed is already setup correctly as per the instructions

Before rebuilding this last time, I did update my EMBEDDING_DIMENSIONS to 3072 as mentioned previously in the thread.

Image

I also am using the legacy Supabase API key that is specifically requested in the .env file '# On the Supabase dashboard, it's labeled as "service_role" under "Project API keys". The project's .env file does not say to use the Anon key.

Image.

Image

I also have the Supabase URL setup correctly.

Image

esd100 avatar Aug 26 '25 04:08 esd100

This should now be resolved, please let me know if you are still having issues on latest main

Wirasm avatar Sep 16 '25 10:09 Wirasm