Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from src.processing.gemini_processor import GeminiProcessor
|
|
4 |
from src.analysis.coverage_generator import CoverageGenerator
|
5 |
from src.analysis.creative_analyzer import CreativeAnalyzer
|
6 |
from src.analysis.analysis_post_processor import AnalysisPostProcessor
|
|
|
7 |
from pathlib import Path
|
8 |
import logging
|
9 |
|
@@ -55,6 +56,7 @@ def process_screenplay(pdf_file, progress=gr.Progress()):
|
|
55 |
return [cleaned_text, gr.update(interactive=True, variant="primary"),
|
56 |
gr.update(interactive=True, variant="primary"),
|
57 |
gr.update(interactive=False, variant="secondary"),
|
|
|
58 |
console.get_output()]
|
59 |
|
60 |
except Exception as e:
|
@@ -127,6 +129,31 @@ def post_process_analysis(progress=gr.Progress()):
|
|
127 |
with open(output_path, 'r') as f:
|
128 |
analysis = f.read()
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
progress(1.0, desc="Complete!")
|
131 |
return [analysis, console.get_output()]
|
132 |
|
@@ -146,6 +173,7 @@ with gr.Blocks(title="Screenplay Coverage Generator") as demo:
|
|
146 |
coverage_btn = gr.Button("Generate Coverage", interactive=False)
|
147 |
analysis_btn = gr.Button("Creative Analysis", interactive=False)
|
148 |
post_process_btn = gr.Button("Post-Process Analysis", interactive=False)
|
|
|
149 |
|
150 |
with gr.Row():
|
151 |
console = gr.Textbox(label="Console Output", lines=10, max_lines=30, autoscroll=True, show_copy_button=True)
|
@@ -159,11 +187,13 @@ with gr.Blocks(title="Screenplay Coverage Generator") as demo:
|
|
159 |
analysis_output = gr.Textbox(label="Creative Analysis", lines=10, show_copy_button=True)
|
160 |
with gr.TabItem("Post-Processed Analysis"):
|
161 |
post_process_output = gr.Textbox(label="Post-Processed Analysis", lines=10, show_copy_button=True)
|
|
|
|
|
162 |
|
163 |
process_btn.click(
|
164 |
fn=process_screenplay,
|
165 |
inputs=[file_input],
|
166 |
-
outputs=[cleaned_output, coverage_btn, analysis_btn, post_process_btn, console]
|
167 |
)
|
168 |
|
169 |
coverage_btn.click(
|
@@ -178,7 +208,12 @@ with gr.Blocks(title="Screenplay Coverage Generator") as demo:
|
|
178 |
|
179 |
post_process_btn.click(
|
180 |
fn=post_process_analysis,
|
181 |
-
outputs=[post_process_output, console]
|
|
|
|
|
|
|
|
|
|
|
182 |
)
|
183 |
|
184 |
if __name__ == "__main__":
|
|
|
4 |
from src.analysis.coverage_generator import CoverageGenerator
|
5 |
from src.analysis.creative_analyzer import CreativeAnalyzer
|
6 |
from src.analysis.analysis_post_processor import AnalysisPostProcessor
|
7 |
+
from src.analysis.market_analyzer import MarketAnalyzer
|
8 |
from pathlib import Path
|
9 |
import logging
|
10 |
|
|
|
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"),
|
60 |
console.get_output()]
|
61 |
|
62 |
except Exception as e:
|
|
|
129 |
with open(output_path, 'r') as f:
|
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)}"
|
137 |
+
console.write(error_msg)
|
138 |
+
raise gr.Error(error_msg)
|
139 |
+
|
140 |
+
def generate_market_analysis(progress=gr.Progress()):
|
141 |
+
console = ConsoleOutput()
|
142 |
+
logger = setup_logging(console)
|
143 |
+
|
144 |
+
try:
|
145 |
+
market_analyzer = MarketAnalyzer()
|
146 |
+
progress(0.5, desc="Generating market analysis...")
|
147 |
+
coverage_path = Path("coverage.txt")
|
148 |
+
creative_analysis_path = Path("cleaned_creative_analysis.txt")
|
149 |
+
success = market_analyzer.generate_market_analysis(coverage_path, creative_analysis_path)
|
150 |
+
|
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 |
|
|
|
173 |
coverage_btn = gr.Button("Generate Coverage", interactive=False)
|
174 |
analysis_btn = gr.Button("Creative Analysis", interactive=False)
|
175 |
post_process_btn = gr.Button("Post-Process Analysis", interactive=False)
|
176 |
+
market_btn = gr.Button("Market Analysis", interactive=False)
|
177 |
|
178 |
with gr.Row():
|
179 |
console = gr.Textbox(label="Console Output", lines=10, max_lines=30, autoscroll=True, show_copy_button=True)
|
|
|
187 |
analysis_output = gr.Textbox(label="Creative Analysis", lines=10, show_copy_button=True)
|
188 |
with gr.TabItem("Post-Processed Analysis"):
|
189 |
post_process_output = gr.Textbox(label="Post-Processed Analysis", lines=10, show_copy_button=True)
|
190 |
+
with gr.TabItem("Market Analysis"):
|
191 |
+
market_output = gr.Textbox(label="Market Analysis", lines=10, show_copy_button=True)
|
192 |
|
193 |
process_btn.click(
|
194 |
fn=process_screenplay,
|
195 |
inputs=[file_input],
|
196 |
+
outputs=[cleaned_output, coverage_btn, analysis_btn, post_process_btn, market_btn, console]
|
197 |
)
|
198 |
|
199 |
coverage_btn.click(
|
|
|
208 |
|
209 |
post_process_btn.click(
|
210 |
fn=post_process_analysis,
|
211 |
+
outputs=[post_process_output, market_btn, console]
|
212 |
+
)
|
213 |
+
|
214 |
+
market_btn.click(
|
215 |
+
fn=generate_market_analysis,
|
216 |
+
outputs=[market_output, console]
|
217 |
)
|
218 |
|
219 |
if __name__ == "__main__":
|