Spaces:
Runtime error
Runtime error
Update apps to work out of the box (#49)
Browse files- buster/apps/gradio_app.ipynb +23 -13
- buster/apps/slackbot.py +4 -4
- buster/chatbot.py +3 -3
buster/apps/gradio_app.ipynb
CHANGED
@@ -4,7 +4,9 @@
|
|
4 |
"cell_type": "code",
|
5 |
"execution_count": null,
|
6 |
"id": "4a6b2b70",
|
7 |
-
"metadata": {
|
|
|
|
|
8 |
"outputs": [],
|
9 |
"source": [
|
10 |
"import gradio as gr\n",
|
@@ -17,7 +19,7 @@
|
|
17 |
" embedding_model=\"text-embedding-ada-002\",\n",
|
18 |
" top_k=3,\n",
|
19 |
" thresh=0.7,\n",
|
20 |
-
"
|
21 |
" completion_kwargs={\n",
|
22 |
" \"engine\": \"text-davinci-003\",\n",
|
23 |
" \"max_tokens\": 500,\n",
|
@@ -26,30 +28,33 @@
|
|
26 |
" link_format=\"markdown\",\n",
|
27 |
" text_after_response=\"I'm a bot 🤖 trained to answer huggingface 🤗 transformers questions. My answers aren't always perfect.\",\n",
|
28 |
" text_before_prompt=\"\"\"You are a slack chatbot assistant answering technical questions about huggingface transformers, a library to train transformers in python.\n",
|
29 |
-
"
|
30 |
-
"
|
31 |
"\n",
|
32 |
-
"
|
33 |
"\n",
|
34 |
-
"
|
35 |
"\n",
|
36 |
-
"
|
37 |
"\n",
|
38 |
-
"
|
39 |
"\n",
|
40 |
-
"
|
41 |
"\n",
|
42 |
-
"
|
43 |
-
"
|
44 |
")\n",
|
45 |
"hf_transformers_chatbot = Chatbot(hf_transformers_cfg)\n",
|
46 |
"\n",
|
47 |
"def chat(question, history):\n",
|
48 |
" history = history or []\n",
|
|
|
49 |
" answer = hf_transformers_chatbot.process_input(question)\n",
|
|
|
|
|
|
|
50 |
"\n",
|
51 |
" history.append((question, answer))\n",
|
52 |
-
" print(history)\n",
|
53 |
" return history, history\n",
|
54 |
"\n",
|
55 |
"\n",
|
@@ -104,7 +109,7 @@
|
|
104 |
],
|
105 |
"metadata": {
|
106 |
"kernelspec": {
|
107 |
-
"display_name": "
|
108 |
"language": "python",
|
109 |
"name": "python3"
|
110 |
},
|
@@ -119,6 +124,11 @@
|
|
119 |
"nbconvert_exporter": "python",
|
120 |
"pygments_lexer": "ipython3",
|
121 |
"version": "3.9.12"
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
},
|
124 |
"nbformat": 4,
|
|
|
4 |
"cell_type": "code",
|
5 |
"execution_count": null,
|
6 |
"id": "4a6b2b70",
|
7 |
+
"metadata": {
|
8 |
+
"scrolled": true
|
9 |
+
},
|
10 |
"outputs": [],
|
11 |
"source": [
|
12 |
"import gradio as gr\n",
|
|
|
19 |
" embedding_model=\"text-embedding-ada-002\",\n",
|
20 |
" top_k=3,\n",
|
21 |
" thresh=0.7,\n",
|
22 |
+
" max_words=3000,\n",
|
23 |
" completion_kwargs={\n",
|
24 |
" \"engine\": \"text-davinci-003\",\n",
|
25 |
" \"max_tokens\": 500,\n",
|
|
|
28 |
" link_format=\"markdown\",\n",
|
29 |
" text_after_response=\"I'm a bot 🤖 trained to answer huggingface 🤗 transformers questions. My answers aren't always perfect.\",\n",
|
30 |
" text_before_prompt=\"\"\"You are a slack chatbot assistant answering technical questions about huggingface transformers, a library to train transformers in python.\n",
|
31 |
+
"Make sure to format your answers in Markdown format, including code block and snippets.\n",
|
32 |
+
"Do not include any links to urls or hyperlinks in your answers.\n",
|
33 |
"\n",
|
34 |
+
"If you do not know the answer to a question, or if it is completely irrelevant to the library usage, simply reply with:\n",
|
35 |
"\n",
|
36 |
+
"'This doesn't seem to be related to the huggingface library.'\n",
|
37 |
"\n",
|
38 |
+
"For example:\n",
|
39 |
"\n",
|
40 |
+
"What is the meaning of life for huggingface?\n",
|
41 |
"\n",
|
42 |
+
"This doesn't seem to be related to the huggingface library.\n",
|
43 |
"\n",
|
44 |
+
"Now answer the following question:\n",
|
45 |
+
"\"\"\",\n",
|
46 |
")\n",
|
47 |
"hf_transformers_chatbot = Chatbot(hf_transformers_cfg)\n",
|
48 |
"\n",
|
49 |
"def chat(question, history):\n",
|
50 |
" history = history or []\n",
|
51 |
+
" \n",
|
52 |
" answer = hf_transformers_chatbot.process_input(question)\n",
|
53 |
+
" \n",
|
54 |
+
" # formatting hack for code blocks to render properly every time\n",
|
55 |
+
" answer = answer.replace(\"```\", \"\\n```\\n\")\n",
|
56 |
"\n",
|
57 |
" history.append((question, answer))\n",
|
|
|
58 |
" return history, history\n",
|
59 |
"\n",
|
60 |
"\n",
|
|
|
109 |
],
|
110 |
"metadata": {
|
111 |
"kernelspec": {
|
112 |
+
"display_name": "base",
|
113 |
"language": "python",
|
114 |
"name": "python3"
|
115 |
},
|
|
|
124 |
"nbconvert_exporter": "python",
|
125 |
"pygments_lexer": "ipython3",
|
126 |
"version": "3.9.12"
|
127 |
+
},
|
128 |
+
"vscode": {
|
129 |
+
"interpreter": {
|
130 |
+
"hash": "5abee959af829406add33dbeab4b81a0c8afd11a2faef151b217e9aebad2d8c1"
|
131 |
+
}
|
132 |
}
|
133 |
},
|
134 |
"nbformat": 4,
|
buster/apps/slackbot.py
CHANGED
@@ -20,7 +20,7 @@ mila_doc_cfg = ChatbotConfig(
|
|
20 |
embedding_model="text-embedding-ada-002",
|
21 |
top_k=3,
|
22 |
thresh=0.7,
|
23 |
-
|
24 |
completion_kwargs={
|
25 |
"engine": "text-davinci-003",
|
26 |
"max_tokens": 200,
|
@@ -56,7 +56,7 @@ orion_cfg = ChatbotConfig(
|
|
56 |
embedding_model="text-embedding-ada-002",
|
57 |
top_k=3,
|
58 |
thresh=0.7,
|
59 |
-
|
60 |
completion_kwargs={
|
61 |
"engine": "text-davinci-003",
|
62 |
"max_tokens": 200,
|
@@ -89,7 +89,7 @@ pytorch_cfg = ChatbotConfig(
|
|
89 |
embedding_model="text-embedding-ada-002",
|
90 |
top_k=3,
|
91 |
thresh=0.7,
|
92 |
-
|
93 |
completion_kwargs={
|
94 |
"engine": "text-davinci-003",
|
95 |
"max_tokens": 500,
|
@@ -122,7 +122,7 @@ hf_transformers_cfg = ChatbotConfig(
|
|
122 |
embedding_model="text-embedding-ada-002",
|
123 |
top_k=3,
|
124 |
thresh=0.7,
|
125 |
-
|
126 |
completion_kwargs={
|
127 |
"engine": "text-davinci-003",
|
128 |
"max_tokens": 500,
|
|
|
20 |
embedding_model="text-embedding-ada-002",
|
21 |
top_k=3,
|
22 |
thresh=0.7,
|
23 |
+
max_words=3000,
|
24 |
completion_kwargs={
|
25 |
"engine": "text-davinci-003",
|
26 |
"max_tokens": 200,
|
|
|
56 |
embedding_model="text-embedding-ada-002",
|
57 |
top_k=3,
|
58 |
thresh=0.7,
|
59 |
+
max_words=3000,
|
60 |
completion_kwargs={
|
61 |
"engine": "text-davinci-003",
|
62 |
"max_tokens": 200,
|
|
|
89 |
embedding_model="text-embedding-ada-002",
|
90 |
top_k=3,
|
91 |
thresh=0.7,
|
92 |
+
max_words=3000,
|
93 |
completion_kwargs={
|
94 |
"engine": "text-davinci-003",
|
95 |
"max_tokens": 500,
|
|
|
122 |
embedding_model="text-embedding-ada-002",
|
123 |
top_k=3,
|
124 |
thresh=0.7,
|
125 |
+
max_words=3000,
|
126 |
completion_kwargs={
|
127 |
"engine": "text-davinci-003",
|
128 |
"max_tokens": 500,
|
buster/chatbot.py
CHANGED
@@ -61,9 +61,9 @@ class ChatbotConfig:
|
|
61 |
separator: str = "\n"
|
62 |
link_format: str = "slack"
|
63 |
unknown_prompt: str = "I Don't know how to answer your question."
|
64 |
-
text_before_documents: str =
|
65 |
-
text_before_prompt: str = "
|
66 |
-
text_after_response: str = "
|
67 |
|
68 |
|
69 |
class Chatbot:
|
|
|
61 |
separator: str = "\n"
|
62 |
link_format: str = "slack"
|
63 |
unknown_prompt: str = "I Don't know how to answer your question."
|
64 |
+
text_before_documents: str = "You are a chatbot answering questions.\n"
|
65 |
+
text_before_prompt: str = "Answer the following question:\n"
|
66 |
+
text_after_response: str = "I'm a chatbot, bleep bloop."
|
67 |
|
68 |
|
69 |
class Chatbot:
|