mikeee commited on
Commit
b0003b5
1 Parent(s): ea2980d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -104,11 +104,11 @@ def predict(RETRY_FLAG, input, chatbot, max_length, top_p, temperature, history,
104
 
105
 
106
  def trans_api(input, max_length=4096, top_p=0.8, temperature=0.2):
107
- if max_length < 100:
108
  max_length = 4096
109
- if top_p < 0.1:
110
- top_p = 0.8
111
- if temperature <= 0:
112
  temperature = 0.01
113
  try:
114
  res, _ = model.chat(
@@ -212,7 +212,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
212
  with gr.Column(scale=1):
213
  emptyBtn = gr.Button("Clear History")
214
  max_length = gr.Slider(0, 32768, value=8192/2, step=1.0, label="Maximum length", interactive=True)
215
- top_p = gr.Slider(0, 1, value=0.8, step=0.01, label="Top P", interactive=True)
216
  temperature = gr.Slider(0.01, 1, value=0.95, step=0.01, label="Temperature", interactive=True)
217
 
218
  history = gr.State([])
@@ -238,25 +238,26 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
238
  etext = """In America, where cars are an important part of the national psyche, a decade ago people had suddenly started to drive less, which had not happened since the oil shocks of the 1970s. """
239
  examples = gr.Examples(
240
  examples=[
241
- ["Explain the plot of Cinderella in a sentence."],
242
- ["How long does it take to become proficient in French, and what are the best methods for retaining information?"],
243
- ["What are some common mistakes to avoid when writing code?"],
244
- ["Build a prompt to generate a beautiful portrait of a horse"],
245
- ["Suggest four metaphors to describe the benefits of AI"],
246
- ["Write a pop song about leaving home for the sandy beaches."],
247
- ["Write a summary demonstrating my ability to tame lions"],
248
- ["鲁迅和周树人什么关系"],
249
- ["从前有一头牛,这头牛后面有什么?"],
250
- ["正无穷大加一大于正无穷大吗?"],
251
- ["-2的平方根等于什么"],
252
- ["树上有5只鸟,猎人开枪打死了一只。树上还有几只鸟?"],
253
- ["树上有11只鸟,猎人开枪打死了一只。树上还有几只鸟?提示:需考虑鸟可能受惊吓飞走。"],
254
- ["鲁迅和周树人什么关系 用英文回答"],
255
- ["以红楼梦的行文风格写一张委婉的请假条。不得少于120字。"],
256
- [f"{etext} 翻成中文,列出3个版本"],
257
- ["js 判断一个数是不是质数"],
258
- ["js 实现python 的 range(10)"],
259
- ["js 实现python 的 [*(range(10)]"],
 
260
  ],
261
  inputs = [user_input],
262
  )
 
104
 
105
 
106
  def trans_api(input, max_length=4096, top_p=0.8, temperature=0.2):
107
+ if max_length < 10:
108
  max_length = 4096
109
+ if top_p < 0.1 or top_p > 1:
110
+ top_p = 0.85
111
+ if temperature <= 0 or temperature > 1:
112
  temperature = 0.01
113
  try:
114
  res, _ = model.chat(
 
212
  with gr.Column(scale=1):
213
  emptyBtn = gr.Button("Clear History")
214
  max_length = gr.Slider(0, 32768, value=8192/2, step=1.0, label="Maximum length", interactive=True)
215
+ top_p = gr.Slider(0, 1, value=0.85, step=0.01, label="Top P", interactive=True)
216
  temperature = gr.Slider(0.01, 1, value=0.95, step=0.01, label="Temperature", interactive=True)
217
 
218
  history = gr.State([])
 
238
  etext = """In America, where cars are an important part of the national psyche, a decade ago people had suddenly started to drive less, which had not happened since the oil shocks of the 1970s. """
239
  examples = gr.Examples(
240
  examples=[
241
+ ["Explain the plot of Cinderella in a sentence."],
242
+ ["How long does it take to become proficient in French, and what are the best methods for retaining information?"],
243
+ ["What are some common mistakes to avoid when writing code?"],
244
+ ["Build a prompt to generate a beautiful portrait of a horse"],
245
+ ["Suggest four metaphors to describe the benefits of AI"],
246
+ ["Write a pop song about leaving home for the sandy beaches."],
247
+ ["Write a summary demonstrating my ability to tame lions"],
248
+ ["鲁迅和周树人什么关系"],
249
+ ["从前有一头牛,这头牛后面有什么?"],
250
+ ["正无穷大加一大于正无穷大吗?"],
251
+ ["-2的平方根等于什么"],
252
+ ["树上有5只鸟,猎人开枪打死了一只。树上还有几只鸟?"],
253
+ ["树上有11只鸟,猎人开枪打死了一只。树上还有几只鸟?提示:需考虑鸟可能受惊吓飞走。"],
254
+ ["鲁迅和周树人什么关系 用英文回答"],
255
+ ["以红楼梦的行文风格写一张委婉的请假条。不得少于120字。"],
256
+ [f"{etext} 翻成中文,列出3个版本"],
257
+ ["js 判断一个数是不是质数"],
258
+ ["js 实现python 的 range(10)"],
259
+ ["js 实现python 的 [*(range(10)]"],
260
+ ["假定 1 + 2 = 4, 试求 7 + 8"],
261
  ],
262
  inputs = [user_input],
263
  )