Browse Source

fix: input prompt message

Timothy J. Baek 11 tháng trước cách đây
mục cha
commit
c7221983a5
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      src/lib/components/chat/Messages/CodeBlock.svelte

+ 6 - 1
src/lib/components/chat/Messages/CodeBlock.svelte

@@ -170,7 +170,7 @@
 			const res = await pyodide.loadPackage('micropip');
 			console.log(res);
 
-			pyodide.setStdin({ stdin: () => prompt() });
+			// pyodide.setStdin({ stdin: () => prompt() });
 
 			const micropip = pyodide.pyimport('micropip');
 
@@ -186,6 +186,11 @@
 			console.log(packages);
 			await micropip.install(packages);
 
+			result = pyodide.runPython(`from js import prompt
+def input(p):
+    return prompt(p)
+__builtins__.input = input`);
+
 			result = pyodide.runPython(code);
 
 			if (!result) {