Skip to content

Commit 5520b65

Browse files
committed
adding eval dataset
1 parent ee09814 commit 5520b65

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed

recipes/use_cases/prompt-migration/prompt_migration/eval_dataset.py

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,163 @@ def get_evaluation_dataset() -> List[Dict]:
101101
environmental impact depends on electricity source and battery recycling.""",
102102
"prompt_type": "analysis",
103103
"complexity": "complex"
104+
},
105+
106+
# Code Generation
107+
{
108+
"text": "Write a Python function to check if a number is prime.",
109+
"expected_summary": """def is_prime(n):
110+
if n < 2:
111+
return False
112+
for i in range(2, int(n ** 0.5) + 1):
113+
if n % i == 0:
114+
return False
115+
return True""",
116+
"prompt_type": "code_generation",
117+
"complexity": "medium"
118+
},
119+
{
120+
"text": "Create a Python function to reverse a string.",
121+
"expected_summary": """def reverse_string(s):
122+
return s[::-1]""",
123+
"prompt_type": "code_generation",
124+
"complexity": "simple"
125+
},
126+
127+
{
128+
"text": "Explain what this code does: [x*x for x in range(10) if x % 2 == 0]",
129+
"expected_summary": "This list comprehension creates a list of squares of even numbers from 0 to 9. It filters numbers where x modulo 2 equals 0 (even numbers) and squares them.",
130+
"prompt_type": "code_explanation",
131+
"complexity": "medium"
132+
},
133+
134+
{
135+
"text": "Write a Python function to implement binary search.",
136+
"expected_summary": """def binary_search(arr, target):
137+
left, right = 0, len(arr) - 1
138+
139+
while left <= right:
140+
mid = (left + right) // 2
141+
if arr[mid] == target:
142+
return mid
143+
elif arr[mid] < target:
144+
left = mid + 1
145+
else:
146+
right = mid - 1
147+
148+
return -1""",
149+
"prompt_type": "code_generation",
150+
"complexity": "medium"
151+
},
152+
153+
{
154+
"text": "Implement a Stack class in Python using a list.",
155+
"expected_summary": """class Stack:
156+
def __init__(self):
157+
self.items = []
158+
159+
def push(self, item):
160+
self.items.append(item)
161+
162+
def pop(self):
163+
if not self.is_empty():
164+
return self.items.pop()
165+
166+
def is_empty(self):
167+
return len(self.items) == 0
168+
169+
def peek(self):
170+
if not self.is_empty():
171+
return self.items[-1]""",
172+
"prompt_type": "code_generation",
173+
"complexity": "medium"
174+
},
175+
176+
{
177+
"text": "Find and fix the bug in this code: def factorial(n): return n * factorial(n-1)",
178+
"expected_summary": """def factorial(n):
179+
if n == 0 or n == 1:
180+
return 1
181+
return n * factorial(n-1)""",
182+
"prompt_type": "code_debugging",
183+
"complexity": "medium"
184+
},
185+
186+
{
187+
"text": "Optimize this code: def fibonacci(n): return fibonacci(n-1) + fibonacci(n-2) if n > 1 else n",
188+
"expected_summary": """def fibonacci(n):
189+
if n <= 1:
190+
return n
191+
a, b = 0, 1
192+
for _ in range(2, n + 1):
193+
a, b = b, a + b
194+
return b""",
195+
"prompt_type": "code_optimization",
196+
"complexity": "medium"
197+
},
198+
199+
{
200+
"text": "Write a Python function using requests to fetch data from a REST API endpoint.",
201+
"expected_summary": """import requests
202+
203+
def fetch_data(url, params=None):
204+
try:
205+
response = requests.get(url, params=params)
206+
response.raise_for_status()
207+
return response.json()
208+
except requests.RequestException as e:
209+
print(f"Error fetching data: {e}")
210+
return None""",
211+
"prompt_type": "code_generation",
212+
"complexity": "medium"
213+
},
214+
215+
{
216+
"text": "Write a Python function to read a CSV file and return it as a list of dictionaries.",
217+
"expected_summary": """import csv
218+
219+
def read_csv(file_path):
220+
data = []
221+
try:
222+
with open(file_path, 'r') as file:
223+
reader = csv.DictReader(file)
224+
for row in reader:
225+
data.append(row)
226+
return data
227+
except Exception as e:
228+
print(f"Error reading CSV: {e}")
229+
return None""",
230+
"prompt_type": "code_generation",
231+
"complexity": "medium"
232+
},
233+
234+
{
235+
"text": "Write a Python function that safely converts a string to integer with error handling.",
236+
"expected_summary": """def safe_int_convert(s):
237+
try:
238+
return int(s), None
239+
except ValueError as e:
240+
return None, str(e)""",
241+
"prompt_type": "code_generation",
242+
"complexity": "simple"
243+
},
244+
245+
# Complex Algorithm
246+
{
247+
"text": "Implement a Python function for Depth-First Search on a graph.",
248+
"expected_summary": """def dfs(graph, start, visited=None):
249+
if visited is None:
250+
visited = set()
251+
252+
visited.add(start)
253+
254+
for next_node in graph[start]:
255+
if next_node not in visited:
256+
dfs(graph, next_node, visited)
257+
258+
return visited""",
259+
"prompt_type": "code_generation",
260+
"complexity": "complex"
104261
}
105262
]
106263

0 commit comments

Comments
 (0)