Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,20 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
| 6 |
"""
|
| 7 |
client = InferenceClient("kronos25/Temporal_Chatbot")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def predict(message, history):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
gr.ChatInterface(
|
| 16 |
predict,
|
|
|
|
| 6 |
"""
|
| 7 |
client = InferenceClient("kronos25/Temporal_Chatbot")
|
| 8 |
|
| 9 |
+
# def predict(message, history):
|
| 10 |
+
# for message in client.chat_completion(history,max_tokens=512):
|
| 11 |
+
# token = message.choices[0].delta.content
|
| 12 |
+
# response += token
|
| 13 |
+
# yield response
|
| 14 |
+
|
| 15 |
def predict(message, history):
|
| 16 |
+
model = T5ForConditionalGeneration.from_pretrained('kronos25/Temporal_Chatbot')
|
| 17 |
+
tokenizer = T5Tokenizer.from_pretrained('kronos25/Temporal_Chatbot')
|
| 18 |
+
input = message + '\n'
|
| 19 |
+
inputs = tokenizer(input, return_tensors="pt")
|
| 20 |
+
outputs = model.generate(**inputs,max_length=100)
|
| 21 |
+
model_result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 22 |
+
return model_result + '\n'
|
| 23 |
|
| 24 |
gr.ChatInterface(
|
| 25 |
predict,
|