Possible Causes:
- Invalid or missing API Key
- Incorrect BaseURL configuration
- Network access restricted
- Text too long
- Configured BaseURL doesn't provide Embeddings endpoint or doesn't support the selected embedding model (e.g., returns 404 Not Found)
Troubleshooting Steps:
1. Confirm OPENAI_API_KEY is set and valid
2. If using a compatible gateway, explicitly set WithBaseURL(os.Getenv("OPENAI_BASE_URL"))
3. Confirm WithModel("text-embedding-3-small") or the embedding model name actually supported by your service
4. Use a minimal example to call the embedding API once to verify connectivity
5. Use curl to verify the target BaseURL implements /v1/embeddings and the model exists:
If it returns 404/model doesn't exist, switch to a BaseURL that supports Embeddings or use a valid embedding model name provided by that service
6. Gradually shorten text to confirm it's not caused by overly long input
Description: Since the PDF reader depends on third-party libraries, to avoid introducing unnecessary dependencies in the main module, the PDF reader uses a separate go.mod.
Usage: To support PDF file reading, manually import the PDF reader package in your code:
# OpenAI API configuration (required when using OpenAI embedder, auto-read by OpenAI SDK)exportOPENAI_API_KEY="your-openai-api-key"exportOPENAI_BASE_URL="your-openai-base-url"# OpenAI embedding model configuration (optional, requires manual reading in code)exportOPENAI_EMBEDDING_MODEL="text-embedding-3-small"# Google Gemini API configuration (when using Gemini embedder)exportGOOGLE_API_KEY="your-google-api-key"# PostgreSQL + pgvector configuration (required when using -vectorstore=pgvector)exportPGVECTOR_HOST="127.0.0.1"exportPGVECTOR_PORT="5432"exportPGVECTOR_USER="postgres"exportPGVECTOR_PASSWORD="your-password"exportPGVECTOR_DATABASE="vectordb"# TcVector configuration (required when using -vectorstore=tcvector)exportTCVECTOR_URL="https://your-tcvector-endpoint"exportTCVECTOR_USERNAME="your-username"exportTCVECTOR_PASSWORD="your-password"# Elasticsearch configuration (required when using -vectorstore=elasticsearch)exportELASTICSEARCH_HOSTS="http://localhost:9200"exportELASTICSEARCH_USERNAME=""exportELASTICSEARCH_PASSWORD=""exportELASTICSEARCH_API_KEY=""exportELASTICSEARCH_INDEX_NAME="trpc_agent_documents"# Milvus configuration (required when using -vectorstore=milvus)exportMILVUS_ADDRESS="localhost:19530"exportMILVUS_USERNAME=""exportMILVUS_PASSWORD=""exportMILVUS_DB_NAME=""exportMILVUS_COLLECTION="trpc_agent_go"