Update app.py
Browse files
app.py
CHANGED
|
@@ -56,8 +56,18 @@ chat_engine = index.as_chat_engine(
|
|
| 56 |
),
|
| 57 |
)
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
import gradio as gr
|
| 60 |
def chat_with_ai(user_input, chat_history):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
response = chat_engine.chat(user_input)
|
| 62 |
references = response.source_nodes
|
| 63 |
ref,pages = [],[]
|
|
|
|
| 56 |
),
|
| 57 |
)
|
| 58 |
|
| 59 |
+
def is_greeting(user_input):
|
| 60 |
+
|
| 61 |
+
greetings = ["hello", "hi", "hey", "good morning", "good afternoon", "good evening", "greetings"]
|
| 62 |
+
user_input_lower = user_input.lower().strip()
|
| 63 |
+
return any(greet in user_input_lower for greet in greetings)
|
| 64 |
+
|
| 65 |
import gradio as gr
|
| 66 |
def chat_with_ai(user_input, chat_history):
|
| 67 |
+
if is_greeting(user_input):
|
| 68 |
+
response = chat_engine.chat(user_input)
|
| 69 |
+
chat_history.append((user_input, greeting_response))
|
| 70 |
+
return chat_history, ""
|
| 71 |
response = chat_engine.chat(user_input)
|
| 72 |
references = response.source_nodes
|
| 73 |
ref,pages = [],[]
|