AI Server Test is a Flask-served browser chat interface for Gemini with model selection and local JSON conversation history.
- Serves
index.html,style.css, andscript.jsfrom a Flask application. - Sends browser chat requests to Gemini through Flask API routes.
- Lists available models from
modellist.txtand switches the active backend model. - Stores chat history as local JSON files in the history folder.
- Supports history rollback by search text and removal of selected history files.
- Summarizes long SDK histories before sending them back to Gemini.
- Python 3.10 or newer.
- A Google API key available as
GOOGLE_API_KEY. - Python packages listed in
requirements.txt:Flask,flask-cors,google-generativeai, andpython-dotenv. - A browser for using the served chat interface.
- Create and activate a virtual environment.
- Install dependencies:
pip install -r requirements.txt- Copy
.env.exampleto a local .env file. - Set the Gemini API key:
GOOGLE_API_KEY=your-google-api-key- Review
modellist.txtif you want to change the model options shown in the UI.
The server creates the history folder automatically when background.py is imported.
Start the Flask server:
python testserver.pyOpen the browser UI:
http://127.0.0.1:5000
The Flask app runs with debug mode enabled, listens on 0.0.0.0, and uses port 5000.
testserver.py: Flask application, static file serving, and chat/history/model API routes.background.py: Gemini setup, conversation execution, history conversion, history storage, rollback, and model list loading.index.html: browser UI shell.script.js: browser-side chat, model, history, rollback, and delete behavior.style.css: browser UI styling.modellist.txt: model names displayed by the UI.requirements.txt: Python runtime dependencies..env.example: sample environment file containingGOOGLE_API_KEY.
AI Server Test 是一個以 Flask 提供服務的 Gemini 網頁聊天介面。
前端由 index.html、style.css 與 script.js 組成,後端 API 則在 testserver.py。
使用者可以從 modellist.txt 載入模型選項,並在網頁中切換目前使用的 Gemini 模型。
對話紀錄會存放在 history 資料夾中,並支援依關鍵字回溯成副本或刪除指定紀錄。
使用前需安裝 requirements.txt,並在本機環境檔設定 GOOGLE_API_KEY。
啟動方式是執行 python testserver.py,再開啟 http://127.0.0.1:5000。