From 2d6ec559919e0f2bc1f5a840d016d953d82d18f9 Mon Sep 17 00:00:00 2001 From: Axel Peytavin Date: Thu, 8 Feb 2024 15:43:22 -0800 Subject: [PATCH 1/4] A pass of reformating + customize example a bit --- examples/social_network/main.py | 14 +++++++++----- natural_frontend/__init__.py | 2 +- natural_frontend/natural_frontend.py | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/social_network/main.py b/examples/social_network/main.py index 5746133..7d49f78 100644 --- a/examples/social_network/main.py +++ b/examples/social_network/main.py @@ -35,13 +35,17 @@ class Post(BaseModel): # Initial data users = [ - User(id=1, email="user1@example.com", name="User One"), - User(id=2, email="user2@example.com", name="User Two"), + User(id=1, email="axel@mail.com", name="Axel Peytavin"), + User(id=2, email="pierrot@great-ai-startup.com", name="Pierre"), + User(id=3, email="michelle@aol.com", name="Michelle"), ] posts = [ - Post(id=1, title="Post 1", content="Content of post 1", owner_id=1), - Post(id=2, title="Post 2", content="Content of post 2", owner_id=1), - Post(id=3, title="Post 3", content="Content of post 3", owner_id=2), + Post(id=1, title="I love my dog", content="I love my dog a lot", owner_id=1), + Post(id=2, title="I love my cat", content="He's so cute", owner_id=1), + Post( + id=3, title="Who left the door open?", content="I'm freezing here", owner_id=2 + ), + Post(id=4, title="I'm so happy", content="I just got a new job", owner_id=3), ] diff --git a/natural_frontend/__init__.py b/natural_frontend/__init__.py index da1ddd2..5418f82 100644 --- a/natural_frontend/__init__.py +++ b/natural_frontend/__init__.py @@ -1 +1 @@ -from natural_frontend.natural_frontend import NaturalFrontend # noqa +from natural_frontend.natural_frontend import NaturalFrontend # noqa diff --git a/natural_frontend/natural_frontend.py b/natural_frontend/natural_frontend.py index 9d663fd..5e0e7cd 100644 --- a/natural_frontend/natural_frontend.py +++ b/natural_frontend/natural_frontend.py @@ -206,14 +206,14 @@ def parse_potential_personas(personas: str, retries=5): "pink", "lightblue", ], # Replace with your actual colors - "frontend_endpoint": f"gen_{frontend_endpoint}" + "frontend_endpoint": f"gen_{frontend_endpoint}", }, ) @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') + server_host = request.headers.get("host") full_url = f"{scheme}://{server_host}" logging.info(f"Generating frontend for url: {full_url}") From b6314be1fc27014db01701f102396cf7fdfc2d4c Mon Sep 17 00:00:00 2001 From: Axel Peytavin Date: Fri, 9 Feb 2024 09:21:44 -0800 Subject: [PATCH 2/4] Fix: Wrong frontend endpoint variable in natural_frontend.py --- natural_frontend/natural_frontend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/natural_frontend/natural_frontend.py b/natural_frontend/natural_frontend.py index 5e0e7cd..0953390 100644 --- a/natural_frontend/natural_frontend.py +++ b/natural_frontend/natural_frontend.py @@ -206,7 +206,7 @@ def parse_potential_personas(personas: str, retries=5): "pink", "lightblue", ], # Replace with your actual colors - "frontend_endpoint": f"gen_{frontend_endpoint}", + "frontend_endpoint": f"{frontend_endpoint}", }, ) From c098bee2ecff8e27519542f4a7ffe98d47bd959e Mon Sep 17 00:00:00 2001 From: Axel Peytavin Date: Fri, 9 Feb 2024 09:21:51 -0800 Subject: [PATCH 3/4] Add personas to NaturalFrontendOptions --- examples/social_network/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/social_network/main.py b/examples/social_network/main.py index 7d49f78..c892f44 100644 --- a/examples/social_network/main.py +++ b/examples/social_network/main.py @@ -15,7 +15,19 @@ app = NaturalFrontend( app, openai_api_key=creds["key"], - options=NaturalFrontendOptions(frontend_endpoint=""), + options=NaturalFrontendOptions( + frontend_endpoint="frontend", + personas=[ + { + "persona": "Twitter Lover Reader", + "description": "User that loves reading posts on a Twitter-like platform", + }, + { + "persona": "Administrator", + "description": "User that can see and change all posts and users", + }, + ], + ), ) From fae9e1bd81d5e215186c2e3e4db0af2475cf9262 Mon Sep 17 00:00:00 2001 From: Axel Peytavin Date: Fri, 9 Feb 2024 09:22:04 -0800 Subject: [PATCH 4/4] Version 0.0.5 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e15f577..9fcd5bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "natural-frontend" -version = "0.0.4" +version = "0.0.5" authors = [ { name="Axel Peytavin", email="peytavin@stanford.edu" }, { name="Pierre Collignon", email="collignonpie@gmail.com" },