saicharantej commited on
Commit
8de1fb8
·
verified ·
1 Parent(s): 95e0e2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -9
app.py CHANGED
@@ -21,19 +21,88 @@ def cohere_response(msg):
21
  print(event.text, end='')
22
  return output
23
 
24
- def generate_mockup(problem):
25
- prompt_sum = f'''You are a UX designer who is an expert in generating front-end code for a given requirement from a product manager: {problem}.
26
- You need to carefully understand the requirement and generate the HTML code for a series of mockups that together form a clickable prototype.
27
- You can use Bootstrap and popularly available visual libraries to generate the code.Each screen should be clearly delimited by the header - Screen 1, Screen 2, Screen 3, etc. Do not generate placeholders and always make assumptions that make the generated
28
- mockups useful to solve real-world problems. Each mockup should link to the next, creating a seamless user experience. The prototype should be visually appealing and
29
- satisfy the requirement as a mockup. You are supposed to just generate the HTML code and nothing else as output.'''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  response = cohere_response(prompt_sum)
31
  return response
32
 
33
  # Define a function to handle form submissions (this is just a placeholder)
34
  def handle_form(requirements):
35
  print(requirements)
36
- emp_content = generate_mockup(requirements)
37
  #final_html_content = extract_html(emp_content)
38
  return emp_content, emp_content
39
 
@@ -42,7 +111,7 @@ gr.Interface(
42
  fn=handle_form,
43
  inputs=gr.Textbox(),
44
  outputs=[gr.HTML(),gr.Textbox()],
45
- title="Mockup Generator",
46
- description="Generate a mockup for a given requirement",
47
  examples=["Design an interface for a food delivery app payment checkout screen, a menu with categories like 'Asian Cuisine' and 'Italian Pasta', and a user profile section.","Generate a newsletter template for a tech company with sections for latest news, featured products, and upcoming events."],
48
  ).launch()
 
21
  print(event.text, end='')
22
  return output
23
 
24
+ def generate_prototype(problem):
25
+ prompt_sum = f'''You are a UX designer who is an expert in generating front-end code for a given requirement from a product manager: {problem}. Follow these step-by-step instructions to create a series of mockups that form a clickable prototype:
26
+
27
+ Understand the Requirement: Carefully read and understand the requirement provided by the product manager.
28
+
29
+ Identify Personas: Identify the personas outlined in the input problem. For example, if the requirement is for an e-commerce website, personas could include:
30
+
31
+ Shopper
32
+ Seller
33
+ Administrator
34
+ Generate Critical User Journeys (CUJs): For each persona, generate Critical User Journeys. For example:
35
+
36
+ Shopper: Searching for a product, adding a product to the cart, checking out.
37
+ Seller: Listing a product, managing inventory, viewing sales reports.
38
+ Administrator: Managing users, handling transactions, viewing site analytics.
39
+ Create Screens: Based on the CUJs, create the corresponding screens. For each screen, write HTML code that includes the header with the screen number and the CUJ it caters to. Ensure each screen links to the next to form a clickable prototype.
40
+
41
+ Use Bootstrap and Visual Libraries: Utilize Bootstrap and other popular visual libraries to enhance the design and functionality of the mockups.
42
+
43
+ Avoid Placeholders: Do not use placeholders. Instead, assume real-world use cases to make the mockups useful and realistic.
44
+
45
+ Ensure Visual Appeal: The mockups should be visually appealing and user-friendly.
46
+
47
+ Output HTML Code Only: Generate only the HTML code for the mockups, nothing else.
48
+
49
+ Example
50
+ Screen 1: Searching for a product (Shopper)
51
+
52
+ html
53
+ Copy code
54
+ <!DOCTYPE html>
55
+ <html lang="en">
56
+ <head>
57
+ <meta charset="UTF-8">
58
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
59
+ <title>Screen 1: Searching for a product (Shopper)</title>
60
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
61
+ </head>
62
+ <body>
63
+ <div class="container">
64
+ <h1>Search for a Product</h1>
65
+ <form>
66
+ <div class="form-group">
67
+ <label for="search">Search</label>
68
+ <input type="text" class="form-control" id="search" placeholder="Enter product name">
69
+ </div>
70
+ <button type="submit" class="btn btn-primary">Search</button>
71
+ </form>
72
+ <a href="screen2.html" class="btn btn-link">Next: Adding a product to the cart</a>
73
+ </div>
74
+ </body>
75
+ </html>
76
+ Screen 2: Adding a product to the cart (Shopper)
77
+
78
+ html
79
+ Copy code
80
+ <!DOCTYPE html>
81
+ <html lang="en">
82
+ <head>
83
+ <meta charset="UTF-8">
84
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
85
+ <title>Screen 2: Adding a product to the cart (Shopper)</title>
86
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
87
+ </head>
88
+ <body>
89
+ <div class="container">
90
+ <h1>Product Details</h1>
91
+ <p>Product Name: Awesome Widget</p>
92
+ <p>Price: $19.99</p>
93
+ <button class="btn btn-success">Add to Cart</button>
94
+ <a href="screen3.html" class="btn btn-link">Next: Checking out</a>
95
+ </div>
96
+ </body>
97
+ </html>
98
+ Follow this structure for each screen and CUJ, ensuring a seamless and visually appealing user experience.'''
99
  response = cohere_response(prompt_sum)
100
  return response
101
 
102
  # Define a function to handle form submissions (this is just a placeholder)
103
  def handle_form(requirements):
104
  print(requirements)
105
+ emp_content = generate_prototype(requirements)
106
  #final_html_content = extract_html(emp_content)
107
  return emp_content, emp_content
108
 
 
111
  fn=handle_form,
112
  inputs=gr.Textbox(),
113
  outputs=[gr.HTML(),gr.Textbox()],
114
+ title="Prototype generator",
115
+ description="Generate a prototype for a given requirement",
116
  examples=["Design an interface for a food delivery app payment checkout screen, a menu with categories like 'Asian Cuisine' and 'Italian Pasta', and a user profile section.","Generate a newsletter template for a tech company with sections for latest news, featured products, and upcoming events."],
117
  ).launch()