Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,19 +12,12 @@ from langchain_community.document_loaders import WikipediaLoader, PyPDFLoader, T
|
|
12 |
from dotenv import load_dotenv
|
13 |
import tempfile
|
14 |
import mimetypes
|
15 |
-
import logging
|
16 |
|
17 |
-
# --- Initialize logging ---
|
18 |
-
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
19 |
-
logger = logging.getLogger(__name__)
|
20 |
|
21 |
# --- Load environment variables ---
|
22 |
load_dotenv()
|
23 |
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
24 |
-
|
25 |
-
logger.error("HF_API_TOKEN not found in environment variables! Please set it to use the HfApiModel.")
|
26 |
-
# Exit or raise an error if the token is critical for functionality
|
27 |
-
# sys.exit(1) # Uncomment if you want to exit the script if token is missing
|
28 |
|
29 |
# --- Utility Functions ---
|
30 |
def extract_youtube_id(url: str) -> str:
|
@@ -346,14 +339,11 @@ You are an advanced, helpful, and highly analytical research assistant. Your goa
|
|
346 |
return agent
|
347 |
|
348 |
def __call__(self, question: str) -> str:
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
except Exception as e:
|
355 |
-
logger.error(f"Agent execution failed for question '{question[:100]}': {str(e)}", exc_info=True) # Log full traceback
|
356 |
-
return f"Error processing your request: {str(e)}. Please try again or rephrase your question."
|
357 |
|
358 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
359 |
"""
|
|
|
12 |
from dotenv import load_dotenv
|
13 |
import tempfile
|
14 |
import mimetypes
|
|
|
15 |
|
|
|
|
|
|
|
16 |
|
17 |
# --- Load environment variables ---
|
18 |
load_dotenv()
|
19 |
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
20 |
+
|
|
|
|
|
|
|
21 |
|
22 |
# --- Utility Functions ---
|
23 |
def extract_youtube_id(url: str) -> str:
|
|
|
339 |
return agent
|
340 |
|
341 |
def __call__(self, question: str) -> str:
|
342 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
343 |
+
answer = self.agent.run(question)
|
344 |
+
print(f"Agent returning answer: {answer}")
|
345 |
+
return answer
|
346 |
+
|
|
|
|
|
|
|
347 |
|
348 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
349 |
"""
|