Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,24 +15,6 @@ GREETING = (
|
|
| 15 |
"What can I tell you about today?"
|
| 16 |
)
|
| 17 |
|
| 18 |
-
# Example queries
|
| 19 |
-
EXAMPLE_QUERIES = [
|
| 20 |
-
"What is multi-material 3D printing?",
|
| 21 |
-
"How is additive manufacturing being applied in aerospace?",
|
| 22 |
-
"Tell me about innovations in metal 3D printing techniques.",
|
| 23 |
-
"What are some sustainable materials for 3D printing?",
|
| 24 |
-
"What are the biggest challenges with support structures in additive manufacturing?",
|
| 25 |
-
"How is 3D printing impacting the medical field?",
|
| 26 |
-
"What are some common applications of additive manufacturing in industry?",
|
| 27 |
-
"What are the benefits and limitations of using polymers in 3D printing?",
|
| 28 |
-
"Are there recent breakthroughs in enhancing precision for additive manufacturing?",
|
| 29 |
-
"Tell me about the environmental impacts of additive manufacturing.",
|
| 30 |
-
"What are the primary limitations of current 3D printing technologies?",
|
| 31 |
-
"What future trends are expected in the field of additive manufacturing?",
|
| 32 |
-
"How are researchers improving the speed of 3D printing processes?",
|
| 33 |
-
"What are the best practices for managing post-processing in additive manufacturing?",
|
| 34 |
-
]
|
| 35 |
-
|
| 36 |
# The embedding model name
|
| 37 |
EMBEDDING_MODEL_NAME = "all-MiniLM-L12-v2"
|
| 38 |
|
|
@@ -108,7 +90,9 @@ def preprocess(query: str, k: int) -> tuple[str, str]:
|
|
| 108 |
)
|
| 109 |
|
| 110 |
prompt = (
|
| 111 |
-
"You are an AI assistant who delights in helping people learn about research
|
|
|
|
|
|
|
| 112 |
"Your main task is to use the RESEARCH_EXCERPTS to provide a concise ANSWER to the USER_QUERY. "
|
| 113 |
"DO NOT list references at the end of the answer.\n\n"
|
| 114 |
"===== RESEARCH_EXCERPTS =====:\n{{EXCERPTS_GO_HERE}}\n\n"
|
|
@@ -164,16 +148,12 @@ def reply(message: str, history: list[str]) -> str:
|
|
| 164 |
for new_token in streamer:
|
| 165 |
if new_token != "<":
|
| 166 |
partial_message += new_token
|
| 167 |
-
time.sleep(0.01)
|
| 168 |
yield partial_message
|
| 169 |
|
| 170 |
-
yield partial_message + "\n\n" + bypass
|
| 171 |
-
|
| 172 |
|
| 173 |
# Create and run the gradio interface
|
| 174 |
gradio.ChatInterface(
|
| 175 |
reply,
|
| 176 |
-
examples=EXAMPLE_QUERIES,
|
| 177 |
chatbot=gradio.Chatbot(
|
| 178 |
show_label=False,
|
| 179 |
show_share_button=False,
|
|
|
|
| 15 |
"What can I tell you about today?"
|
| 16 |
)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# The embedding model name
|
| 19 |
EMBEDDING_MODEL_NAME = "all-MiniLM-L12-v2"
|
| 20 |
|
|
|
|
| 90 |
)
|
| 91 |
|
| 92 |
prompt = (
|
| 93 |
+
"You are an AI assistant who delights in helping people learn about research. "
|
| 94 |
+
"Do your best to answer the following question about additive manufacturing research. "
|
| 95 |
+
"Do not refuse to answer or mention any issues with the research excerpts. "
|
| 96 |
"Your main task is to use the RESEARCH_EXCERPTS to provide a concise ANSWER to the USER_QUERY. "
|
| 97 |
"DO NOT list references at the end of the answer.\n\n"
|
| 98 |
"===== RESEARCH_EXCERPTS =====:\n{{EXCERPTS_GO_HERE}}\n\n"
|
|
|
|
| 148 |
for new_token in streamer:
|
| 149 |
if new_token != "<":
|
| 150 |
partial_message += new_token
|
|
|
|
| 151 |
yield partial_message
|
| 152 |
|
|
|
|
|
|
|
| 153 |
|
| 154 |
# Create and run the gradio interface
|
| 155 |
gradio.ChatInterface(
|
| 156 |
reply,
|
|
|
|
| 157 |
chatbot=gradio.Chatbot(
|
| 158 |
show_label=False,
|
| 159 |
show_share_button=False,
|