Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
72 |
-
|
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 |
-
|
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__':
|