yalrashed commited on
Commit
edfc0ce
·
verified ·
1 Parent(s): d880189

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -53,7 +53,7 @@ def process_screenplay(pdf_file, progress=gr.Progress()):
53
  cleaned_text = f.read()
54
 
55
  progress(1.0, desc="Complete!")
56
- return [cleaned_text, gr.update(interactive=True, variant="primary"),
57
  gr.update(interactive=True, variant="primary"),
58
  gr.update(interactive=False, variant="secondary"),
59
  gr.update(interactive=False, variant="secondary"),
@@ -77,11 +77,12 @@ def generate_coverage(progress=gr.Progress()):
77
  if not success:
78
  raise gr.Error("Failed to generate coverage")
79
 
80
- with open(Path("coverage.txt"), 'r') as f:
 
81
  coverage = f.read()
82
 
83
  progress(1.0, desc="Complete!")
84
- return [coverage, console.get_output()]
85
 
86
  except Exception as e:
87
  error_msg = f"Error: {str(e)}"
@@ -101,11 +102,12 @@ def analyze_screenplay(progress=gr.Progress()):
101
  if not success:
102
  raise gr.Error("Failed to generate creative analysis")
103
 
104
- with open(Path("creative_analysis.txt"), 'r') as f:
 
105
  analysis = f.read()
106
 
107
  progress(1.0, desc="Complete!")
108
- return [analysis, gr.update(interactive=True, variant="primary"), console.get_output()]
109
 
110
  except Exception as e:
111
  error_msg = f"Error: {str(e)}"
@@ -130,7 +132,7 @@ def post_process_analysis(progress=gr.Progress()):
130
  analysis = f.read()
131
 
132
  progress(1.0, desc="Complete!")
133
- return [analysis, gr.update(interactive=True, variant="primary"), console.get_output()]
134
 
135
  except Exception as e:
136
  error_msg = f"Error: {str(e)}"
@@ -151,11 +153,12 @@ def generate_market_analysis(progress=gr.Progress()):
151
  if not success:
152
  raise gr.Error("Failed to generate market analysis")
153
 
154
- with open(Path("market_analysis.txt"), 'r') as f:
 
155
  analysis = f.read()
156
 
157
  progress(1.0, desc="Complete!")
158
- return [analysis, console.get_output()]
159
 
160
  except Exception as e:
161
  error_msg = f"Error: {str(e)}"
@@ -183,56 +186,56 @@ with gr.Blocks(title="Screenplay Coverage Generator") as demo:
183
  with gr.Row():
184
  cleaned_output = gr.Textbox(label="Cleaned Screenplay", lines=10, show_copy_button=True)
185
  with gr.Row():
186
- gr.File(value="cleaned_screenplay_long.txt", label="Download Cleaned Screenplay")
187
 
188
  with gr.TabItem("Coverage"):
189
  with gr.Row():
190
  coverage_output = gr.Textbox(label="Coverage Document", lines=10, show_copy_button=True)
191
  with gr.Row():
192
- gr.File(value="coverage.txt", label="Download Coverage")
193
 
194
  with gr.TabItem("Creative Analysis"):
195
  with gr.Row():
196
  analysis_output = gr.Textbox(label="Creative Analysis", lines=10, show_copy_button=True)
197
  with gr.Row():
198
- gr.File(value="creative_analysis.txt", label="Download Creative Analysis")
199
 
200
  with gr.TabItem("Post-Processed Analysis"):
201
  with gr.Row():
202
  post_process_output = gr.Textbox(label="Post-Processed Analysis", lines=10, show_copy_button=True)
203
  with gr.Row():
204
- gr.File(value="cleaned_creative_analysis.txt", label="Download Post-Processed Analysis")
205
 
206
  with gr.TabItem("Market Analysis"):
207
  with gr.Row():
208
  market_output = gr.Textbox(label="Market Analysis", lines=10, show_copy_button=True)
209
  with gr.Row():
210
- gr.File(value="market_analysis.txt", label="Download Market Analysis")
211
 
212
  process_btn.click(
213
  fn=process_screenplay,
214
  inputs=[file_input],
215
- outputs=[cleaned_output, coverage_btn, analysis_btn, post_process_btn, market_btn, console]
216
  )
217
 
218
  coverage_btn.click(
219
  fn=generate_coverage,
220
- outputs=[coverage_output, console]
221
  )
222
 
223
  analysis_btn.click(
224
  fn=analyze_screenplay,
225
- outputs=[analysis_output, post_process_btn, console]
226
  )
227
 
228
  post_process_btn.click(
229
  fn=post_process_analysis,
230
- outputs=[post_process_output, market_btn, console]
231
  )
232
 
233
  market_btn.click(
234
  fn=generate_market_analysis,
235
- outputs=[market_output, console]
236
  )
237
 
238
  if __name__ == "__main__":
 
53
  cleaned_text = f.read()
54
 
55
  progress(1.0, desc="Complete!")
56
+ return [cleaned_text, str(cleaned_path), gr.update(interactive=True, variant="primary"),
57
  gr.update(interactive=True, variant="primary"),
58
  gr.update(interactive=False, variant="secondary"),
59
  gr.update(interactive=False, variant="secondary"),
 
77
  if not success:
78
  raise gr.Error("Failed to generate coverage")
79
 
80
+ coverage_path = Path("coverage.txt")
81
+ with open(coverage_path, 'r') as f:
82
  coverage = f.read()
83
 
84
  progress(1.0, desc="Complete!")
85
+ return [coverage, str(coverage_path), console.get_output()]
86
 
87
  except Exception as e:
88
  error_msg = f"Error: {str(e)}"
 
102
  if not success:
103
  raise gr.Error("Failed to generate creative analysis")
104
 
105
+ analysis_path = Path("creative_analysis.txt")
106
+ with open(analysis_path, 'r') as f:
107
  analysis = f.read()
108
 
109
  progress(1.0, desc="Complete!")
110
+ return [analysis, str(analysis_path), gr.update(interactive=True, variant="primary"), console.get_output()]
111
 
112
  except Exception as e:
113
  error_msg = f"Error: {str(e)}"
 
132
  analysis = f.read()
133
 
134
  progress(1.0, desc="Complete!")
135
+ return [analysis, str(output_path), gr.update(interactive=True, variant="primary"), console.get_output()]
136
 
137
  except Exception as e:
138
  error_msg = f"Error: {str(e)}"
 
153
  if not success:
154
  raise gr.Error("Failed to generate market analysis")
155
 
156
+ market_path = Path("market_analysis.txt")
157
+ with open(market_path, 'r') as f:
158
  analysis = f.read()
159
 
160
  progress(1.0, desc="Complete!")
161
+ return [analysis, str(market_path), console.get_output()]
162
 
163
  except Exception as e:
164
  error_msg = f"Error: {str(e)}"
 
186
  with gr.Row():
187
  cleaned_output = gr.Textbox(label="Cleaned Screenplay", lines=10, show_copy_button=True)
188
  with gr.Row():
189
+ cleaned_file = gr.File(label="Download Cleaned Screenplay", interactive=True, visible=False)
190
 
191
  with gr.TabItem("Coverage"):
192
  with gr.Row():
193
  coverage_output = gr.Textbox(label="Coverage Document", lines=10, show_copy_button=True)
194
  with gr.Row():
195
+ coverage_file = gr.File(label="Download Coverage", interactive=True, visible=False)
196
 
197
  with gr.TabItem("Creative Analysis"):
198
  with gr.Row():
199
  analysis_output = gr.Textbox(label="Creative Analysis", lines=10, show_copy_button=True)
200
  with gr.Row():
201
+ analysis_file = gr.File(label="Download Creative Analysis", interactive=True, visible=False)
202
 
203
  with gr.TabItem("Post-Processed Analysis"):
204
  with gr.Row():
205
  post_process_output = gr.Textbox(label="Post-Processed Analysis", lines=10, show_copy_button=True)
206
  with gr.Row():
207
+ post_process_file = gr.File(label="Download Post-Processed Analysis", interactive=True, visible=False)
208
 
209
  with gr.TabItem("Market Analysis"):
210
  with gr.Row():
211
  market_output = gr.Textbox(label="Market Analysis", lines=10, show_copy_button=True)
212
  with gr.Row():
213
+ market_file = gr.File(label="Download Market Analysis", interactive=True, visible=False)
214
 
215
  process_btn.click(
216
  fn=process_screenplay,
217
  inputs=[file_input],
218
+ outputs=[cleaned_output, cleaned_file, coverage_btn, analysis_btn, post_process_btn, market_btn, console]
219
  )
220
 
221
  coverage_btn.click(
222
  fn=generate_coverage,
223
+ outputs=[coverage_output, coverage_file, console]
224
  )
225
 
226
  analysis_btn.click(
227
  fn=analyze_screenplay,
228
+ outputs=[analysis_output, analysis_file, post_process_btn, console]
229
  )
230
 
231
  post_process_btn.click(
232
  fn=post_process_analysis,
233
+ outputs=[post_process_output, post_process_file, market_btn, console]
234
  )
235
 
236
  market_btn.click(
237
  fn=generate_market_analysis,
238
+ outputs=[market_output, market_file, console]
239
  )
240
 
241
  if __name__ == "__main__":