Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to create copilot" after tutorial walk through - 502 Bad Gateway #735

Open
mr-sk opened this issue Apr 8, 2024 · 10 comments
Open

Comments

@mr-sk
Copy link

mr-sk commented Apr 8, 2024

Describe the bug
Hello, I walked through the tutorial and setup the docker containers w/out any issues. I have the nginx server running and I am able to resolve http://localhost:8888/create/copilot. However, when asked for my copilot name and I hit "lets do this" it errors out with "Failed to create copilot".

To Reproduce
Steps to reproduce the behavior:

  1. Follow local installation instructions
  2. Goto localhost:8888/create/copilot and attempt to create a copilot
  3. Get error "Failed to create copilot"
  4. In browser inspect you can see a call to: XHRPOST
    http://localhost:8888/backend/copilot/
    [HTTP/1.1 502 Bad Gateway 7ms]
  5. The error thrown is likely from dashboard/app/(authenticated)/(main)/create/copilot/SetCopilotNameStep.tsx L33

Expected behavior
It creates a copilot and progresses through the wizard.

Screenshots
Screenshot 2024-04-08 at 9 03 36 AM

Desktop (please complete the following information):

  • OS: Darwin peo 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020 arm64
  • Browser Firefox
  • Version 123.0.1 (64-bit)
@JuergenCornely
Copy link

i have the same behavior after upgrade with git pull to the latest Version. Installed Copiots cant be found and in the log file i see error from llmserver :
image

@tpmccallum
Copy link
Contributor

I have that same behaviour:

nginx-1       | 172.25.0.1 - - [12/Apr/2024:03:45:29 +0000] "GET /backend/copilot/ HTTP/1.1" 500 90 "http://localhost:8888/create/copilot" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"

@tpmccallum
Copy link
Contributor

Tried restarting nginx:

docker compose restart nginx
WARN[0000] The "TARGET" variable is not set. Defaulting to a blank string. 
[+] Restarting 1/1
 ✔ Container opencopilot-nginx-1  Started

Still the same error (500)

@tpmccallum
Copy link
Contributor

Updated to the latest code and tried again today, same issue:

nginx-1       | 2024/05/21 01:42:49 [error] 29#29: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.20.0.1, server: , request: "POST /backend/copilot/ HTTP/1.1", upstream: "http://172.20.0.5:8002/backend/copilot/", host: "localhost:8888", referrer: "http://localhost:8888/create/copilot"
nginx-1       | 172.20.0.1 - - [21/May/2024:01:42:49 +0000] "POST /backend/copilot/ HTTP/1.1" 502 559 "http://localhost:8888/create/copilot" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"

@tpmccallum
Copy link
Contributor

Here is how to replicate it.

git clone https://github.com/openchatai/OpenCopilot.git
cd OpenCopilot

Config:

vi llm-server/.env

Paste in the following (note the sk-your-api-key):

# For local development environment

# OpenAI Configuration
OPENAI_API_TYPE=openai
OPENAI_API_KEY='sk-your-api-key'

# Pinecone Configuration
PINECONE_API_KEY=  # Your Pinecone API Key
PINECONE_ENV=  # Your Pinecone Environment

# MongoDB Configuration
MONGODB_URL=mongodb://dbuser:dbpass@mongodb:27017  # Your MongoDB Connection URL

# QDRANT Configuration
QDRANT_URL=http://qdrant:6333  # QDRANT Server URL
SCORE_THRESHOLD=0.91  # Score Threshold
STORE=QDRANT  # Default Store

# Langchain Configuration
LANGCHAIN_TRACING_V2=false  # Enable Langchain Tracing V2
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"  # Langchain API Endpoint
LANGCHAIN_API_KEY="TOKEN_GOES_HERE"  # Your Langchain API Key
LANGCHAIN_PROJECT="PROJECT_NAME_GOES_HERE"  # Your Langchain Project Name

# CoPilot Configuration
COPILOT_MODE=interactive  # CoPilot Mode

# MySQL Configuration
MYSQL_URI=mysql+pymysql://dbuser:dbpass@mysql:3306/opencopilot  # MySQL Connection URI

# Celery Configuration
CELERY_BROKER=redis://redis:6379/0  # Celery Broker URL
CELERY_BACKEND=redis://redis:6379/1  # Celery Backend URL

# Local IP Configuration
LOCAL_IP=host.docker.internal  # Local IP for Docker

# Shared Folder Configuration
SHARED_FOLDER=/app/shared_data/  # Path to Shared Data Folder

# Selenium Configuration
SELENIUM_GRID_URL=http://selenium:4444/wd/hub  # URL of the Selenium Grid for web scraping

Make and run:

cd ../../OpenCopilot
make install

@tpmccallum
Copy link
Contributor

cc: @codebanesr @ah7255703 @gharbat ⬆️

@tpmccallum
Copy link
Contributor

tpmccallum commented May 22, 2024

Hi @mr-sk @JuergenCornely
I managed to get this working but probably won't explain it very well ...here goes:

  • Do a fresh git pull
  • Then open the llm-server/.env and put nothing other than just your API key in there (surrounded by '):
OPENAI_API_KEY='sk-proj-NJ...........................Vv'

At this point I also like to go in and update the number of pages that the data source is allowed to index by updating the value of 15 up to 150 in the llm-server/utils/llm_consts.py file i.e. (max_pages_to_crawl = int(os.getenv("MAX_PAGES_TO_CRAWL", "150")))

  • make install
  • When it comes up paste in the following commands
  • docker compose up -d --build --no-deps llm-server
  • docker compose up -d --build --no-deps worker

At this point it should work. I am not sure what part of that did the trick - but that is precisely what I did and it works!

@codebanesr
Copy link
Contributor

@tpmccallum probably some environment variable was messing it up! Thanks for the answer

@tpmccallum
Copy link
Contributor

Thanks @codebanesr
I wonder if you can help me understand this related error:

$ docker compose up -d --build --no-deps worker
WARN[0000] The "TARGET" variable is not set. Defaulting to a blank string. 
no such service: worker

Is this what you mean by some environmental variable not being set?

@JuergenCornely
Copy link

JuergenCornely commented May 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants