Spaces:
Running
Running
Commit
·
e84c507
1
Parent(s):
4a39e77
Reverting back to old working model.
Browse files- app.py +14 -6
- model/__pycache__/analyzer.cpython-310.pyc +0 -0
- model/analyzer.py +12 -1
app.py
CHANGED
@@ -6,6 +6,16 @@ import httpx
|
|
6 |
import subprocess
|
7 |
import atexit
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Register the exit handler
|
10 |
api_process = start_api_server()
|
11 |
atexit.register(stop_api_server, api_process)
|
@@ -569,10 +579,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
|
|
569 |
""")
|
570 |
|
571 |
if __name__ == "__main__":
|
572 |
-
iface
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
title="Content Trigger Analysis",
|
577 |
-
description="Analyze text content for sensitive topics and trigger warnings"
|
578 |
)
|
|
|
6 |
import subprocess
|
7 |
import atexit
|
8 |
|
9 |
+
# Start the API server
|
10 |
+
def start_api_server():
|
11 |
+
# Start uvicorn in a subprocess
|
12 |
+
process = subprocess.Popen(["uvicorn", "script_search_api:app", "--reload"])
|
13 |
+
return process
|
14 |
+
|
15 |
+
# Stop the API server
|
16 |
+
def stop_api_server(process):
|
17 |
+
process.terminate()
|
18 |
+
|
19 |
# Register the exit handler
|
20 |
api_process = start_api_server()
|
21 |
atexit.register(stop_api_server, api_process)
|
|
|
579 |
""")
|
580 |
|
581 |
if __name__ == "__main__":
|
582 |
+
iface.launch(
|
583 |
+
share=False,
|
584 |
+
debug=True,
|
585 |
+
show_error=True
|
|
|
|
|
586 |
)
|
model/__pycache__/analyzer.cpython-310.pyc
CHANGED
Binary files a/model/__pycache__/analyzer.cpython-310.pyc and b/model/__pycache__/analyzer.cpython-310.pyc differ
|
|
model/analyzer.py
CHANGED
@@ -237,6 +237,7 @@ async def analyze_content(
|
|
237 |
analyzer = ContentAnalyzer()
|
238 |
|
239 |
try:
|
|
|
240 |
triggers = await analyzer.analyze_script(script, progress)
|
241 |
|
242 |
if progress:
|
@@ -260,4 +261,14 @@ async def analyze_content(
|
|
260 |
"model": "google/flan-t5-base",
|
261 |
"analysis_timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
262 |
"error": str(e)
|
263 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
analyzer = ContentAnalyzer()
|
238 |
|
239 |
try:
|
240 |
+
# Fix: Use the analyzer instance's method instead of undefined function
|
241 |
triggers = await analyzer.analyze_script(script, progress)
|
242 |
|
243 |
if progress:
|
|
|
261 |
"model": "google/flan-t5-base",
|
262 |
"analysis_timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
263 |
"error": str(e)
|
264 |
+
}
|
265 |
+
|
266 |
+
if __name__ == "__main__":
|
267 |
+
iface = gr.Interface(
|
268 |
+
fn=analyze_content,
|
269 |
+
inputs=gr.Textbox(lines=8, label="Input Text"),
|
270 |
+
outputs=gr.JSON(),
|
271 |
+
title="Content Trigger Analysis",
|
272 |
+
description="Analyze text content for sensitive topics and trigger warnings"
|
273 |
+
)
|
274 |
+
iface.launch()
|