edouardlgp commited on
Commit
96017ad
Β·
verified Β·
1 Parent(s): c984fb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
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
- #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 = rag1.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
 
 
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