Skip to main content

胖貓專屬嘴臭LLM推理API

Project description

🐈 FatCat GPT API

這是一個基於 FastAPI 與 fatcat-gpt 套件建構的大型語言模型 (LLM) 推理伺服器。 模型被設定為一個名叫咪咪的 Discord 活躍群友,講話直接,而且專門給出讓人心情更糟的超臭回覆。

透過這個專案,模型只會在伺服器啟動時載入顯示卡一次,之後便可在背景待命,隨時接收 API 請求並瞬間給出回覆,可以用來串接 Discord 機器人。


🛠️ 環境與安裝清單

請確保你的環境中已經安裝了 fatcat-gpt 核心套件以及 API 所需的依賴模組:

# 確保已安裝 fatcat-gpt
pip install -e .

🚀 快速啟動指南

這個專案分為「伺服器端 (Server)」與「測試端 (Client)」兩個部分。

第一步:啟動背景伺服器 (server.py)

伺服器負責將幾十 GB 的模型載入 GPU 中並保持待命。請在終端機中執行以下指令來啟動 API 伺服器:

uvicorn server:app --host 0.0.0.0 --port 8000

💡 提示 (多顯卡環境): > 如果你的機器有多張顯卡,且你想把模型強制綁定在特定的 GPU (例如 GPU 0),請在指令前面加上環境變數:

CUDA_VISIBLE_DEVICES=0 uvicorn server:app --host 0.0.0.0 --port 8000

等待終端機印出 [伺服器已就緒] 或類似的成功訊息後,就代表伺服器已經成功啟動並駐留在背景。請將這個終端機視窗保持開啟,不要關閉。

第二步:發送測試請求 (send.py)

請開啟另一個新的終端機視窗,執行測試腳本,向剛才開好的伺服器發送對話內容:

python send.py

如果一切順利,你將會瞬間在終端機看到來自咪咪的無情臭人回覆!

📡 API 規格說明

伺服器啟動後,預設會監聽 http://127.0.0.1:8000。

POST /chat 接收對話歷史並回傳咪咪生成的文字。

請求格式 (JSON payload):

{
  "messages": [
    {
      "role": "user",
      "content": "[聊天頻道名稱] user_id_a: 今天晚餐吃什麼好? [聊天頻道名稱] user_id_b: 不知道欸"
    }
  ],
  "max_new_tokens": 128,
  "temperature": 0.3,
  "top_p": 0.95
}

成功回應格式 (JSON):

{
  "status": "success",
  "response": "咪咪生成的無情回覆字串"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fatcat_gpt-0.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fatcat_gpt-0.1.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file fatcat_gpt-0.1.1.tar.gz.

File metadata

  • Download URL: fatcat_gpt-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fatcat_gpt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e5628ca522cee7c96ad29b86fbad9c7bf80b52f250ff5a3921353da647150de3
MD5 b51140aeff919dabfa506eb574449439
BLAKE2b-256 4f845108174153dc78c940593692b4509701225b633b4ddf4a0c7b087724aab6

See more details on using hashes here.

File details

Details for the file fatcat_gpt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fatcat_gpt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fatcat_gpt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8def952e7febfaaa263cd8d55c00133c1882a6821d73e16dc853219fe4d514bc
MD5 ae57cb93c035bea8651c05dd96e958c2
BLAKE2b-256 7433c3a67424d0e4f06708fcf7597e4d34b09a4c27b775ef95585a61f62750fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page