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/translations/hk/9-chat-project/solution/backend/python
localizeflow[bot] e11291bd14
chore(i18n): sync translations with latest source changes (chunk 10/20, 100 files)
1 month ago
..
README.md chore(i18n): sync translations with latest source changes (chunk 10/20, 100 files) 1 month ago

README.md

運行代碼

設置

建立虛擬環境

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

安裝依賴

pip install openai fastapi uvicorn python-dotenv

運行 API

# 方法 1直接執行
python api.py

# 方法 2使用 uvicorn
uvicorn api:app --host 0.0.0.0 --port 5000 --reload

測試 API

訪問互動式 API 文件:http://localhost:5000/docs

運行前端

確保你在 frontend 資料夾內

找到 app.js,將 BASE_URL 改為你的後端 URL

運行它

npx http-server -p 8000

試著在聊天中輸入訊息,你應該會看到回應(前提是你在 Codespace 中運行此程式或已設定存取權杖)。

設置存取權杖(如果你不是在 Codespace 中執行)

請參閱 設定 PAT


免責聲明
本文件由 AI 翻譯服務 Co-op Translator 進行翻譯。雖然我們力求準確,但請注意自動翻譯可能包含錯誤或不準確之處。原本文檔的母語版本應視為權威來源。對於重要資訊,建議使用專業人工翻譯。我們不負責因使用本翻譯而產生的任何誤解或錯誤詮釋。