You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Web-Dev-For-Beginners/9-chat-project/solution/backend/python
chris 845ed4aed3
last fixes
1 month ago
..
README.md last fixes 1 month ago
api.py last fixes 1 month ago
llm.py Upgraded typing game, chat backend, and main index files 2 months ago

README.md

Run code

Set up

Create virtual environment

python -m venv venv
source ./venv/bin/activate

Install dependencies

pip install openai fastapi uvicorn python-dotenv

Run API

# Method 1: Direct execution
python api.py

# Method 2: Using uvicorn
uvicorn api:app --host 0.0.0.0 --port 5000 --reload

Test API

Visit the interactive API documentation at: http://localhost:5000/docs

Run frontend

Make sure you stand in the frontend folder

Locate app.js, change BASE_URL to that of your backend URL

Run it

npx http-server -p 8000

Try typing a message in the chat, you should see a response (providing you're running this in a Codespace or have set up a access token).

Set up access token (if you don't run this in a Codespace)

See Set up PAT