Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,3 @@
|
|
1 |
-
"""
|
2 |
-
DOLPHIN PDF Document AI - Local Gemma 3n Version
|
3 |
-
Optimized for powerful GPU deployment with local models
|
4 |
-
Features: AI-generated alt text for accessibility using local Gemma 3n
|
5 |
-
"""
|
6 |
-
|
7 |
import gradio as gr
|
8 |
import json
|
9 |
import markdown
|
@@ -981,7 +975,7 @@ with gr.Blocks(
|
|
981 |
return history
|
982 |
|
983 |
if not processed_markdown:
|
984 |
-
return history + [
|
985 |
|
986 |
try:
|
987 |
# Use RAG to get relevant chunks from markdown
|
@@ -1009,14 +1003,14 @@ Please provide a clear and helpful answer based on the context provided."""
|
|
1009 |
|
1010 |
# Generate response using local Gemma 3n
|
1011 |
response_text = gemma_model.chat(prompt)
|
1012 |
-
return history + [
|
1013 |
|
1014 |
except Exception as e:
|
1015 |
error_msg = f"β Error generating response: {str(e)}"
|
1016 |
print(f"Full error: {e}")
|
1017 |
import traceback
|
1018 |
traceback.print_exc()
|
1019 |
-
return history + [
|
1020 |
|
1021 |
send_btn.click(
|
1022 |
fn=chatbot_response,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
import markdown
|
|
|
975 |
return history
|
976 |
|
977 |
if not processed_markdown:
|
978 |
+
return history + [{"role": "user", "content": message}, {"role": "assistant", "content": "β Please process a PDF document first before asking questions."}]
|
979 |
|
980 |
try:
|
981 |
# Use RAG to get relevant chunks from markdown
|
|
|
1003 |
|
1004 |
# Generate response using local Gemma 3n
|
1005 |
response_text = gemma_model.chat(prompt)
|
1006 |
+
return history + [{"role": "user", "content": message}, {"role": "assistant", "content": response_text}]
|
1007 |
|
1008 |
except Exception as e:
|
1009 |
error_msg = f"β Error generating response: {str(e)}"
|
1010 |
print(f"Full error: {e}")
|
1011 |
import traceback
|
1012 |
traceback.print_exc()
|
1013 |
+
return history + [{"role": "user", "content": message}, {"role": "assistant", "content": error_msg}]
|
1014 |
|
1015 |
send_btn.click(
|
1016 |
fn=chatbot_response,
|