How andyk/recursive_llm works
Project type and purpose
• This is an open‑source command‑line tool (not a multi‑tier web app) whose sole responsibility is to automate “recursive” LLM prompting.
• It uses Python (run_recursive_gpt.py) to read an English‑language prompt from STDIN or a text file, submit it to the OpenAI API, receive back a new prompt, and repeat until a base case is reached.
File structure
• Top‑level files:
• README.md – detailed description, use cases, dependencies.
• run_recursive_gpt.py – the orchestration script.
• prompt_*.txt – various example prompt templates (fibonacci, counting, factorial).
• shell_demo_*.mp4 – recorded usage demos (documentation/artifacts, but not part of the runtime flow).
README for additional insights
• Confirms two recursion layers:
a) English‑based “recursive” prompt that regenerates itself toward a goal.
b) A Python function that calls itself with the model’s output.
• Highlights external dependency: OpenAI’s text‑davinci‑003 (or GPT‑3.5) API.
Main components
a. User/Developer (initiates the process via CLI or file redirect)
b. Prompt Templates (prompt_*.txt) or STDIN (initial prompt state)
c. Recursive Python Function (run_recursive_gpt.py)
d. OpenAI API / LLM service (text‑davinci‑003)
e. Terminal Output (prints “response #n” lines)
Relationships and data flow
• User → (initial prompt text) → Python script
• Python script ↔ (HTTP request/response) ↔ OpenAI API
• Python script → (stdout) → Terminal / User
• Python script → (recursive call) → itself, feeding the last API response back as the next prompt
Architectural patterns and design principles
• Client‑Service: local CLI client calling an external RESTful LLM service
• Separation of concerns: prompt templates (data) are decoupled from orchestration logic (code)
• Two recursion layers:
• Prompt‑level recursion (state encoded in English text)
• Code‑level recursion (run_recursive_gpt → run_recursive_gpt)
• Stateless orchestration aside from passing the evolving prompt string
Relevant technologies and libraries
• Python 3.x, openai Python SDK
• OpenAI REST API (text‑davinci‑003 or GPT‑3.5)
• Shell / STDIN/STDOUT
Essential architectural elements without over‑complicating
• Don’t try to model CI/CD or documentation videos—focus on runtime flow
1. User/CLI layer
2. Local orchestration layer (scripts + prompt files)
3. External LLM service layer