adding datasets
Browse files
app.py
CHANGED
@@ -1,13 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
"""
|
7 |
-
|
|
|
|
|
|
|
8 |
|
|
|
|
|
|
|
9 |
|
|
|
|
|
10 |
|
|
|
11 |
def respond(
|
12 |
message,
|
13 |
history: list[tuple[str, str]],
|
@@ -28,22 +38,19 @@ def respond(
|
|
28 |
|
29 |
response = ""
|
30 |
|
31 |
-
for message in client.
|
32 |
messages,
|
33 |
max_tokens=max_tokens,
|
34 |
stream=True,
|
35 |
temperature=temperature,
|
36 |
top_p=top_p,
|
37 |
):
|
38 |
-
token = message
|
39 |
-
|
40 |
response += token
|
41 |
yield response
|
42 |
|
43 |
|
44 |
-
|
45 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
46 |
-
"""
|
47 |
demo = gr.ChatInterface(
|
48 |
respond,
|
49 |
additional_inputs=[
|
@@ -60,6 +67,6 @@ demo = gr.ChatInterface(
|
|
60 |
],
|
61 |
)
|
62 |
|
63 |
-
|
64 |
if __name__ == "__main__":
|
65 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
from datasets import load_dataset
|
4 |
|
5 |
+
# β
Load the datasets
|
6 |
+
datasets = {
|
7 |
+
"sales": load_dataset("goendalf666/sales-conversations"),
|
8 |
+
"blended": load_dataset("blended_skill_talk"),
|
9 |
+
"dialog": load_dataset("daily_dialog"),
|
10 |
+
"multiwoz": load_dataset("multi_woz_v22"),
|
11 |
+
}
|
12 |
|
13 |
+
# Optional: Print dataset names and sizes
|
14 |
+
for name, dataset in datasets.items():
|
15 |
+
print(f"{name}: {len(dataset['train'])} examples")
|
16 |
|
17 |
+
# Initialize the model client (use correct model for chatbot)
|
18 |
+
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
19 |
|
20 |
+
# Chatbot response function
|
21 |
def respond(
|
22 |
message,
|
23 |
history: list[tuple[str, str]],
|
|
|
38 |
|
39 |
response = ""
|
40 |
|
41 |
+
for message in client.chat_completions(
|
42 |
messages,
|
43 |
max_tokens=max_tokens,
|
44 |
stream=True,
|
45 |
temperature=temperature,
|
46 |
top_p=top_p,
|
47 |
):
|
48 |
+
token = message["choices"][0]["delta"]["content"]
|
|
|
49 |
response += token
|
50 |
yield response
|
51 |
|
52 |
|
53 |
+
# Gradio interface for chatbot
|
|
|
|
|
54 |
demo = gr.ChatInterface(
|
55 |
respond,
|
56 |
additional_inputs=[
|
|
|
67 |
],
|
68 |
)
|
69 |
|
70 |
+
# Launch Gradio app
|
71 |
if __name__ == "__main__":
|
72 |
demo.launch()
|