Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
# Load knowledge base from a .txt file
|
| 5 |
-
def load_knowledge_base(file_path):
|
| 6 |
-
with open(file_path, "r") as file:
|
| 7 |
-
return file.read()
|
| 8 |
-
|
| 9 |
-
knowledge_base = load_knowledge_base("manufacturing_info.txt")
|
| 10 |
-
|
| 11 |
"""
|
| 12 |
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
|
| 13 |
"""
|
|
@@ -22,15 +15,7 @@ def respond(
|
|
| 22 |
temperature,
|
| 23 |
top_p,
|
| 24 |
):
|
| 25 |
-
|
| 26 |
-
system_message_with_knowledge = (
|
| 27 |
-
system_message
|
| 28 |
-
+ "\n\nKnowledge Base:\n"
|
| 29 |
-
+ knowledge_base
|
| 30 |
-
+ "\n\nRespond to the user's queries based on this knowledge."
|
| 31 |
-
)
|
| 32 |
-
|
| 33 |
-
messages = [{"role": "system", "content": system_message_with_knowledge}]
|
| 34 |
|
| 35 |
for val in history:
|
| 36 |
if val[0]:
|
|
@@ -63,8 +48,16 @@ demo = gr.ChatInterface(
|
|
| 63 |
additional_inputs=[
|
| 64 |
gr.Textbox(
|
| 65 |
value=(
|
| 66 |
-
"You are an expert chatbot for additive manufacturing. "
|
| 67 |
-
"Assist users with all their 3D printing needs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
),
|
| 69 |
label="System message",
|
| 70 |
),
|
|
|
|
| 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
|
| 6 |
"""
|
|
|
|
| 15 |
temperature,
|
| 16 |
top_p,
|
| 17 |
):
|
| 18 |
+
messages = [{"role": "system", "content": system_message}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
for val in history:
|
| 21 |
if val[0]:
|
|
|
|
| 48 |
additional_inputs=[
|
| 49 |
gr.Textbox(
|
| 50 |
value=(
|
| 51 |
+
"You are AddiBot, an expert chatbot for additive manufacturing. "
|
| 52 |
+
"Assist users with all their 3D printing needs, whether they're beginners or professionals. "
|
| 53 |
+
"Here’s what you can do:\n"
|
| 54 |
+
"- Explain additive manufacturing concepts such as FDM, SLA, SLS, and DMLS.\n"
|
| 55 |
+
"- Provide guidance on materials like PLA, ABS, PETG, resins, and metal powders.\n"
|
| 56 |
+
"- Troubleshoot common issues like warping, nozzle clogs, and adhesion problems.\n"
|
| 57 |
+
"- Share best practices for improving print quality, reducing waste, and optimizing settings.\n"
|
| 58 |
+
"- Discuss advanced topics, including multi-material printing, industrial applications, and recent innovations.\n"
|
| 59 |
+
"- Suggest software tools for slicing, modeling, and simulation.\n\n"
|
| 60 |
+
"Make your responses clear, concise, and engaging, tailored to the user's level of expertise."
|
| 61 |
),
|
| 62 |
label="System message",
|
| 63 |
),
|