AI Context & Architecture Guide for Gemini
This document provides context for AI coding assistants to understand the architecture, design patterns, and workflows of the `trans-summary` project.
AI Context & Architecture Guide for Gemini
This document provides context for AI coding assistants to understand the architecture, design patterns, and workflows of the trans-summary project.
1. Architecture Overview
The project follows a Core-Wrapper pattern to separate business logic from user interfaces.
- Core Logic (
pipeline.py): Contains the implementation of all major processing steps (formatting, summarizing, generating). It handles API interactions, file I/O, and logic. It is UI-agnostic. - Shared Utilities (
transcript_utils.py): Provides robust primitives for logging, API calls (with retry/validation), text normalization, and regex extraction. - Configuration (
config.py): Central source of truth for file paths, model selection, and constants. - Interfaces:
- GUI (
ts_gui.py): Tkinter-based interface that callspipeline.pyfunctions in threads. - CLI Wrappers (
transcript_*.py): Simple scripts that parse arguments and callpipeline.pyfunctions.
- GUI (
2. Data Pipeline Flow
Files move through specific states, denoted by suffixes and directories:
- Ingestion:
source/*.txt(Raw text)- Action:
format_transcript
- Action:
- Formatting:
formatted/* - formatted.md(Clean Markdown)- Action:
add_yaml
- Action:
- Metadata:
formatted/* - yaml.md(Formatted + Frontmatter)- Action:
summarize_transcript
- Action:
- Extraction:
projects/* - structural-themes.md,interpretive-themes.md,topics.md,key-terms.md,lenses-ranked.md,bowen-references.md,emphasis-items.md - Synthesis:
projects/* - summary-generated.md,abstract-generated.md - Publication:
projects/*.html,projects/*.pdf
3. Key Design Patterns
API Interaction
- Centralized Calls: All Claude API calls go through
transcript_utils.call_claude_with_retry. - 7-Level Validation: Responses are rigorously validated (message type, role, stop reason, content existence, text validity, token usage) to prevent silent failures.
- Truncation Safety: The system automatically detects and rejects responses truncated by token limits.
- Streaming: Long generations use streaming to prevent timeouts.
Text Processing
- Regex over JSON: The pipeline prefers robust Regex extraction (see
transcript_utils.extract_section) over strict JSON parsing for large text blocks, as it is more forgiving of LLM formatting minor errors. - Fuzzy Matching: Validation scripts (
transcript_validate_*.py) usedifflib.SequenceMatcherto verify that generated quotes exist in the source text, handling minor punctuation/whitespace differences.
Prompt Management
- External Files: Prompts are stored as Markdown files in
prompts/. - Template Injection:
pipeline._fill_prompt_templatehandles Jinja-like variable replacement (e.g.,{{transcript}}).
4. Critical Files Map
| File | Responsibility |
|---|---|
pipeline.py | The Brain. Orchestrates all logic. If adding a feature, start here. |
config.py | The Settings. Paths, models, constants. |
transcript_utils.py | The Toolbox. Logging, API wrappers, text helpers. |
html_generator.py | The Publisher. Logic for HTML/PDF creation. |
summary_validation.py | The Critic. Deep semantic validation for summaries. |
abstract_validation.py | The Critic. Deep semantic validation for abstracts. |
ts_gui.py | The Face. Tkinter GUI implementation. |
5. Validation Strategy
The project emphasizes correctness. Every generation step has a corresponding validation step:
- Format:
validate_formatchecks word preservation. - Headers:
validate_headerschecks header relevance via LLM. - Abstract/Summary:
validate_coveragechecks if required topics are present. - Quotes:
validate_emphasis_itemsensures quotes are not hallucinations.
6. Common Tasks for AI Agents
-
Adding a new pipeline step:
- Define prompt in
prompts/. - Add logic to
pipeline.py. - Add CLI wrapper
transcript_new_step.py. - Update
ts_gui.pyto include a button.
- Define prompt in
-
Updating Prompts:
- Modify files in
prompts/. - Ensure placeholders (e.g.,
{{transcript}}) match whatpipeline.pyprovides.
- Modify files in
-
Changing Models:
- Update
DEFAULT_MODELorAUX_MODELinconfig.py.
- Update
-
Testing & QA:
- Always run
pytest testsafter making logic changes. - Run
ruff check .to ensure code style compliance. - Add new tests in
tests/if introducing new logic.
- Always run
7. Workflows
- Request Logging:
- Automatically track user requests and task completion status in
REQUEST_LOG.md. - Update this log at the start and end of significant tasks.
- Automatically track user requests and task completion status in
Related Documents
Totem — Development Rules
- **pnpm only** (never npm/yarn). Use `pnpm dlx` (never `npx`). Windows 11 + Git Bash. TypeScript strict mode.
MechCAD-MLLM
我们将这一新模型暂定名为 **"MechCAD-MLLM"**(面向机械领域的CAD多模态大模型)。
Gemini Project Context: ScryFall-UI
This file provides context for the Gemini AI assistant to understand and effectively assist with this project.
GEMINI.md — FIM One Instructional Context
FIM One is an AI-powered **Connector Hub** that serves as a bridge between disjointed enterprise systems (ERP, CRM, OA, Databases) through autonomous AI agents.