Spaces:
Running
Running
up
Browse files
crazy_functions/数学动画生成manim.py
CHANGED
@@ -25,14 +25,14 @@ def eval_manim(code):
|
|
25 |
def get_class_name(class_string):
|
26 |
import re
|
27 |
# Use regex to extract the class name
|
28 |
-
class_name = re.search(r'class (\w+)\(
|
29 |
return class_name
|
30 |
|
31 |
class_name = get_class_name(code)
|
32 |
|
33 |
try:
|
34 |
subprocess.check_output([sys.executable, '-c', f"from gpt_log.MyAnimation import {class_name}; {class_name}().render()"])
|
35 |
-
shutil.
|
36 |
return f'gpt_log/{gen_time_str()}.mp4'
|
37 |
except subprocess.CalledProcessError as e:
|
38 |
output = e.output.decode()
|
@@ -68,7 +68,7 @@ def 动画生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
|
|
68 |
# 基本信息:功能、贡献者
|
69 |
chatbot.append([
|
70 |
"函数插件功能?",
|
71 |
-
"生成数学动画, 作者: binary-husky, 插件初始化中 ..."
|
72 |
])
|
73 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
74 |
|
|
|
25 |
def get_class_name(class_string):
|
26 |
import re
|
27 |
# Use regex to extract the class name
|
28 |
+
class_name = re.search(r'class (\w+)\(', class_string).group(1)
|
29 |
return class_name
|
30 |
|
31 |
class_name = get_class_name(code)
|
32 |
|
33 |
try:
|
34 |
subprocess.check_output([sys.executable, '-c', f"from gpt_log.MyAnimation import {class_name}; {class_name}().render()"])
|
35 |
+
shutil.move('media/videos/1080p60/{class_name}.mp4', f'gpt_log/{class_name}-{gen_time_str()}.mp4')
|
36 |
return f'gpt_log/{gen_time_str()}.mp4'
|
37 |
except subprocess.CalledProcessError as e:
|
38 |
output = e.output.decode()
|
|
|
68 |
# 基本信息:功能、贡献者
|
69 |
chatbot.append([
|
70 |
"函数插件功能?",
|
71 |
+
"生成数学动画, 此插件处于开发阶段, 建议暂时不要使用, 作者: binary-husky, 插件初始化中 ..."
|
72 |
])
|
73 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
74 |
|