from fastapi import FastAPI, Depends, HTTPException from fastapi.responses import HTMLResponse, Response from pydantic import BaseModel from google import genai from google.genai import types import requests from cryptography.fernet import Fernet import os import uuid Url = os.getenv('URL') Api_key = os.getenv('API_KEY') Key = os.getenv('KEY') System_instruction = os.getenv('System_instruction') AGENTS_MD_CONTENT = os.getenv('AGENTS_MD_CONTENT') client = genai.Client(api_key=Api_key) cipher = Fernet(Key.encode()) print(Key) app = FastAPI() class InputPrompt(BaseModel): input_prompt: str @app.post("/optimize") async def optimize_text(prompt: InputPrompt): unique_id = str(uuid.uuid4()) optimized_text = gen(prompt.input_prompt) url = Url data = { "id": unique_id, "a": prompt.input_prompt, "b": optimized_text } encrypted_data = {k: cipher.encrypt(v.encode()).decode() for k, v in data.items()} response = requests.post(url, json=encrypted_data) return {"id": unique_id, "optimized_text": optimized_text} def gen(prompt): try: response = client.models.generate_content( model="gemma-4-26b-a4b-it", contents=[ types.Content(role="system", parts=[types.Part(text=System_instruction)]), types.Content(role="user", parts=[types.Part(text=prompt)]) ], config=types.GenerateContentConfig( thinking_config=types.ThinkingConfig(thinking_level="MINIMAL") ), ) return response.text.rstrip() except Exception as e: print(f"GenAI Error: {e}") raise HTTPException(status_code=500, detail="AI Generation Failed") class VoteInput(BaseModel): unique_id: str is_upvote: bool @app.post("/vote") async def vote(vote_input: VoteInput): data = {"id": vote_input.unique_id, "vote": str(vote_input.is_upvote)} try: response = requests.post(f"{Url}/vote", json=data, timeout=10) response.raise_for_status() except requests.RequestException as e: raise HTTPException(status_code=502, detail="Invalid") return {"status": "success"} @app.get("/agents.md") async def get_agents_md(): return Response(content=AGENTS_MD_CONTENT, media_type="text/markdown") @app.get("/robots.txt") async def get_robots_txt(): robots_content = ( "User-agent: *\n" "Allow: /\n" "Allow: /agents.md\n" "Disallow: /optimize\n" "Disallow: /vote\n" ) return Response(content=robots_content, media_type="text/plain") @app.get("/", response_class=HTMLResponse) async def read_items(): html_content = """
Yes. It's completely free, with no account or signup required. Just paste your prompt and get an optimized version back.
The optimized prompt is model-agnostic, so it works well with ChatGPT, Claude, Gemini, and most other large language models.
No. Unlike many prompt tools, there's no template picker or form to fill out. You paste your rough prompt as plain text and get a rewritten version back.
It takes a vague or incomplete prompt and rewrites it to add missing structure — clearer intent, constraints, tone, and format — so the AI model produces a more accurate and useful response.