|
1087 | 1087 | "name": "stdout", |
1088 | 1088 | "output_type": "stream", |
1089 | 1089 | "text": [ |
| 1090 | + "⚠️ Für diesen Test nutzen wir absichtlich ein kleineres Modell: github_copilot/gpt-4o-mini\n", |
| 1091 | + "\n", |
1090 | 1092 | "📋 Task: Code Generation\n", |
1091 | 1093 | " Metrik: Echte Ausführung mit Testdaten!\n", |
1092 | 1094 | "\n", |
1093 | 1095 | "📝 Aufgabe: Write a function that returns the nth Fibonacci number using iteration.\n", |
1094 | 1096 | " Generierter Code:\n", |
1095 | | - " │ def fibonacci(n: int) -> int:\n", |
1096 | | - " │ \"\"\"\n", |
1097 | | - " │ Return the nth Fibonacci number using iteration.\n", |
1098 | | - " │ \n", |
1099 | | - " │ The sequence is defined as:\n", |
1100 | | - " │ F(0) = 0\n", |
1101 | | - " │ F(1) = 1\n", |
1102 | | - " │ F(n) = F(n-1) + F(n-2) for n >= 2\n", |
1103 | | - " │ ... (47 Zeilen)\n", |
| 1097 | + " │ def fibonacci(n):\n", |
| 1098 | + " │ if n <= 0:\n", |
| 1099 | + " │ return 0\n", |
| 1100 | + " │ elif n == 1:\n", |
| 1101 | + " │ return 1\n", |
| 1102 | + " │ \n", |
| 1103 | + " │ a, b = 0, 1\n", |
| 1104 | + " │ for _ in range(2, n + 1):\n", |
| 1105 | + " │ ... (10 Zeilen)\n", |
1104 | 1106 | " ✅ fibonacci(0) → 0\n", |
1105 | 1107 | " ✅ fibonacci(1) → 1\n", |
1106 | 1108 | " ✅ fibonacci(10) → 55\n", |
1107 | 1109 | " ✅ fibonacci(20) → 6765\n", |
1108 | 1110 | "\n", |
1109 | 1111 | "📝 Aufgabe: Write a function that checks if a string is a palindrome, ignoring case and non-\n", |
1110 | 1112 | " Generierter Code:\n", |
1111 | | - " │ def is_palindrome(s: str) -> bool:\n", |
1112 | | - " │ \"\"\"\n", |
1113 | | - " │ Check if the given string is a palindrome, ignoring case and non-alphanumeric characters.\n", |
| 1113 | + " │ import re\n", |
1114 | 1114 | " │ \n", |
1115 | | - " │ Args:\n", |
1116 | | - " │ s (str): The input string to check.\n", |
| 1115 | + " │ def is_palindrome(s: str) -> bool:\n", |
| 1116 | + " │ # Remove non-alphanumeric characters and convert to lower case\n", |
| 1117 | + " │ cleaned_string = re.sub(r'[^a-zA-Z0-9]', '', s).lower()\n", |
| 1118 | + " │ # Check if the cleaned string is the same as its reverse\n", |
| 1119 | + " │ return cleaned_string == cleaned_string[::-1]\n", |
1117 | 1120 | " │ \n", |
1118 | | - " │ Returns:\n", |
1119 | | - " │ ... (28 Zeilen)\n", |
| 1121 | + " │ ... (11 Zeilen)\n", |
1120 | 1122 | " ✅ is_palindrome('racecar') → True\n", |
1121 | 1123 | " ✅ is_palindrome('hello') → False\n", |
1122 | 1124 | " ✅ is_palindrome('A man a plan a canal Panama') → True\n", |
1123 | 1125 | "\n", |
1124 | | - "📝 Aufgabe: Write a function that flattens a nested list of arbitrary depth into a single li\n" |
| 1126 | + "📝 Aufgabe: Write a function that flattens a nested list of arbitrary depth into a single li\n", |
| 1127 | + " Generierter Code:\n", |
| 1128 | + " │ def flatten(nested_list):\n", |
| 1129 | + " │ flat_list = []\n", |
| 1130 | + " │ for element in nested_list:\n", |
| 1131 | + " │ if isinstance(element, list):\n", |
| 1132 | + " │ flat_list.extend(flatten(element)) # Recursively flatten the sublist\n", |
| 1133 | + " │ else:\n", |
| 1134 | + " │ flat_list.append(element) # Add the non-list element to the flat list\n", |
| 1135 | + " │ return flat_list\n", |
| 1136 | + " │ ... (13 Zeilen)\n", |
| 1137 | + "[1, 2, 3, 4, 5, 6, 7, 8]\n", |
| 1138 | + " ✅ flatten([1, [2], 3]) → [1, 2, 3]\n", |
| 1139 | + " ✅ flatten([1, [2, [3, [4]]]]) → [1, 2, 3, 4]\n", |
| 1140 | + "\n", |
| 1141 | + "📝 Aufgabe: Write a function that counts the frequency of each word in a string and returns \n" |
1125 | 1142 | ] |
1126 | 1143 | } |
1127 | 1144 | ], |
1128 | 1145 | "source": [ |
1129 | 1146 | "import re\n", |
1130 | 1147 | "\n", |
| 1148 | + "# Für Code-Generierung testen wir absichtlich ein KLEINERES Modell\n", |
| 1149 | + "# um zu zeigen dass nicht jedes Modell alles kann\n", |
| 1150 | + "SMALL_MODEL = \"github_copilot/gpt-4o-mini\"\n", |
| 1151 | + "configure_dspy(SMALL_MODEL)\n", |
| 1152 | + "print(f\"⚠️ Für diesen Test nutzen wir absichtlich ein kleineres Modell: {SMALL_MODEL}\")\n", |
| 1153 | + "print()\n", |
| 1154 | + "\n", |
1131 | 1155 | "task = get_task(\"code_generation\")\n", |
1132 | 1156 | "print(f\"📋 Task: {task.name}\")\n", |
1133 | 1157 | "print(f\" Metrik: Echte Ausführung mit Testdaten!\")\n", |
|
1265 | 1289 | "print(\" Ob er die RICHTIGEN ERGEBNISSE liefert — das zählt!\")\n", |
1266 | 1290 | "print()\n", |
1267 | 1291 | "print(\" Das ist wie bei Software-Tests:\")\n", |
1268 | | - "print(\" Ein Programm das startet aber falsch rechnet ist wertlos.\")" |
| 1292 | + "print(\" Ein Programm das startet aber falsch rechnet ist wertlos.\")\n", |
| 1293 | + "\n", |
| 1294 | + "# Zurück zum Haupt-Modell für die nächsten Zellen\n", |
| 1295 | + "configure_dspy(MODEL)" |
1269 | 1296 | ] |
1270 | 1297 | }, |
1271 | 1298 | { |
|
0 commit comments