How jgravelle/grompt works
Project type and purpose
• This is an open-source Python utility (“Grompt”) that serves as both:
a. A command-line tool / importable module for programmatically refactoring LLM prompts.
b. A Streamlit-based web demo app for interactive prompt optimization.
• Its purpose is to accept a user’s natural-language prompt, apply configurable transformation settings, and call the Groq LLM API to return a polished, structured prompt.
File structure
• Top-level scripts:
• Grompt.py – core library and CLI entry point
• streamlit_app.py – front-end web app using Streamlit
• prompt_canvas.py – auxiliary script (e.g., interactive local prompt builder/demo)
• Configuration and docs:
• .env_sample (sample environment variables)
• requirements.txt (dependencies: groq, python-dotenv, streamlit, etc.)
• src/ (contains Markdown guides: Grompt.md and custom_instructions.txt)
• No internal database or persistent storage—state is in memory; configuration via environment.
README for additional insights
• Core workflow: load .env → initialize Groq client → accept prompt → optionally read defaults from src/ → call Groq API → return optimized prompt.
• Two usage modes: CLI and Streamlit web UI.
• Configurable defaults: model, temperature, max_tokens.
Main components and interactions (to be shown
a. Front-ends
• CLI interface (Grompt.py main)
• Streamlit UI (streamlit_app.py)
• Optional local canvas UI (prompt_canvas.py)
b. Core service
• Grompt module:
• Config loader (dotenv)
• Default-prompt loader (src/Grompt.md, src/custom_instructions.txt)
• API client wrapper (groq Python SDK)
c. External service
• Groq LLM API endpoint
d. Supporting configuration
• .env file (.env_sample template)
• requirements.txt dependencies
Relationships and data flow
• User enters prompt (CLI or browser)
→ Front-end script invokes Grompt.rephrase_prompt()
→ Grompt module loads environment and default templates
→ Constructs API request and posts to Groq LLM service over HTTPS
→ Receives optimized prompt JSON response
→ Returns to front-end for display (stdout or web page)
Architectural patterns and design principles
• Separation of concerns:
• Presentation layer (CLI / Web UI)
• Business logic (prompt transformation and API orchestration in Grompt.py)
• Configuration layer (dotenv + src/)
• Plug-and-play extensibility: Grompt.py can be imported into any Python project.
• No persistent data store—stateless, real-time API calls.
Technologies and frameworks
• Python 3.6+
• groq Python SDK for API calls
• python-dotenv for configuration
• Streamlit for web UI