saicharantej commited on
Commit
40de3d2
1 Parent(s): 0a8441f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cohere
3
+
4
+ co = cohere.Client(
5
+ api_key="0DjnHo0ao7mVua9IpqnWsTcNNIgEM6AkQHKGKrBg", # This is your trial API key
6
+ )
7
+
8
+ def cohere_response(msg):
9
+ stream = co.chat_stream(
10
+ model='command-r-plus',
11
+ message=msg,
12
+ temperature=0.3,
13
+ chat_history=[],
14
+ prompt_truncation='AUTO',
15
+ )
16
+ output = ''
17
+ for event in stream:
18
+ if event.event_type == "text-generation":
19
+ output += event.text
20
+ print(event.text, end='')
21
+ return output
22
+
23
+ def generate_mockup(problem):
24
+ 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}. You need to carefully understand the requirement
25
+ and generate the html code for the mockup. You can use bootstrap and popularly available visual libraries to generate the code. Do not generate placeholders and always make assumptions that makes the generated mockup useful to solve real-world problems. It should be visually appealing and should
26
+ satisfy the requirement as a mockup. You are supposed to just generate the html code and nothing else as output.'''
27
+ response = cohere_response(prompt_sum)
28
+ return response
29
+
30
+ # Define a function to handle form submissions (this is just a placeholder)
31
+ def handle_form(inputs):
32
+ print(inputs)
33
+ emp_content = generate_mockup(inputs)
34
+ #final_html_content = extract_html(emp_content)
35
+ return emp_content, emp_content
36
+
37
+ # Create a Gradio interface to showcase the HTML content
38
+ gr.Interface(
39
+ fn=handle_form,
40
+ inputs=gr.Textbox(),
41
+ outputs=[gr.HTML(),gr.Textbox()],
42
+ title="Mockup Generator",
43
+ description="Generate a mockup for a given requirement",
44
+ examples=[],
45
+ ).launch()