Really-amin commited on
Commit
ea9e5d3
·
verified ·
1 Parent(s): 0b249f3

Upload PromptForge v1.0 — Structured prompt generator for Google AI Studio

Browse files
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "github.copilot.chat.codeGeneration.useInstructionFiles": true
3
+ }
backend/instruction_store.py CHANGED
@@ -9,7 +9,7 @@ from datetime import datetime
9
  from pathlib import Path
10
  from typing import Dict, List, Optional
11
 
12
- from schemas import (
13
  InstructionSettings, InstructionSettingsCreate, InstructionSettingsUpdate,
14
  AIProvider, OutputFormat, PersonaType, StyleType,
15
  )
 
9
  from pathlib import Path
10
  from typing import Dict, List, Optional
11
 
12
+ from .schemas import (
13
  InstructionSettings, InstructionSettingsCreate, InstructionSettingsUpdate,
14
  AIProvider, OutputFormat, PersonaType, StyleType,
15
  )
backend/main.py CHANGED
@@ -7,21 +7,21 @@ import logging, os
7
  from pathlib import Path
8
  from typing import List, Optional
9
 
10
- from fastapi import FastAPI, HTTPException, Query, status
11
  from fastapi.middleware.cors import CORSMiddleware
12
  from fastapi.responses import HTMLResponse, JSONResponse
13
  from fastapi.staticfiles import StaticFiles
14
  from pydantic import BaseModel
15
 
16
- import store
17
- import instruction_store
18
- from ai_client import enhance_prompt, check_hf_key, check_google_key, HF_DEFAULT_MODEL, GOOGLE_DEFAULT_MODEL
19
- from prompt_logic import (
20
  build_manifest, build_manifest_from_settings,
21
  apply_edits, refine_with_feedback, generate_explanation,
22
  apply_target_formatting,
23
  )
24
- from schemas import (
25
  ApproveRequest, ApproveResponse,
26
  ExportRequest, ExportResponse,
27
  GenerateRequest, GenerateFromSettingsRequest, GenerateResponse,
@@ -109,6 +109,28 @@ async def get_config() -> EnvConfigStatus:
109
  )
110
 
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  @app.get("/api/stats", response_model=StatsResponse, tags=["System"])
113
  async def get_stats() -> StatsResponse:
114
  s = store.get_stats()
 
7
  from pathlib import Path
8
  from typing import List, Optional
9
 
10
+ from fastapi import FastAPI, HTTPException, Query, status, UploadFile, File
11
  from fastapi.middleware.cors import CORSMiddleware
12
  from fastapi.responses import HTMLResponse, JSONResponse
13
  from fastapi.staticfiles import StaticFiles
14
  from pydantic import BaseModel
15
 
16
+ from . import store
17
+ from . import instruction_store
18
+ from .ai_client import enhance_prompt, check_hf_key, check_google_key, HF_DEFAULT_MODEL, GOOGLE_DEFAULT_MODEL
19
+ from .prompt_logic import (
20
  build_manifest, build_manifest_from_settings,
21
  apply_edits, refine_with_feedback, generate_explanation,
22
  apply_target_formatting,
23
  )
24
+ from .schemas import (
25
  ApproveRequest, ApproveResponse,
26
  ExportRequest, ExportResponse,
27
  GenerateRequest, GenerateFromSettingsRequest, GenerateResponse,
 
109
  )
110
 
111
 
112
+ @app.post("/api/upload-main", tags=["System"])
113
+ async def upload_main(file: UploadFile = File(...)) -> dict:
114
+ """Upload an HTML file and replace the frontend index.html (simple uploader).
115
+ The uploaded file must be an HTML file. The previous index.html is backed up
116
+ to `index.html.bak` if present.
117
+ """
118
+ if not file.filename.lower().endswith(".html"):
119
+ raise HTTPException(status_code=400, detail="Only .html files are allowed.")
120
+ try:
121
+ content = await file.read()
122
+ dest = _FRONTEND_DIR / "index.html"
123
+ # Backup existing index
124
+ if dest.exists():
125
+ bak = _FRONTEND_DIR / "index.html.bak"
126
+ bak.write_bytes(dest.read_bytes())
127
+ dest.write_bytes(content)
128
+ except Exception as exc:
129
+ logger.exception("Failed to save uploaded main file")
130
+ raise HTTPException(status_code=500, detail=str(exc))
131
+ return {"success": True, "message": "Uploaded as main index.", "link": "/"}
132
+
133
+
134
  @app.get("/api/stats", response_model=StatsResponse, tags=["System"])
135
  async def get_stats() -> StatsResponse:
136
  s = store.get_stats()
backend/prompt_logic.py CHANGED
@@ -9,7 +9,7 @@ import textwrap
9
  from datetime import datetime
10
  from typing import Any, Dict, List, Optional, Tuple
11
 
12
- from schemas import (
13
  PromptManifest,
14
  StructuredPrompt,
15
  PersonaType,
 
9
  from datetime import datetime
10
  from typing import Any, Dict, List, Optional, Tuple
11
 
12
+ from .schemas import (
13
  PromptManifest,
14
  StructuredPrompt,
15
  PersonaType,
backend/schemas.py CHANGED
@@ -298,9 +298,4 @@ class EnvConfigStatus(BaseModel):
298
  port: str = "7860"
299
  version: str = "4.0"
300
  hf_model: str = "mistralai/Mistral-7B-Instruct-v0.2"
301
- google_model: str = "gemini-1.5-flash"
302
- class TargetModel(str, Enum):
303
- google_ai_studio = "google_ai_studio"
304
- openai = "openai"
305
- anthropic = "anthropic"
306
- generic = "generic"
 
298
  port: str = "7860"
299
  version: str = "4.0"
300
  hf_model: str = "mistralai/Mistral-7B-Instruct-v0.2"
301
+ google_model: str = "gemini-1.5-flash"
 
 
 
 
 
backend/store.py CHANGED
@@ -10,7 +10,7 @@ from datetime import datetime
10
  from pathlib import Path
11
  from typing import Dict, List, Optional
12
 
13
- from schemas import PromptManifest, HistoryEntry, PromptStatus
14
 
15
  logger = logging.getLogger("promptforge.store")
16
 
 
10
  from pathlib import Path
11
  from typing import Dict, List, Optional
12
 
13
+ from .schemas import PromptManifest, HistoryEntry, PromptStatus
14
 
15
  logger = logging.getLogger("promptforge.store")
16