I am a new comer in programing. Please help me on this topic: how to deploy a hugging…
- User
I am a new comer in programing. Please help me on this topic: how to deploy a hugging face app on vercel? please explain as detailed as possible and give a specific example to showcase how to deploy. Thanks.
- Assistant
- User
In which directory is your code located? what is it?
- Assistant
In the instructions provided, the code is located in a directory named
huggingface-vercel. This directory was created using the following command:mkdir huggingface-vercelThe
huggingface-verceldirectory contains the following files:main.py: This is the main file containing the FastAPI application and the Hugging Face Transformer model code. It defines two API endpoints, one for the root and another for classifying text.vercel.json: This file is used to configure Vercel for deployment. It specifies the name of the project, the build configuration, and the entry point to start the FastAPI server..gitignore: This file tells Git which files or folders to ignore when tracking changes (e.g., thevenvdirectory containing the virtual environment).
After creating the
huggingface-vercelfolder, navigating to it withcd huggingface-vercel, setting up the virtual environment, and installing the required packages, you should create themain.pyandvercel.jsonfiles inside thehuggingface-vercelfolder by following the instructions above. - User
after Vercel deploy, 404: NOT_FOUND Code: NOT_FOUND ID: cle1::gkz2g-1685774333864-458df6c059d5\
- Assistant
If you're encountering a 404 Not Found error after deploying your FastAPI application on Vercel, there could be several reasons. Here are a few possible issues and solutions:
-
Ensure the
vercel.jsonfile is in the root of your project directory, the same folder wheremain.pyis located. -
Double-check the content of your
vercel.json. It should look like this:
{ "version": 2, "name": "huggingface-vercel", "builds": [ { "src": "main.py", "use": "@vercel/python", "config": { "entrypoint": "uvicorn main:app --host 0.0.0.0 --port $PORT" } } ] }Make sure there are no typos and that the
buildsarray correctly points to "main.py" as the source. -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.