Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
|
|
|
| 3 |
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
|
@@ -15,29 +16,37 @@ def respond(
|
|
| 15 |
temperature,
|
| 16 |
top_p,
|
| 17 |
):
|
| 18 |
-
messages = [{"role": "system", "content": system_message}]
|
| 19 |
|
| 20 |
-
for val in history:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
messages.append({"role": "user", "content": message})
|
| 27 |
|
| 28 |
-
response = ""
|
| 29 |
|
| 30 |
-
for message in client.chat_completion(
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
):
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
"""
|
| 43 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
+
from naive_chatbot import NaiveChatbot
|
| 4 |
|
| 5 |
"""
|
| 6 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
|
|
|
| 16 |
temperature,
|
| 17 |
top_p,
|
| 18 |
):
|
| 19 |
+
# messages = [{"role": "system", "content": system_message}]
|
| 20 |
|
| 21 |
+
# for val in history:
|
| 22 |
+
# if val[0]:
|
| 23 |
+
# messages.append({"role": "user", "content": val[0]})
|
| 24 |
+
# if val[1]:
|
| 25 |
+
# messages.append({"role": "assistant", "content": val[1]})
|
| 26 |
|
| 27 |
+
# messages.append({"role": "user", "content": message})
|
| 28 |
|
| 29 |
+
# response = ""
|
| 30 |
|
| 31 |
+
# for message in client.chat_completion(
|
| 32 |
+
# messages,
|
| 33 |
+
# max_tokens=max_tokens,
|
| 34 |
+
# stream=True,
|
| 35 |
+
# temperature=temperature,
|
| 36 |
+
# top_p=top_p,
|
| 37 |
+
# ):
|
| 38 |
+
# token = message.choices[0].delta.content
|
| 39 |
|
| 40 |
+
# response += token
|
| 41 |
+
my_bot = NaiveChatbot(pretrained=True,
|
| 42 |
+
query_tokenizer_path="utils/query_tokenizer.pickle",
|
| 43 |
+
intent_tokenizer_path="utils/intent_tokenizer.pickle",
|
| 44 |
+
model_weights_path="utils/checkpoint.ckpt",
|
| 45 |
+
db_responses2text_path="utils/db_responses2text.pickle",
|
| 46 |
+
db_intent2response_path="utils/db_intent2response.pickle",
|
| 47 |
+
db_transliteration_path="utils/db_ar2safebw.pickle")
|
| 48 |
+
response = my_bot.get_reply(user_input, 0.97)
|
| 49 |
+
yield response
|
| 50 |
|
| 51 |
"""
|
| 52 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|