Zing Forum

Reading

AI-Debate-partner: An Intelligent Debate Training Platform Based on Gemini

An AI debate platform built with FastAPI and Python, supporting interactive debates with AI, featuring context memory, dynamic prompts, and automatic scoring functions.

AI辩论FastAPIGeminiStreamlit大语言模型教育科技Python批判性思维
Published 2026-05-14 14:20Recent activity 2026-05-14 14:29Estimated read 7 min
AI-Debate-partner: An Intelligent Debate Training Platform Based on Gemini
1

Section 01

Introduction: Core Overview of the AI-Debate-partner Intelligent Debate Training Platform

AI-Debate-partner is an open-source AI-driven debate platform developed by anushkam545. Built using Python and the FastAPI framework, it uses the Google Gemini 2.5 Flash large language model as its AI engine and integrates with a Streamlit frontend to form a full-stack application. Its core goal is to help users improve their argumentation skills and critical thinking by simulating real debate scenarios, with features like dynamic stance assignment, context memory, strict argument scoring, and detailed round feedback.

2

Section 02

Project Background and Core Objectives

This platform aims to enable users to engage in real-time interactive debates with AI and build a complete debate ecosystem. Unlike simple Q&A interactions, its unique features include dynamic stance assignment, dialogue memory management, quantitative scoring mechanisms, and a round feedback system, helping users think about issues from multiple perspectives and improve their debate skills.

3

Section 03

Analysis of Core Features

  1. Dynamic Stance Assignment: When the user selects a stance, the AI automatically chooses the opposite stance to ensure the debate's opposition and challenge;
  2. Context Memory: Passes the complete conversation history to the model so the AI can respond accurately to previous arguments;
  3. Argument Scoring System: Quantitatively scores arguments from 1 to 10 based on dimensions like logicality and sufficiency of evidence, deducting points for weak arguments or vague expressions;
  4. Round Feedback: Provides score comparisons and detailed reports, pointing out the strengths and weaknesses of the argumentation and the overall verdict.
4

Section 04

Technical Implementation Details

  • Backend Architecture: FastAPI framework, modules include main.py (API routes), debate_engine.py (Gemini interaction), prompts.py (prompt templates), memory.py (session storage), scoring.py (scoring feedback);
  • Prompt Engineering: Four templates (opening, rebuttal, scoring, summary);
  • Session Management: UUID-based in-memory storage, supporting multiple independent sessions;
  • Frontend: Built with Streamlit, the interface includes functions like topic input, stance selection, and argument submission.
5

Section 05

Development Challenges and Solutions

  1. API Quota Limitations: Create a new Google Cloud project to obtain quotas and upgrade to gemini-2.5-flash;
  2. Model Availability: Use genai.list_models() to dynamically detect available models;
  3. JSON Parsing: Three-layer strategy (remove Markdown fences, extract JSON with regex, alternative number extraction);
  4. String Formatting: Double the curly braces in example JSON to {{}};
  5. Response Truncation: Increase max_output_tokens from 512 to 1024.
6

Section 06

Application Scenarios and Value

  • Debate Skill Training: Provides an always-available training partner and identifies weak points in argumentation;
  • Critical Thinking Cultivation: Forces users to examine issues from multiple angles and reveals blind spots in their views;
  • View Pressure Testing: Acts as a devil's advocate to refine arguments;
  • Educational Assistance: Teachers can use it as an after-class practice tool, and scoring feedback can serve as an evaluation basis.
7

Section 07

Deployment and Usage Guide

  1. Clone the code repository;
  2. Create a Python virtual environment and install dependencies;
  3. Obtain the Gemini API key from Google AI Studio;
  4. Configure the .env file;
  5. Run the backend (Uvicorn, port 8000) and frontend (Streamlit, port 8501), then access the frontend via a browser to start debating.
8

Section 08

Summary and Future Outlook

This platform is well-designed and fully functional, demonstrating the application of LLMs in interactive educational scenarios and providing references for engineering practices like prompt design and error handling. Its open-source nature supports community expansion, such as multilingual support, complex scoring algorithms, and integration with more LLM providers. It will play a greater role in education and personal development in the future.