grahamwhiteuk commited on
Commit
3ba38dc
·
1 Parent(s): 6997fc5

fix: synchronise examples with the Granite Playground

Browse files
Files changed (1) hide show
  1. src/app.py +66 -3
src/app.py CHANGED
@@ -133,10 +133,73 @@ with gr.Blocks(fill_height=True, css_paths=css_file_path, head_paths=head_file_p
133
  chat_interface = gr.ChatInterface(
134
  fn=generate,
135
  examples=[
136
- ["Explain quantum computing"],
137
  ["What is OpenShift?"],
138
- ["Importance of low latency inference"],
139
- ["Write a binary search in Python"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  ],
141
  cache_examples=False,
142
  type="messages",
 
133
  chat_interface = gr.ChatInterface(
134
  fn=generate,
135
  examples=[
136
+ ["Explain the concept of quantum computing to someone with no background in physics or computer science."],
137
  ["What is OpenShift?"],
138
+ ["Why is low latency inference important?"],
139
+ [
140
+ """Imagine you're a productivity expert. How can I develop effective habits to increase my productivity and efficiency? Provide me with specific strategies and actionable steps I can implement in my daily routine.""" # noqa: E501
141
+ ],
142
+ [
143
+ """Explain the following code in a concise manner:
144
+
145
+ ```java
146
+ import java.util.ArrayList;
147
+ import java.util.List;
148
+
149
+ public class Main {
150
+
151
+ public static void main(String[] args) {
152
+ int[] arr = {1, 5, 3, 4, 2};
153
+ int diff = 3;
154
+ List<Pair> pairs = findPairs(arr, diff);
155
+ for (Pair pair : pairs) {
156
+ System.out.println(pair.x + " " + pair.y);
157
+ }
158
+ }
159
+
160
+ public static List<Pair> findPairs(int[] arr, int diff) {
161
+ List<Pair> pairs = new ArrayList<>();
162
+ for (int i = 0; i < arr.length; i++) {
163
+ for (int j = i + 1; j < arr.length; j++) {
164
+ if (Math.abs(arr[i] - arr[j]) < diff) {
165
+ pairs.add(new Pair(arr[i], arr[j]));
166
+ }
167
+ }
168
+ }
169
+
170
+ return pairs;
171
+ }
172
+ }
173
+
174
+ class Pair {
175
+ int x;
176
+ int y;
177
+ public Pair(int x, int y) {
178
+ this.x = x;
179
+ this.y = y;
180
+ }
181
+ }
182
+ ```"""
183
+ ],
184
+ [
185
+ """Generate a Java code block from the following explanation:
186
+
187
+ The code in the Main class finds all pairs in an array whose absolute difference is less than a given value.
188
+
189
+ The findPairs method takes two arguments: an array of integers and a difference value. It iterates over the array and compares each element to every other element in the array. If the absolute difference between the two elements is less than the difference value, a new Pair object is created and added to a list.
190
+
191
+ The Pair class is a simple data structure that stores two integers.
192
+
193
+ The main method creates an array of integers, initializes the difference value, and calls the findPairs method to find all pairs in the array. Finally, the code iterates over the list of pairs and prints each pair to the console.""" # noqa: E501
194
+ ],
195
+ ],
196
+ example_labels=[
197
+ "Explain quantum computing",
198
+ "What is OpenShift?",
199
+ "Importance of low latency inference",
200
+ "Boosting productivity habits",
201
+ "Explain and document your code",
202
+ "Generate Java Code",
203
  ],
204
  cache_examples=False,
205
  type="messages",