feng2022 commited on
Commit
c37dd70
1 Parent(s): 3557c00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -24
app.py CHANGED
@@ -2,7 +2,6 @@
2
 
3
  from __future__ import annotations
4
 
5
- import random
6
  import argparse
7
  import functools
8
  import os
@@ -68,22 +67,8 @@ def load_model(file_name: str, path:str,device: torch.device) -> nn.Module:
68
  model(z, label, force_fp32=True)
69
  return model
70
 
71
- def predict(text):
72
- return pipe(text)[0]["translation_text"]
73
-
74
- def chat(message, history):
75
- history = history or []
76
- message = message.lower()
77
- if message.startswith("how many"):
78
- response = random.randint(1, 10)
79
- elif message.startswith("how"):
80
- response = random.choice(["Great", "Good", "Okay", "Bad"])
81
- elif message.startswith("where"):
82
- response = random.choice(["Here", "There", "Somewhere"])
83
- else:
84
- response = "I don't know"
85
- history.append((message, response))
86
- return history, history
87
 
88
 
89
  def main():
@@ -128,13 +113,7 @@ def main():
128
  #server_port=args.port,
129
  #share=args.share,
130
  #)
131
- chatbot = gr.Chatbot().style(color_map=("green", "pink"))
132
- demo = gr.Interface(
133
- chat,
134
- ["text", "state"],
135
- [chatbot, "state"],
136
- allow_flagging="never",
137
- )
138
  demo.launch()
139
 
140
  if __name__ == '__main__':
 
2
 
3
  from __future__ import annotations
4
 
 
5
  import argparse
6
  import functools
7
  import os
 
67
  model(z, label, force_fp32=True)
68
  return model
69
 
70
+ def greet(name):
71
+ return "Hello " + name + "!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
 
74
  def main():
 
113
  #server_port=args.port,
114
  #share=args.share,
115
  #)
116
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
117
  demo.launch()
118
 
119
  if __name__ == '__main__':