test2023h5 commited on
Commit
22268b4
·
verified ·
1 Parent(s): df23b68

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -6
main.py CHANGED
@@ -56,7 +56,6 @@ def generate_response(task, text):
56
  return generated_texts[0].split('\n')[0]
57
 
58
  def predict(text, method):
59
- return "hi"
60
  '''
61
  # Example usage
62
  prompt = ["Translate to French", "Hello, how are you?"]
@@ -74,7 +73,6 @@ def predict(text, method):
74
  prompt = ["翻译成古文", "好久不见了,近来可好啊"]
75
  '''
76
 
77
- print("debug1", method)
78
  if method == 0:
79
  prompt = ["翻译成现代文", text]
80
  base_model.set_adapter("adapter1")
@@ -85,8 +83,6 @@ def predict(text, method):
85
 
86
  response = generate_response(prompt[0], prompt[1])
87
 
88
- print("debug2", response)
89
-
90
  #ss.session["result"] = response
91
  return response
92
  #comment(score)
@@ -111,10 +107,10 @@ async def say_hello():
111
  async def process_text(request: ProcessRequest):
112
  if request.method == "0":
113
  #processed_text = request.text.upper()
114
- processed_text = "predict(request.text, 0)"
115
  elif request.method == "1":
116
  #processed_text = request.text.lower()
117
- processed_text = "predict(request.text, 1)"
118
  elif request.method == "2":
119
  processed_text = "request.text[::-1]" # 反转字符串
120
  else:
 
56
  return generated_texts[0].split('\n')[0]
57
 
58
  def predict(text, method):
 
59
  '''
60
  # Example usage
61
  prompt = ["Translate to French", "Hello, how are you?"]
 
73
  prompt = ["翻译成古文", "好久不见了,近来可好啊"]
74
  '''
75
 
 
76
  if method == 0:
77
  prompt = ["翻译成现代文", text]
78
  base_model.set_adapter("adapter1")
 
83
 
84
  response = generate_response(prompt[0], prompt[1])
85
 
 
 
86
  #ss.session["result"] = response
87
  return response
88
  #comment(score)
 
107
  async def process_text(request: ProcessRequest):
108
  if request.method == "0":
109
  #processed_text = request.text.upper()
110
+ processed_text = predict(request.text, 0)
111
  elif request.method == "1":
112
  #processed_text = request.text.lower()
113
+ processed_text = predict(request.text, 1)
114
  elif request.method == "2":
115
  processed_text = "request.text[::-1]" # 反转字符串
116
  else: