Skip to content

Ansenchen123/AI_server_test

Repository files navigation

AI Server Test

AI Server Test is a Flask-served browser chat interface for Gemini with model selection and local JSON conversation history.

Features

  • Serves index.html, style.css, and script.js from a Flask application.
  • Sends browser chat requests to Gemini through Flask API routes.
  • Lists available models from modellist.txt and 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.

Requirements

  • 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, and python-dotenv.
  • A browser for using the served chat interface.

Setup

  1. Create and activate a virtual environment.
  2. Install dependencies:
pip install -r requirements.txt
  1. Copy .env.example to a local .env file.
  2. Set the Gemini API key:
GOOGLE_API_KEY=your-google-api-key
  1. Review modellist.txt if you want to change the model options shown in the UI.

The server creates the history folder automatically when background.py is imported.

Run

Start the Flask server:

python testserver.py

Open 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.

Project Structure

  • 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 containing GOOGLE_API_KEY.

摘要

AI Server Test 是一個以 Flask 提供服務的 Gemini 網頁聊天介面。 前端由 index.htmlstyle.cssscript.js 組成,後端 API 則在 testserver.py。 使用者可以從 modellist.txt 載入模型選項,並在網頁中切換目前使用的 Gemini 模型。 對話紀錄會存放在 history 資料夾中,並支援依關鍵字回溯成副本或刪除指定紀錄。 使用前需安裝 requirements.txt,並在本機環境檔設定 GOOGLE_API_KEY。 啟動方式是執行 python testserver.py,再開啟 http://127.0.0.1:5000

About

Browser-based Gemini chat interface with Flask backend, model switching, and local history management.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors