kwabs22 commited on
Commit
098fa9f
·
1 Parent(s): 35fa9a6

Lists in dictionary to avoid growing front end code

Browse files
Files changed (1) hide show
  1. app.py +100 -69
app.py CHANGED
@@ -94,76 +94,107 @@ def custom_generate_response(cust_user_message, prompt_index, prompts_list):
94
  cust_user_message = f"{prompt}\n\n{cust_user_message}\n\n{ending}"
95
  yield from generate_response(cust_user_message)
96
 
97
- CustomPrompts = [
98
- ("Write a Class Diagram based on the following text:", "Class Diagram:"),
99
- ("Write a Pydot code based on the following text:", "Pydot Code:"),
100
- ("Describe what a standard happy scene in any movie would be planned in great detail, based on the following text:", "Scene Details"),
101
- ("Explain a teardown of the product mentioned in the following text:", "Teardown Details:"),
102
- ("Explain the manufacturing of the product mentioned in the following text:", "Manufacturing Details:"),
103
- ("Explain the marketing considerations of the product mentioned in the following text:", "Considerations:"),
104
- ("Explain the target users considerations of the product mentioned in the following text:", "Target Users Considerations:"),
105
- ("My problem to solve is", "- please make 10 sub problems have to solve from this:"),
106
- ]
107
-
108
- BusinessPrompts = [
109
- ("Suggest Product ideas just based off the following text:", "Products:"),
110
- ("Write an outline for a business plan for: " , ""),
111
- ("Write an example of a detailed report for a Executive Summary for " , "Executive Summary:"),
112
- ("Write an example of a detailed report for a Company Description for " , "Company Description:"),
113
- ("Write an example of a detailed report for a Market Analysis for " , "Market Analysis:"),
114
- ("Write an example of a detailed report for a Marketing and Sales Strategy for " , "Marketing and Sales Strategy:"),
115
- ("Write an example of a detailed report for a Product Development for " , "Product Development:"),
116
- ("Write an example of a detailed report for a Operations and Management for " , "Operations and Management:"),
117
- ("Write an example of a detailed report for a Financial Projections for " , "Financial Projections:"),
118
- ("Explain how this to make this product unique from competitors:", "Considerations:"),
119
- ]
120
-
121
- ProgrammingPatternPrompts = [
122
- ("Demonstrate a builder pattern in go:", ""),
123
- ("Demonstrate a zero cost abstractions in go:", ""),
124
- ("Demonstrate a builder pattern in rust:", ""),
125
- ("Demonstrate a Polymorphism in rust:", ""),
126
- ("Explain how RAII pattern affects rust:", ""),
127
- ("Demonstrate a builder pattern in c++:", ""),
128
- ("Explain when to consider using a builder pattern in go:", ""),
129
- ]
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  with gr.Blocks() as iface:
132
- gr.HTML("<a href='https://huggingface.co/spaces/stabilityai/stablelm-2-1_6b-zephyr'> -- Original StabilityAI demo -- </a> | ")
133
- gr.Interface(
134
- fn=generate_response,
135
- inputs=gr.Textbox(lines=2, placeholder="Type your message here..."),
136
- outputs="text",
137
- title="Stable LM 2 Zephyr (1.6b) LLama.cpp Interface Test (Inconsistent Performance - 100 tokens in 50 secs (when this HF space is updated) or 800+ secs(HF space open for long))",
138
- description="No Prompt template used yet (Essentially autocomplete). No Message History for now - Enter your message and get a response.",
139
- flagging_dir="/usr/src/app/flagged",
140
- )
141
-
142
- gr.HTML("Any standard way of thinking / Repetitive idea / rule of thumb / advice can be turned into a button (In a timeline?)")
143
- gr.HTML("LLM powered Buttons as the new notetaking? (Youtube Video to prompt pipeline?)<br><br>List to buttons (Instead of buttons tabs and dropdowns?)")
144
-
145
- MainOutput = gr.TextArea(placeholder='Output will show here')
146
- CustomButtonInput = gr.TextArea(lines=1, placeholder='Prompt goes here')
147
-
148
- with gr.Accordion("Random Ideas"):
149
- with gr.Group():
150
- for index, (prompt, _) in enumerate(CustomPrompts):
151
- button = gr.Button(prompt)
152
- # Pass CustomPrompts list as an argument
153
- button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(CustomPrompts)], outputs=MainOutput)
154
-
155
- with gr.Accordion("General Product and Business based", open=False):
156
- with gr.Group():
157
- for index, (prompt, _) in enumerate(BusinessPrompts):
158
- button = gr.Button(prompt)
159
- # Pass BusinessPrompts list as an argument
160
- button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(BusinessPrompts)], outputs=MainOutput)
161
-
162
- with gr.Accordion("General Programming Pattern based", open=False):
163
- with gr.Group():
164
- for index, (prompt, _) in enumerate(ProgrammingPatternPrompts):
165
- button = gr.Button(prompt)
166
- # Pass BusinessPrompts list as an argument
167
- button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(ProgrammingPatternPrompts)], outputs=MainOutput)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
  iface.queue().launch(server_name="0.0.0.0", share=True)
 
94
  cust_user_message = f"{prompt}\n\n{cust_user_message}\n\n{ending}"
95
  yield from generate_response(cust_user_message)
96
 
97
+ Allprompts = {
98
+ "Custom Prompts" : [
99
+ ("Write a Class Diagram based on the following text:", "Class Diagram:"),
100
+ ("Write a Pydot code based on the following text:", "Pydot Code:"),
101
+ ("Describe what a standard happy scene in any movie would be planned in great detail, based on the following text:", "Scene Details"),
102
+ ("Explain a teardown of the product mentioned in the following text:", "Teardown Details:"),
103
+ ("Explain the manufacturing of the product mentioned in the following text:", "Manufacturing Details:"),
104
+ ("Explain the marketing considerations of the product mentioned in the following text:", "Considerations:"),
105
+ ("Explain the target users considerations of the product mentioned in the following text:", "Target Users Considerations:"),
106
+ ("My problem to solve is", "- please make 10 sub problems have to solve from this:"),
107
+ ],
108
+ "Business Prompts" : [
109
+ ("Suggest Product ideas just based off the following text:", "Products:"),
110
+ ("Write an outline for a business plan for: " , ""),
111
+ ("Write an example of a detailed report for a Executive Summary for " , "Executive Summary:"),
112
+ ("Write an example of a detailed report for a Company Description for " , "Company Description:"),
113
+ ("Write an example of a detailed report for a Market Analysis for " , "Market Analysis:"),
114
+ ("Write an example of a detailed report for a Marketing and Sales Strategy for " , "Marketing and Sales Strategy:"),
115
+ ("Write an example of a detailed report for a Product Development for " , "Product Development:"),
116
+ ("Write an example of a detailed report for a Operations and Management for " , "Operations and Management:"),
117
+ ("Write an example of a detailed report for a Financial Projections for " , "Financial Projections:"),
118
+ ("Explain how this to make this product unique from competitors:", "Considerations:"),
119
+ ],
120
+ "Programming Pattern Prompts" : [
121
+ ("Demonstrate a builder pattern in go:", ""),
122
+ ("Demonstrate a zero cost abstractions in go:", ""),
123
+ ("Demonstrate a builder pattern in rust:", ""),
124
+ ("Demonstrate a Polymorphism in rust:", ""),
125
+ ("Explain how RAII pattern affects rust:", ""),
126
+ ("Demonstrate a builder pattern in c++:", ""),
127
+ ("Explain when to consider using a builder pattern in go:", ""),
128
+ ],
129
+ "Creativity Prompts" : [
130
+ ("Make the following text more vague:", "Vague version:"),
131
+ ("Turn the following text into a bunch of rules:", "Rules:"),
132
+ ("What Syllogisms can be made from this text:", "Syllogisms:"),
133
+ ("Reimagine the following text:", ""),
134
+ ],
135
+ "Game Based" : [
136
+ ("What obstacles to growth exist in the following text:", "Obstacles:"),
137
+ ("Write a story for the basis of a random game", ""),
138
+ ("What are common themes in games?", ""),
139
+ ("Write Three factions and why they are at conflict based on the following text:", "Faction 1:"),
140
+ ]
141
+ }
142
 
143
  with gr.Blocks() as iface:
144
+ with gr.Tab("Single prompt"):
145
+ gr.HTML("<a href='https://huggingface.co/spaces/stabilityai/stablelm-2-1_6b-zephyr'> -- Original StabilityAI demo -- </a> | ")
146
+ gr.Interface(
147
+ fn=generate_response,
148
+ inputs=gr.Textbox(lines=2, placeholder="Type your message here..."),
149
+ outputs="text",
150
+ title="Stable LM 2 Zephyr (1.6b) LLama.cpp Interface Test (Inconsistent Performance - 100 tokens in 50 secs (when this HF space is updated) or 800+ secs(HF space open for long))",
151
+ description="No Prompt template used yet (Essentially autocomplete). No Message History for now - Enter your message and get a response.",
152
+ flagging_dir="/usr/src/app/flagged",
153
+ )
154
+
155
+ gr.HTML("Any standard way of thinking / Repetitive idea / rule of thumb / advice can be turned into a button (In a timeline?)")
156
+ gr.HTML("LLM powered Buttons as the new notetaking? (Youtube Video to prompt pipeline?)<br><br>List to buttons (Instead of buttons tabs and dropdowns maybe?)")
157
+
158
+ MainOutput = gr.TextArea(placeholder='Output will show here')
159
+ CustomButtonInput = gr.TextArea(lines=1, placeholder='Prompt goes here')
160
+
161
+ # with gr.Accordion("Random Ideas"):
162
+ # with gr.Group():
163
+ # for index, (prompt, _) in enumerate(CustomPrompts):
164
+ # button = gr.Button(prompt)
165
+ # # Pass CustomPrompts list as an argument
166
+ # button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(CustomPrompts)], outputs=MainOutput)
167
+
168
+ # with gr.Accordion("General Product and Business based", open=False):
169
+ # with gr.Group():
170
+ # for index, (prompt, _) in enumerate(BusinessPrompts):
171
+ # button = gr.Button(prompt)
172
+ # # Pass BusinessPrompts list as an argument
173
+ # button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(BusinessPrompts)], outputs=MainOutput)
174
+
175
+ # with gr.Accordion("General Programming Pattern based", open=False):
176
+ # with gr.Group():
177
+ # for index, (prompt, _) in enumerate(ProgrammingPatternPrompts):
178
+ # button = gr.Button(prompt)
179
+ # # Pass BusinessPrompts list as an argument
180
+ # button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(ProgrammingPatternPrompts)], outputs=MainOutput)
181
+
182
+ # with gr.Accordion("General Creativity Pattern based", open=False):
183
+ # with gr.Group():
184
+ # for index, (prompt, _) in enumerate(CreativityPrompts):
185
+ # button = gr.Button(prompt)
186
+ # # Pass BusinessPrompts list as an argument
187
+ # button.click(custom_generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(CreativityPrompts)], outputs=MainOutput)
188
+
189
+ for category_name, category_prompts in Allprompts.items():
190
+ with gr.Accordion(f"General {category_name} Pattern based"):
191
+ with gr.Group():
192
+ for index, (prompt, _) in enumerate(category_prompts):
193
+ button = gr.Button(prompt)
194
+ button.click(generate_response, inputs=[CustomButtonInput, gr.State(index), gr.State(category_name)], outputs=MainOutput)
195
+
196
+
197
+ with gr.Tab("Workflow Brainstom"):
198
+ gr.HTML("Workflow = premeditated events --- need a timeline before prompts")
199
 
200
  iface.queue().launch(server_name="0.0.0.0", share=True)