measmonysuon commited on
Commit
fdeda0d
1 Parent(s): 2abf6c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -82,6 +82,17 @@ def format_gpu_info(gpu_info):
82
 
83
  return formatted_info
84
 
 
 
 
 
 
 
 
 
 
 
 
85
  def gradio_interface(prompt, resolution_key, user_chat_id):
86
  if not user_chat_id.strip():
87
  return None, "User Chat ID cannot be blank. Please provide a valid User Chat ID or register with @supportBot to get UID."
@@ -245,21 +256,6 @@ def notify_webhook_with_file(user_chat_id, full_file_url, gpu_info):
245
  logger.info(f"Webhook notification sent successfully for user {user_chat_id}. Response: {response.status_code}")
246
  except requests.RequestException as e:
247
  logger.error(f"Error sending webhook notification with file URL: {e}")
248
- '''
249
- def gradio_interface(prompt, resolution_key, user_chat_id):
250
- if not user_chat_id.strip():
251
- return None, "User Chat ID cannot be blank. Please provide a valid User Chat ID."
252
-
253
- result = generate_image(prompt, resolution_key)
254
- if result and result[0]:
255
- file_path = result[0][0].get('image')
256
- if file_path and os.path.exists(file_path):
257
- update_user_points(user_chat_id, -5)
258
- notify_webhook_with_file(user_chat_id, file_path) # Notify webhook with file path
259
- return file_path, "The image was generated successfully."
260
- return None, "The image file is not available. Please try again later."
261
- return None, "There was an error processing your photo. Please try again later."
262
- '''
263
 
264
  def request_otp_and_update_ui(user_chat_id):
265
  # Validate user_chat_id
 
82
 
83
  return formatted_info
84
 
85
+ def format_gpu_info(gpu_info):
86
+ # Extract and format GPU information
87
+ is_cuda_available = gpu_info.get('is_cuda_available', False)
88
+ device_name = gpu_info.get('device_name', 'Unknown Device')
89
+
90
+ # Create a friendly message
91
+ cuda_status = "Available" if is_cuda_available else "Not Available"
92
+ formatted_info = f"Device: {device_name}, CUDA: {cuda_status}"
93
+
94
+ return formatted_info
95
+
96
  def gradio_interface(prompt, resolution_key, user_chat_id):
97
  if not user_chat_id.strip():
98
  return None, "User Chat ID cannot be blank. Please provide a valid User Chat ID or register with @supportBot to get UID."
 
256
  logger.info(f"Webhook notification sent successfully for user {user_chat_id}. Response: {response.status_code}")
257
  except requests.RequestException as e:
258
  logger.error(f"Error sending webhook notification with file URL: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
  def request_otp_and_update_ui(user_chat_id):
261
  # Validate user_chat_id