Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import pandas as pd
|
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
| 4 |
import faiss
|
|
|
|
| 5 |
from sentence_transformers import SentenceTransformer
|
| 6 |
from huggingface_hub import InferenceClient
|
| 7 |
|
|
@@ -39,7 +40,8 @@ def generate_answer(messages):
|
|
| 39 |
Question: {user_query}
|
| 40 |
Answer:"""
|
| 41 |
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
response = client.text_generation(
|
| 45 |
prompt,
|
|
@@ -50,7 +52,8 @@ Answer:"""
|
|
| 50 |
return {"role": "assistant", "content": response.strip()}
|
| 51 |
|
| 52 |
except Exception as e:
|
| 53 |
-
|
|
|
|
| 54 |
return {"role": "assistant", "content": "An internal error occurred. Please try again."}
|
| 55 |
|
| 56 |
# --- Gradio Chat Interface ---
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
| 4 |
import faiss
|
| 5 |
+
import sys
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from huggingface_hub import InferenceClient
|
| 8 |
|
|
|
|
| 40 |
Question: {user_query}
|
| 41 |
Answer:"""
|
| 42 |
|
| 43 |
+
sys.stderr.write(f"Prompt sent to model:\n{prompt}\n")
|
| 44 |
+
sys.stderr.flush()
|
| 45 |
|
| 46 |
response = client.text_generation(
|
| 47 |
prompt,
|
|
|
|
| 52 |
return {"role": "assistant", "content": response.strip()}
|
| 53 |
|
| 54 |
except Exception as e:
|
| 55 |
+
sys.stderr.write(f"Error during inference: {type(e).__name__}: {e}\n")
|
| 56 |
+
sys.stderr.flush()
|
| 57 |
return {"role": "assistant", "content": "An internal error occurred. Please try again."}
|
| 58 |
|
| 59 |
# --- Gradio Chat Interface ---
|