Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,39 +88,39 @@ except Exception as e:
|
|
| 88 |
## Let's a do simple test from the doc --
|
| 89 |
|
| 90 |
# Define query and sources
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
|
| 106 |
# Generate a response
|
| 107 |
-
|
| 108 |
-
|
| 109 |
# rag1 = RAGWithCitations(
|
| 110 |
# model_path_or_name="PleIAs/Pleias-RAG-350M"
|
| 111 |
# )
|
| 112 |
-
|
| 113 |
-
|
| 114 |
# do_sample=True, # Enable sampling
|
| 115 |
# top_p=0.95, # Set top_p for nucleus sampling
|
| 116 |
# pad_token_id=rag.tokenizer.eos_token_id, # Set pad_token_id to eos_token_id
|
| 117 |
# attention_mask=None # Ensure attention_mask is passed if needed
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
|
| 125 |
|
| 126 |
|
|
|
|
| 88 |
## Let's a do simple test from the doc --
|
| 89 |
|
| 90 |
# Define query and sources
|
| 91 |
+
query = "What is the capital of France?"
|
| 92 |
+
log_debug(f"π Test Query: {query}")
|
| 93 |
+
|
| 94 |
+
sources = [
|
| 95 |
+
{
|
| 96 |
+
"text": "Paris is the capital and most populous city of France.",
|
| 97 |
+
"metadata": {"source": "Geographic Encyclopedia", "reliability": "high"}
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"text": "The Eiffel Tower is located in Paris, France.",
|
| 101 |
+
"metadata": {"source": "Travel Guide", "year": 2020}
|
| 102 |
+
}
|
| 103 |
+
]
|
| 104 |
+
log_debug("π Test Sources loaded successfully.")
|
| 105 |
|
| 106 |
# Generate a response
|
| 107 |
+
try:
|
| 108 |
+
log_debug("π§ Test rag model on simple example...")
|
| 109 |
# rag1 = RAGWithCitations(
|
| 110 |
# model_path_or_name="PleIAs/Pleias-RAG-350M"
|
| 111 |
# )
|
| 112 |
+
response = rag.generate(query,
|
| 113 |
+
sources #,
|
| 114 |
# do_sample=True, # Enable sampling
|
| 115 |
# top_p=0.95, # Set top_p for nucleus sampling
|
| 116 |
# pad_token_id=rag.tokenizer.eos_token_id, # Set pad_token_id to eos_token_id
|
| 117 |
# attention_mask=None # Ensure attention_mask is passed if needed
|
| 118 |
+
)
|
| 119 |
+
log_debug("β
Test Answer generated successfully.")
|
| 120 |
+
log_debug(response["processed"]["clean_answer"])
|
| 121 |
+
except Exception as e:
|
| 122 |
+
log_debug(f"β Test Answer generation failed: {str(e)}")
|
| 123 |
+
raise
|
| 124 |
|
| 125 |
|
| 126 |
|