Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,40 +114,35 @@ def convert_text_style(input_text):
|
|
| 114 |
except Exception as e:
|
| 115 |
return f"生成过程中出现错误: {str(e)}"
|
| 116 |
|
| 117 |
-
# 创建Gradio接口
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
)
|
| 139 |
-
|
| 140 |
-
return iface
|
| 141 |
|
| 142 |
-
# 启动应用
|
| 143 |
if __name__ == "__main__":
|
| 144 |
print("正在启动应用...")
|
| 145 |
-
iface = create_interface()
|
| 146 |
iface.launch(
|
| 147 |
server_name="0.0.0.0",
|
| 148 |
server_port=7860,
|
| 149 |
share=False,
|
| 150 |
-
debug=False
|
| 151 |
-
enable_queue
|
| 152 |
-
max_threads=1 # 限制线程数
|
| 153 |
)
|
|
|
|
| 114 |
except Exception as e:
|
| 115 |
return f"生成过程中出现错误: {str(e)}"
|
| 116 |
|
| 117 |
+
# 创建Gradio接口 - 修复版本兼容性问题
|
| 118 |
+
iface = gr.Interface(
|
| 119 |
+
fn=convert_text_style,
|
| 120 |
+
inputs=gr.Textbox(
|
| 121 |
+
label="输入文本",
|
| 122 |
+
placeholder="请输入需要转换为口语化的书面文本...",
|
| 123 |
+
lines=3
|
| 124 |
+
),
|
| 125 |
+
outputs=gr.Textbox(
|
| 126 |
+
label="输出文本",
|
| 127 |
+
lines=3
|
| 128 |
+
),
|
| 129 |
+
title="中文文本风格转换API",
|
| 130 |
+
description="将书面化、技术性文本转换为自然、口语化表达",
|
| 131 |
+
examples=[
|
| 132 |
+
["乙醇的检测方法包括酸碱度检查。"],
|
| 133 |
+
["本品为薄膜衣片,除去包衣后显橙红色。"]
|
| 134 |
+
],
|
| 135 |
+
cache_examples=False, # 不缓存示例
|
| 136 |
+
flagging_mode="never" # 修复:使用flagging_mode替代allow_flagging
|
| 137 |
+
)
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
+
# 启动应用 - 移除不兼容的参数
|
| 140 |
if __name__ == "__main__":
|
| 141 |
print("正在启动应用...")
|
|
|
|
| 142 |
iface.launch(
|
| 143 |
server_name="0.0.0.0",
|
| 144 |
server_port=7860,
|
| 145 |
share=False,
|
| 146 |
+
debug=False
|
| 147 |
+
# 移除了enable_queue和max_threads参数
|
|
|
|
| 148 |
)
|