BroBro87 commited on
Commit
103d454
·
verified ·
1 Parent(s): 7801ced

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -17,7 +17,7 @@ class CalendarWrappedAPI:
17
  self.llm = OpenAI(model="gpt-4", api_key=os.getenv('OPENAI_API_KEY'))
18
  self.connections = {}
19
 
20
- def initiate_connection(self, entity_id, redirect_url=None):
21
  """Initialize connection using entity_id (username)"""
22
 
23
  try:
@@ -31,7 +31,9 @@ class CalendarWrappedAPI:
31
  'status': connection_request.connectionStatus,
32
  'redirect_url': connection_request.redirectUrl
33
  }
34
-
 
 
35
  # Wait for random time between 60-100 seconds
36
  wait_time = random.randint(60, 100)
37
  print(f"Waiting for {wait_time} seconds before checking connection status...")
@@ -102,8 +104,8 @@ class CalendarWrappedAPI:
102
  def create_gradio_api():
103
  api = CalendarWrappedAPI()
104
 
105
- def handle_connection(entity_id, redirect_url):
106
- result = api.initiate_connection(entity_id, redirect_url)
107
  return {
108
  **result,
109
  'message': f"Connection initiated. Waited for {result.get('wait_time', 0)} seconds."
@@ -119,8 +121,7 @@ def create_gradio_api():
119
  with gr.Blocks() as demo:
120
  gr.Markdown("""
121
  # Google Calendar Wrapped Generator
122
- **Note**: After initiating connection, check the console/terminal for the redirect URL.
123
- The status will be checked automatically after 60-100 seconds.
124
  """)
125
 
126
  with gr.Tab("Connection"):
@@ -128,16 +129,12 @@ def create_gradio_api():
128
  label="Entity ID (Username)",
129
  placeholder="Enter your username as entity ID"
130
  )
131
- redirect_url_input = gr.Textbox(
132
- label="Redirect URL",
133
- placeholder="https://yourwebsite.com/connection/success"
134
- )
135
  connect_btn = gr.Button("Initialize Connection")
136
  connection_output = gr.HTML(label="Connection Status")
137
 
138
  connect_btn.click(
139
  fn=handle_connection,
140
- inputs=[entity_id_input, redirect_url_input],
141
  outputs=connection_output
142
  )
143
 
 
17
  self.llm = OpenAI(model="gpt-4", api_key=os.getenv('OPENAI_API_KEY'))
18
  self.connections = {}
19
 
20
+ def initiate_connection(self, entity_id):
21
  """Initialize connection using entity_id (username)"""
22
 
23
  try:
 
31
  'status': connection_request.connectionStatus,
32
  'redirect_url': connection_request.redirectUrl
33
  }
34
+ return {
35
+ 'redirect_url':f'<a href="{connection_request.redirectUrl}" target="_blank">{connection_request.redirectUrl}</a>'
36
+ }
37
  # Wait for random time between 60-100 seconds
38
  wait_time = random.randint(60, 100)
39
  print(f"Waiting for {wait_time} seconds before checking connection status...")
 
104
  def create_gradio_api():
105
  api = CalendarWrappedAPI()
106
 
107
+ def handle_connection(entity_id):
108
+ result = api.initiate_connection(entity_id)
109
  return {
110
  **result,
111
  'message': f"Connection initiated. Waited for {result.get('wait_time', 0)} seconds."
 
121
  with gr.Blocks() as demo:
122
  gr.Markdown("""
123
  # Google Calendar Wrapped Generator
124
+ **Note**: After initiating connection, check the connection status and generate your wrapped summary.
 
125
  """)
126
 
127
  with gr.Tab("Connection"):
 
129
  label="Entity ID (Username)",
130
  placeholder="Enter your username as entity ID"
131
  )
 
 
 
 
132
  connect_btn = gr.Button("Initialize Connection")
133
  connection_output = gr.HTML(label="Connection Status")
134
 
135
  connect_btn.click(
136
  fn=handle_connection,
137
+ inputs=entity_id_input,
138
  outputs=connection_output
139
  )
140