PromptShield is a resilient browser prompt enhancer for AI apps like ChatGPT, Claude, and Gemini.
It improves weak prompts and demonstrates resilience when the primary LLM or tool layer fails. The MVP uses a Chrome extension frontend, FastAPI backend, and a TrueFoundry AI Gateway-compatible OpenAI client.
- Floats over ChatGPT / Claude / Gemini
- Reads the user's draft prompt
- Enhances it based on mode: general, resume, coding, research, academic
- Calls a backend connected to TrueFoundry AI Gateway
- Falls back to a local rule-based prompt enhancer if the gateway/model fails
- Includes chaos mode for hackathon demo: simulate LLM failure
- Logs gateway success/failure and fallback behavior
Browser AI App
↓
PromptShield Chrome Extension
↓ localhost:8000
FastAPI Backend
↓
TrueFoundry AI Gateway Virtual Model
↓
Primary LLM → fallback model(s)
If gateway/model fails:
FastAPI → local fallback enhancer → user still gets a useful promptpromptshield/
backend/
main.py
gateway_client.py
resilience.py
prompt_templates.py
requirements.txt
.env.example
extension/
manifest.json
content.js
styles.css
README.md- Python 3.10+
- Google Chrome or Chromium-based browser
- TrueFoundry AI Gateway endpoint and API key
You can still run the app without TrueFoundry credentials to test local fallback behavior.
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .envEdit .env:
TRUEFOUNDRY_API_KEY=your_truefoundry_gateway_key
TRUEFOUNDRY_GATEWAY_BASE_URL=https://your-gateway-url/v1
TRUEFOUNDRY_VIRTUAL_MODEL=promptshield-routerStart the server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000Open:
http://localhost:8000/docscurl -X POST http://localhost:8000/enhance \
-H "Content-Type: application/json" \
-d '{"prompt":"make my resume better","mode":"resume"}'Simulate LLM failure:
curl -X POST "http://localhost:8000/chaos/toggle?kind=llm_failure&enabled=true"Turn it off:
curl -X POST "http://localhost:8000/chaos/toggle?kind=llm_failure&enabled=false"View logs:
curl http://localhost:8000/logs- Open Chrome.
- Go to
chrome://extensions/. - Turn on Developer mode.
- Click Load unpacked.
- Select the
extension/folder. - Open
https://chatgpt.com/. - You should see the PromptShield floating widget.
- Open ChatGPT.
- Type:
make my resume better. - Click Enhance Prompt.
- Show the improved prompt.
- Click Simulate LLM Failure.
- Type another weak prompt.
- Click Enhance Prompt again.
- Show that PromptShield still returns a useful prompt using local fallback.
- Open
http://localhost:8000/logsto show resilience logs.
PromptShield: A resilient prompt copilot that improves user input and survives LLM/tool failures without breaking the user experience.
Failure scenarios shown:
- Primary LLM failure
- Gateway/client exception
- Slow response simulation
- Local fallback response
- User-facing recovery status
- Observability logs
- Add MCP server failure simulation
- Add provider-level fallback visualization
- Add prompt quality scoring
- Add user memory/preferences
- Add team prompt library
- Add SDK for agent builders