SamiKLN commited on
Commit
18d631d
·
verified ·
1 Parent(s): 3ce9638

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -2
main.py CHANGED
@@ -15,6 +15,7 @@ import io
15
  import pandas as pd
16
  from docx import Document
17
  from pptx import Presentation
 
18
 
19
  # Configuration du logging
20
  logging.basicConfig(level=logging.INFO)
@@ -218,17 +219,23 @@ async def answer_question(request: QARequest):
218
  if not context:
219
  raise HTTPException(400, "Aucun contexte trouvé pour répondre à la question.")
220
 
221
- response = client.post(
 
222
  model=MODELS["qa"],
223
  json={
224
  "inputs": {
225
  "question": request.question,
226
  "context": context
227
  }
228
-
229
  }
230
  )
231
 
 
 
 
 
 
 
232
 
233
  return {"answer": response["answer"]}
234
  except Exception as e:
 
15
  import pandas as pd
16
  from docx import Document
17
  from pptx import Presentation
18
+ import json
19
 
20
  # Configuration du logging
21
  logging.basicConfig(level=logging.INFO)
 
219
  if not context:
220
  raise HTTPException(400, "Aucun contexte trouvé pour répondre à la question.")
221
 
222
+ # Après l'appel
223
+ raw_response = client.post(
224
  model=MODELS["qa"],
225
  json={
226
  "inputs": {
227
  "question": request.question,
228
  "context": context
229
  }
 
230
  }
231
  )
232
 
233
+ # Décoder proprement
234
+ response = json.loads(raw_response)
235
+
236
+
237
+
238
+
239
 
240
  return {"answer": response["answer"]}
241
  except Exception as e: