diff --git a/examples/social_network/main.py b/examples/social_network/main.py index 14937c8..5746133 100644 --- a/examples/social_network/main.py +++ b/examples/social_network/main.py @@ -4,7 +4,7 @@ from datetime import datetime import json -from natural_frontend.natural_frontend import NaturalFrontend +from natural_frontend.natural_frontend import NaturalFrontend, NaturalFrontendOptions app = FastAPI() @@ -12,7 +12,11 @@ with open("creds.json") as f: creds = json.load(f) -app = NaturalFrontend(app, openai_api_key=creds["key"]) +app = NaturalFrontend( + app, + openai_api_key=creds["key"], + options=NaturalFrontendOptions(frontend_endpoint=""), +) class User(BaseModel): diff --git a/natural_frontend/natural_frontend.py b/natural_frontend/natural_frontend.py index 10a04dd..9d663fd 100644 --- a/natural_frontend/natural_frontend.py +++ b/natural_frontend/natural_frontend.py @@ -115,9 +115,9 @@ async def on_startup(): frontend_generator.seed_prompt("FastAPI") frontend_generator.add_api_source(aggregated_api_source) - print("Natural Frontend was initiated successfully") + logging.info("Natural Frontend was initiated successfully") - @app.get(f"/{frontend_endpoint}/", response_class=HTMLResponse) + @app.get(f"/{frontend_endpoint}", response_class=HTMLResponse) async def frontend(request: Request): cache_key = "frontend_personas" @@ -206,10 +206,11 @@ def parse_potential_personas(personas: str, retries=5): "pink", "lightblue", ], # Replace with your actual colors + "frontend_endpoint": f"gen_{frontend_endpoint}" }, ) - @app.post(f"/gen_{frontend_endpoint}/", response_class=HTMLResponse) + @app.post(f"/gen_{frontend_endpoint}", response_class=HTMLResponse) async def handle_form(request: Request, persona: str = Form(...)): scheme = request.url.scheme server_host = request.headers.get('host') @@ -225,7 +226,7 @@ async def handle_form(request: Request, persona: str = Form(...)): # With the query in hand, send it to the NLP model # Handle the processed query response_content = frontend_generator.generate_frontend_code( - persona, full_url, options.colors, + persona, full_url, options.colors ) cache.set(cache_key, response_content) diff --git a/natural_frontend/templates/queryForm.html b/natural_frontend/templates/queryForm.html index 02ff079..adb5f50 100644 --- a/natural_frontend/templates/queryForm.html +++ b/natural_frontend/templates/queryForm.html @@ -95,9 +95,9 @@ max-width: 800px; margin: 0 auto; } - .persona-buttons button { + .persona-buttons-container button { margin: 5px; - padding: 10px; + padding: 10px 20px; border-radius: 5px; border: none; background-color: #f0f0f0; /* A neutral color for non-selected buttons */ @@ -105,13 +105,13 @@ transition: background-color 0.3s; background-image: none; } - .persona-buttons button.active { + .persona-buttons-container button.active { background-color: #a1eafb; /* A highlighted color for the active/selected button */ } - .persona-buttons { + .persona-buttons-container { margin-bottom: 20px; } - .persona-buttons h2 { + .persona-buttons-container h2 { margin-bottom: 5px; } .generate-btn { @@ -165,9 +165,33 @@ flex-direction: row; align-items: center; justify-content: center; + } + + .persona-buttons-container { + display: flex; + flex-direction: row; + align-items: center; + flex-wrap: wrap; + justify-content: center; margin-bottom: 20px; } + .form-container { + width: 600px; + display: flex; + flex-direction: column; + align-items: center; + } + + .form-container h2 { + margin-bottom: 20px; + } + + .persona-buttons-container button.active { + background-color: #a1eafb; /* Highlight color for the active/selected button */ + color: #333; /* Text color for the active/selected button */ + } + @keyframes spin { 0% { transform: rotate(0deg); @@ -188,7 +212,7 @@
-