yxccai commited on
Commit
ae39785
·
verified ·
1 Parent(s): ec9daa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -29
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
- def create_interface():
119
- iface = gr.Interface(
120
- fn=convert_text_style,
121
- inputs=gr.Textbox(
122
- label="输入文本",
123
- placeholder="请输入需要转换为口语化的书面文本...",
124
- lines=3
125
- ),
126
- outputs=gr.Textbox(
127
- label="输出文本",
128
- lines=3
129
- ),
130
- title="中文文本风格转换API",
131
- description="将书面化、技术性文本转换为自然、口语化表达",
132
- examples=[
133
- ["乙醇的检测方法包括酸碱度检查。"],
134
- ["本品为薄膜衣片,除去包衣后显橙红色。"]
135
- ],
136
- cache_examples=False, # 不缓存示例
137
- allow_flagging="never" # 禁用标记功能
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=True,
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
  )