Upload api.py
Browse files
api.py
CHANGED
|
@@ -24,12 +24,12 @@ class GAIAHFAPIClient:
|
|
| 24 |
def __init__(self, profile: gr.OAuthProfile | None, api_base_url=DEFAULT_API_URL):
|
| 25 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 26 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
self.agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 34 |
self.questions_url = f"{api_base_url}/questions"
|
| 35 |
self.random_question_url = f"{api_base_url}/random-question"
|
|
|
|
| 24 |
def __init__(self, profile: gr.OAuthProfile | None, api_base_url=DEFAULT_API_URL):
|
| 25 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 26 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 27 |
+
if profile:
|
| 28 |
+
self.username = f"{profile.username}"
|
| 29 |
+
logger.info(f"User logged in: {self.username}")
|
| 30 |
+
else:
|
| 31 |
+
logger.warning("User not logged in.")
|
| 32 |
+
return "Please Login to Hugging Face with the button.", None
|
| 33 |
self.agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 34 |
self.questions_url = f"{api_base_url}/questions"
|
| 35 |
self.random_question_url = f"{api_base_url}/random-question"
|