Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -135,20 +135,14 @@ def load_profile():
|
|
| 135 |
def respond(message, chat_history):
|
| 136 |
if not message:
|
| 137 |
return "", chat_history
|
| 138 |
-
|
| 139 |
-
# Initialize history if None (though Gradio usually handles this)
|
| 140 |
-
if chat_history is None:
|
| 141 |
-
chat_history = []
|
| 142 |
|
| 143 |
-
# Append user message immediately for responsiveness
|
| 144 |
-
chat_history.append({"role": "user", "content": message})
|
| 145 |
-
|
| 146 |
try:
|
| 147 |
# Get AI response
|
| 148 |
answer = query_rag(message, vector_store, hf_client)
|
| 149 |
-
|
|
|
|
| 150 |
except Exception as e:
|
| 151 |
-
chat_history.append(
|
| 152 |
|
| 153 |
return "", chat_history
|
| 154 |
|
|
@@ -162,7 +156,7 @@ with gr.Blocks(title="My AI Twin", theme=gr.themes.Soft()) as demo:
|
|
| 162 |
gr.Textbox(value=load_profile(), label="About Me", interactive=False, lines=15)
|
| 163 |
|
| 164 |
with gr.Column(scale=2):
|
| 165 |
-
chatbot = gr.Chatbot(label="Conversation", height=400
|
| 166 |
msg = gr.Textbox(label="Ask a question", placeholder="e.g. What are my skills?")
|
| 167 |
with gr.Row():
|
| 168 |
submit_btn = gr.Button("Submit", variant="primary")
|
|
|
|
| 135 |
def respond(message, chat_history):
|
| 136 |
if not message:
|
| 137 |
return "", chat_history
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
|
|
|
|
|
|
|
|
|
| 139 |
try:
|
| 140 |
# Get AI response
|
| 141 |
answer = query_rag(message, vector_store, hf_client)
|
| 142 |
+
# Standard tuple format: (user_msg, bot_msg)
|
| 143 |
+
chat_history.append((message, answer))
|
| 144 |
except Exception as e:
|
| 145 |
+
chat_history.append((message, f"Error: {str(e)}"))
|
| 146 |
|
| 147 |
return "", chat_history
|
| 148 |
|
|
|
|
| 156 |
gr.Textbox(value=load_profile(), label="About Me", interactive=False, lines=15)
|
| 157 |
|
| 158 |
with gr.Column(scale=2):
|
| 159 |
+
chatbot = gr.Chatbot(label="Conversation", height=400)
|
| 160 |
msg = gr.Textbox(label="Ask a question", placeholder="e.g. What are my skills?")
|
| 161 |
with gr.Row():
|
| 162 |
submit_btn = gr.Button("Submit", variant="primary")
|