Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- README.md +1 -1
- app.py +6 -7
- requirements.txt +2 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🤖
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.16.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
app.py
CHANGED
|
@@ -135,15 +135,14 @@ def load_profile():
|
|
| 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 |
-
|
| 143 |
-
chat_history.append((message, answer))
|
| 144 |
except Exception as e:
|
| 145 |
-
chat_history.append(
|
| 146 |
-
|
| 147 |
return "", chat_history
|
| 148 |
|
| 149 |
with gr.Blocks(title="My AI Twin", theme=gr.themes.Soft()) as demo:
|
|
@@ -156,7 +155,7 @@ with gr.Blocks(title="My AI Twin", theme=gr.themes.Soft()) as demo:
|
|
| 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")
|
|
|
|
| 135 |
def respond(message, chat_history):
|
| 136 |
if not message:
|
| 137 |
return "", chat_history
|
| 138 |
+
if chat_history is None:
|
| 139 |
+
chat_history = []
|
| 140 |
+
chat_history.append({"role": "user", "content": message})
|
| 141 |
try:
|
|
|
|
| 142 |
answer = query_rag(message, vector_store, hf_client)
|
| 143 |
+
chat_history.append({"role": "assistant", "content": answer})
|
|
|
|
| 144 |
except Exception as e:
|
| 145 |
+
chat_history.append({"role": "assistant", "content": f"Error: {str(e)}"})
|
|
|
|
| 146 |
return "", chat_history
|
| 147 |
|
| 148 |
with gr.Blocks(title="My AI Twin", theme=gr.themes.Soft()) as demo:
|
|
|
|
| 155 |
gr.Textbox(value=load_profile(), label="About Me", interactive=False, lines=15)
|
| 156 |
|
| 157 |
with gr.Column(scale=2):
|
| 158 |
+
chatbot = gr.Chatbot(label="Conversation", height=400, type="messages")
|
| 159 |
msg = gr.Textbox(label="Ask a question", placeholder="e.g. What are my skills?")
|
| 160 |
with gr.Row():
|
| 161 |
submit_btn = gr.Button("Submit", variant="primary")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
-
gradio
|
| 2 |
huggingface-hub
|
| 3 |
numpy
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
huggingface-hub
|
| 3 |
numpy
|
| 4 |
+
pydantic==2.10.6
|