GattoNero commited on
Commit
93997a6
·
verified ·
1 Parent(s): a62509e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -12,6 +12,10 @@ from llama_index.core import (
12
  )
13
  from llama_index.llms.openai import OpenAI
14
 
 
 
 
 
15
 
16
  class BasicAgent:
17
  def __init__(self):
@@ -26,7 +30,8 @@ class BasicAgent:
26
  llm = OpenAI(
27
  model="gpt-4o-mini",
28
  temperature=0,
29
- api_key=openai_api_key
 
30
  )
31
 
32
  # Imposta le impostazioni tramite Settings
@@ -46,6 +51,11 @@ class BasicAgent:
46
  def __call__(self, question: str) -> str:
47
  print(f"Received question: {question[:50]}...")
48
  response = self.query_engine.query(question)
 
 
 
 
 
49
  return str(response)
50
 
51
 
@@ -91,7 +101,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
91
  try:
92
  response = requests.get(questions_url, timeout=15)
93
  response.raise_for_status()
94
- questions_data = response.json()
 
95
  if not questions_data:
96
  print("Fetched questions list is empty.")
97
  return "Fetched questions list is empty or invalid format.", None
 
12
  )
13
  from llama_index.llms.openai import OpenAI
14
 
15
+ NUMERO_DOMANDE_TOTALE = 1
16
+
17
+ set_global_handler("DEBUG") # Oppure "INFO" se vuoi meno verbosità
18
+ logging.getLogger().setLevel(logging.DEBUG)
19
 
20
  class BasicAgent:
21
  def __init__(self):
 
30
  llm = OpenAI(
31
  model="gpt-4o-mini",
32
  temperature=0,
33
+ api_key=openai_api_key,
34
+ verbose = True
35
  )
36
 
37
  # Imposta le impostazioni tramite Settings
 
51
  def __call__(self, question: str) -> str:
52
  print(f"Received question: {question[:50]}...")
53
  response = self.query_engine.query(question)
54
+
55
+ # Stampa ragionamento interno
56
+ print("Query response object:", response)
57
+ print("Response text:", str(response))
58
+
59
  return str(response)
60
 
61
 
 
101
  try:
102
  response = requests.get(questions_url, timeout=15)
103
  response.raise_for_status()
104
+ total_questions = response.json()
105
+ questions_data = total_questions[:NUMERO_DOMANDE_TOTALE]
106
  if not questions_data:
107
  print("Fetched questions list is empty.")
108
  return "Fetched questions list is empty or invalid format.", None