curiousgeorge1292 commited on
Commit
c399b67
·
verified ·
1 Parent(s): e908559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import requests
 
3
  from bs4 import BeautifulSoup
4
  import gradio as gr
5
  from groq import Groq
@@ -69,6 +70,8 @@ def oauth2callback():
69
  )
70
  flow.fetch_token(authorization_response=request.url)
71
 
 
 
72
  # Save the credentials to the session
73
  credentials = flow.credentials
74
  creds_dict = {
@@ -85,6 +88,8 @@ def oauth2callback():
85
 
86
  return "Authorization successful. You can now save emails to Gmail drafts"
87
 
 
 
88
  @app.route('/authenticate_gmail')
89
  def authenticate_gmail():
90
  authorization_url, state = flow.authorization_url(
@@ -92,6 +97,8 @@ def authenticate_gmail():
92
  include_granted_scopes='true'
93
  )
94
  return redirect(authorization_url)
 
 
95
  # Gmail OAuth2 logic here
96
  #credentials = get_credentials_from_oauth()
97
  #if 'user_id' not in flask.session:
@@ -325,16 +332,18 @@ def generate_email(name, email, prospect_name, linkedin_url, website_url, contex
325
  def email_agent(credentials_info, name, email, prospect_name, linkedin_url, website_url, context_url, word_count, email_purpose, interested_position, company_url, professional_title, personal_background):
326
 
327
  try:
328
- # First check if we have valid credentials
329
- credentials_info = credential_store.get_credentials(email)
330
- if not credentials_info:
331
- return ("<div style='color: red;'>Please click the 'Authenticate with Gmail' button above to connect your Gmail account.</div>", "")
332
 
333
  # Generate the email content
334
  email_content = generate_email(name, email, prospect_name, linkedin_url, website_url, context_url, word_count, email_purpose, interested_position, company_url, professional_title, personal_background)
335
 
336
  if not email_content:
337
  return ("<div style='color: red;'>Failed to generate email content.</div>", "")
 
 
 
 
 
 
338
 
339
  # Save to Gmail drafts
340
  try:
 
1
  import os
2
  import requests
3
+ import logging
4
  from bs4 import BeautifulSoup
5
  import gradio as gr
6
  from groq import Groq
 
70
  )
71
  flow.fetch_token(authorization_response=request.url)
72
 
73
+ logging.basicConfig(level=logging.DEBUG)
74
+
75
  # Save the credentials to the session
76
  credentials = flow.credentials
77
  creds_dict = {
 
88
 
89
  return "Authorization successful. You can now save emails to Gmail drafts"
90
 
91
+ logging.basicConfig(level=logging.DEBUG)
92
+
93
  @app.route('/authenticate_gmail')
94
  def authenticate_gmail():
95
  authorization_url, state = flow.authorization_url(
 
97
  include_granted_scopes='true'
98
  )
99
  return redirect(authorization_url)
100
+
101
+ logging.basicConfig(level=logging.DEBUG)
102
  # Gmail OAuth2 logic here
103
  #credentials = get_credentials_from_oauth()
104
  #if 'user_id' not in flask.session:
 
332
  def email_agent(credentials_info, name, email, prospect_name, linkedin_url, website_url, context_url, word_count, email_purpose, interested_position, company_url, professional_title, personal_background):
333
 
334
  try:
 
 
 
 
335
 
336
  # Generate the email content
337
  email_content = generate_email(name, email, prospect_name, linkedin_url, website_url, context_url, word_count, email_purpose, interested_position, company_url, professional_title, personal_background)
338
 
339
  if not email_content:
340
  return ("<div style='color: red;'>Failed to generate email content.</div>", "")
341
+
342
+ credentials_info = credential_store.get_credentials(email)
343
+ if not credentials_info:
344
+ return ("<div style='color: red;'>Please click the 'Authenticate with Gmail' button above to connect your Gmail account.</div>", "")
345
+
346
+ logging.basicConfig(level=logging.DEBUG)
347
 
348
  # Save to Gmail drafts
349
  try: