Open mattarderne opened 11 months ago
@mattarderne thanks for checking out the project and for the detailed list of issues. I'll try to address the errors Im seeing one by one:
make seed_db_local
:
make[1]: awslocal: No such file or directory
. Are you in the poetry shell (just type poetry shell
) and have you run poetry install
in that shell?make refresh_db
:
make migrate
to re-apply the migrations? Again, make sure you're in the poetry shell
and that you've completely shutdown the DB container (could just do docker compose down
).make run
:
make migrate
or make refresh_db
before being able to do this.I presume to keep the first make run terminal open per this line. Or do I rather ctrl+c to exit and run everything in that terminal? i think I've probably tried both. In any case I get stuck with above in both scenarios once I've got the Exception: Database is not up to date. Please run poetry run alembic upgrade head error
In regards to this, yes I would just do ctrl+c to stop the server process before running any of the seed_db_local
, refresh_db
, or migrate
Makefile commands. You will need to have successfully applied the Alembic migrations before being able to start the backend server.
One thing that may help is using the devcontainer configuration. You can spin this up either on Github Codespaces or even in a locally running Docker conatiner through VS Code's devcontainer feature. This container sets up a development environment that is specifically configured for this project. NVM I see that you are in fact running this in a codespace haha
make seed_db_local: This prints out make[1]: awslocal: No such file or directory. Are you in the poetry shell (just type poetry shell) and have you run poetry install in that shell?
@sourabhdesai thanks this seemed to get it to work, I think the issue was having not re-entered the poetry shell at this step after exiting the first make run
. I think this is just unfamiliarity with how Poetry works. The rest of the instructions worked with this info.
I've now not managed to get the frontend to load any documents in the document search drop down.
I tested the backend and it is working at https://<codespaces url>.app.github.dev:8000/api/document/
and I changed the NEXT_PUBLIC_BACKEND_URL=https://<codespaces url>-8000.app.github.dev/
but it doesn't seem to be connecting.
Thanks!
@mattarderne can you open dev tools in your browser and check the console logs? Most likely is due to CORS.
Access to fetch at 'https://< codespaces url >-8000.app.github.dev/api/document/'
from origin 'https://< codespaces url >-3000.app.github.dev' has been blocked by
CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch
the resource with CORS disabled.
@sourabhdesai yes CORS, thanks
@mattarderne have you solved the issue?
have you tried this
add CODESPACE_NAME=your-code-space-name
to your .env
file in the backend then just set -a
and source .env
then re-run the backend, hope this will help
@kikirizki Just want to follow up on this - I have added the relevant github info in the backend .env file:
DATABASE_URL=postgresql://user:password@127.0.0.1:5432/llama_app_db
BACKEND_CORS_ORIGINS='["http://localhost", "http://localhost:8000", "http://localhost:3000", "http://127.0.0.1:3000", "https://llama-app-backend.onrender.com", "https://llama-app-frontend.vercel.app", "http://secinsights.ai", "http://www.secinsights.ai", "https://secinsights.ai", "https://www.secinsights.ai"]'
OPENAI_API_KEY=xxx
LOG_LEVEL=debug
RENDER=False
S3_BUCKET_NAME=llama-app-backend-local
S3_ASSET_BUCKET_NAME=llama-app-web-assets-local
CDN_BASE_URL=http://llama-app-web-assets-local.s3-website.localhost.localstack.cloud:4566
AWS_KEY=xxx
AWS_SECRET=xxx
POLYGON_IO_API_KEY=xxx
CODESPACE_NAME=special-doodle-q7qp4969w9grc9jpg
And I also print out the origins
variable in the code, which shows like below and seems to be working:
[AnyHttpUrl('http://localhost', ), AnyHttpUrl('http://localhost:8000', ), AnyHttpUrl('http://localhost:3000', ), AnyHttpUrl('http://127.0.0.1:3000', ), AnyHttpUrl('https://llama-app-backend.onrender.com', ), AnyHttpUrl('https://llama-app-frontend.vercel.app', ), AnyHttpUrl('http://secinsights.ai', ), AnyHttpUrl('http://www.secinsights.ai', ), AnyHttpUrl('https://secinsights.ai', ), AnyHttpUrl('https://www.secinsights.ai', ), 'https://special-doodle-q7qp4969w9grc9jpg-3000.app.github.dev']
However, I'm still getting this CORS error after I've restarted my backend:
Access to fetch at 'https://special-doodle-q7qp4969w9grc9jpg-8000.app.github.dev/api/document/' from origin 'https://special-doodle-q7qp4969w9grc9jpg-3000.app.github.dev' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Any insights here? From the backend code looks like we are trying to solve the CORS issue but it's not successful?
Also I've tried to manually add https://special-doodle-q7qp4969w9grc9jpg-3000.app.github.dev
to BACKEND_CORS_ORIGINS='["http://localhost", "http://localhost:8000", "http://localhost:3000", "http://127.0.0.1:3000", "https://llama-app-backend.onrender.com", "https://llama-app-frontend.vercel.app", "http://secinsights.ai", "http://www.secinsights.ai", "https://secinsights.ai", "https://www.secinsights.ai"]'
but still see the same issue.
OK, I think the above issue is solved. The tricky thing here is that the github codespace won't make your URL public accessible, so when codespace have a pop up asking you, you should click the "make it public" button to make sure your backend is publicly accessible. Otherwise Github requires you to login to access the backend, and the front end won't be able to do that (although they are launched in the same codespace)
@jameszhucigna thank you for the follow up, glad it's work for you
I followed the instructions on the latest PR merge, but still bumping into a few issues with codespaces. The first
make run
worked, but then on following further instructions, it starts throwing issues. The only change I have made is the the .env addingOPENAI_API_KEY
make seed_db_local
make refresh_db
Then going back to try
make run
againNot sure what the missing step is. I presume to keep the first
make run
terminal open per this line. Or do I ratherctrl+c
to exit and run everything in that terminal? i think I've probably tried both. In any case I get stuck with above in both scenarios once I've got theException: Database is not up to date. Please run poetry run alembic upgrade head
error