getGO007 commited on
Commit
6bbd22d
·
verified ·
1 Parent(s): 2359e0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -1,4 +1,10 @@
1
  import os
 
 
 
 
 
 
2
  # import openai
3
  import shutil
4
  import asyncio
@@ -33,6 +39,8 @@ Settings.chunk_overlap = 64
33
 
34
 
35
  # ---- 2. Parser Setup ----
 
 
36
  parser = LlamaParse(
37
  api_key = LLAMA_CLOUD_API_KEY,
38
  # base_url = os.getenv("LLAMA_CLOUD_BASE_URL"),
@@ -51,6 +59,10 @@ Path("./index_data").mkdir(exist_ok=True)
51
 
52
  # ---- 3a. Upload + Answer Logic ----
53
  async def answer(uploaded_files: list[gr.FileData], question: str) -> str:
 
 
 
 
54
  if not uploaded_files:
55
  return "❗ Please upload at least one PDF."
56
  if len(uploaded_files) > 5:
 
1
  import os
2
+
3
+ print(">>> DEBUG: Environment Variables at Startup <<<")
4
+ for var in ("OPENAI_API_KEY", "LLAMA_CLOUD_API_KEY"):
5
+ #, "LLAMA_CLOUD_BASE_URL"):
6
+ print(f"{var} = {os.getenv(var)!r}")
7
+
8
  # import openai
9
  import shutil
10
  import asyncio
 
39
 
40
 
41
  # ---- 2. Parser Setup ----
42
+ print(">>> DEBUG: About to init LlamaParse with key:", os.getenv("LLAMA_CLOUD_API_KEY") is not None)
43
+ # print(">>> DEBUG: About to init LlamaParse with key:", os.getenv("LLAMA_CLOUD_BASE_URL") is not None)
44
  parser = LlamaParse(
45
  api_key = LLAMA_CLOUD_API_KEY,
46
  # base_url = os.getenv("LLAMA_CLOUD_BASE_URL"),
 
59
 
60
  # ---- 3a. Upload + Answer Logic ----
61
  async def answer(uploaded_files: list[gr.FileData], question: str) -> str:
62
+
63
+ print(f">>> DEBUG: answer() called. OPENAI key set? {os.getenv('OPENAI_API_KEY') is not None}")
64
+ print(f">>> DEBUG: answer() called. LLAMA key set? {os.getenv('LLAMA_CLOUD_API_KEY') is not None}")
65
+
66
  if not uploaded_files:
67
  return "❗ Please upload at least one PDF."
68
  if len(uploaded_files) > 5: