Spaces:
Sleeping
Sleeping
Upload streamlit_app.py
Browse files- streamlit_app.py +22 -18
streamlit_app.py
CHANGED
|
@@ -1785,6 +1785,9 @@ class EnhancedOpenAIProcessor:
|
|
| 1785 |
|
| 1786 |
if not self.is_available():
|
| 1787 |
return f"OpenAI client not available: {self._initialization_error}"
|
|
|
|
|
|
|
|
|
|
| 1788 |
|
| 1789 |
try:
|
| 1790 |
# Retrieve relevant documents
|
|
@@ -1851,10 +1854,11 @@ class EnhancedOpenAIProcessor:
|
|
| 1851 |
error_msg = f"API call failed: {str(api_error)}"
|
| 1852 |
logger.error(error_msg)
|
| 1853 |
return f"Error: {error_msg}"
|
| 1854 |
-
|
| 1855 |
-
|
| 1856 |
-
|
| 1857 |
-
|
|
|
|
| 1858 |
def __init__(self, api_key: str):
|
| 1859 |
self._api_key = api_key
|
| 1860 |
self.client = None
|
|
@@ -2283,7 +2287,7 @@ class EnhancedCreativeJobProcessor:
|
|
| 2283 |
return {}
|
| 2284 |
|
| 2285 |
return {
|
| 2286 |
-
'total_jobs': self.dataset_analysis.get('total_jobs', 0),
|
| 2287 |
'columns': list(self.processed_df.columns) if self.processed_df is not None else [],
|
| 2288 |
'analysis_results': self.dataset_analysis,
|
| 2289 |
'qa_answers': self.qa_answers,
|
|
@@ -2368,24 +2372,24 @@ class EnhancedCreativeJobProcessor:
|
|
| 2368 |
|
| 2369 |
try:
|
| 2370 |
summary = {
|
| 2371 |
-
'total_jobs': self.dataset_analysis.get('total_jobs', 0),
|
| 2372 |
'role_counts': {
|
| 2373 |
-
'designers': self.dataset_analysis.get('role_analysis', {}).get('designer_count', 0),
|
| 2374 |
-
'video_professionals': self.dataset_analysis.get('role_analysis', {}).get('video_professional_count', 0),
|
| 2375 |
-
'photo_professionals': self.dataset_analysis.get('role_analysis', {}).get('photo_professional_count', 0)
|
| 2376 |
},
|
| 2377 |
'software_counts': {
|
| 2378 |
-
'adobe_only': self.dataset_analysis.get('adobe_analysis', {}).get('adobe_only_count', 0),
|
| 2379 |
-
'non_adobe_only': self.dataset_analysis.get('adobe_analysis', {}).get('non_adobe_only_count', 0),
|
| 2380 |
-
'both_adobe_non_adobe': self.dataset_analysis.get('adobe_analysis', {}).get('both_apps_count', 0),
|
| 2381 |
-
'ai_tools': self.dataset_analysis.get('ai_tools_analysis', {}).get('ai_tools_count', 0)
|
| 2382 |
},
|
| 2383 |
-
'top_adobe_apps': self.dataset_analysis.get('software_analysis', {}).get('adobe_apps_frequency', Counter()).most_common(5),
|
| 2384 |
-
'top_non_adobe_apps': self.dataset_analysis.get('software_analysis', {}).get('non_adobe_apps_frequency', Counter()).most_common(5),
|
| 2385 |
'cross_disciplinary': {
|
| 2386 |
-
'non_video_with_video_tools': self.dataset_analysis.get('cross_disciplinary_analysis', {}).get('non_video_with_video_tools_count', 0),
|
| 2387 |
-
'non_photo_with_photo_tools': self.dataset_analysis.get('cross_disciplinary_analysis', {}).get('non_photo_with_photo_tools_count', 0),
|
| 2388 |
-
'non_design_with_design_tools': self.dataset_analysis.get('cross_disciplinary_analysis', {}).get('non_design_with_design_tools_count', 0)
|
| 2389 |
},
|
| 2390 |
'persistence_info': {
|
| 2391 |
'backend': self.vector_store.get_stats().get('backend', 'unknown'),
|
|
|
|
| 1785 |
|
| 1786 |
if not self.is_available():
|
| 1787 |
return f"OpenAI client not available: {self._initialization_error}"
|
| 1788 |
+
|
| 1789 |
+
# Ensure dataset_analysis is a dict to avoid NoneType errors
|
| 1790 |
+
dataset_analysis = dataset_analysis or {}
|
| 1791 |
|
| 1792 |
try:
|
| 1793 |
# Retrieve relevant documents
|
|
|
|
| 1854 |
error_msg = f"API call failed: {str(api_error)}"
|
| 1855 |
logger.error(error_msg)
|
| 1856 |
return f"Error: {error_msg}"
|
| 1857 |
+
|
| 1858 |
+
except Exception as e:
|
| 1859 |
+
logger.error(f"Error in enhanced RAG query: {e}")
|
| 1860 |
+
return f"Processing error: {str(e)}"
|
| 1861 |
+
|
| 1862 |
def __init__(self, api_key: str):
|
| 1863 |
self._api_key = api_key
|
| 1864 |
self.client = None
|
|
|
|
| 2287 |
return {}
|
| 2288 |
|
| 2289 |
return {
|
| 2290 |
+
'total_jobs': (self.dataset_analysis or {}).get('total_jobs', 0),
|
| 2291 |
'columns': list(self.processed_df.columns) if self.processed_df is not None else [],
|
| 2292 |
'analysis_results': self.dataset_analysis,
|
| 2293 |
'qa_answers': self.qa_answers,
|
|
|
|
| 2372 |
|
| 2373 |
try:
|
| 2374 |
summary = {
|
| 2375 |
+
'total_jobs': (self.dataset_analysis or {}).get('total_jobs', 0),
|
| 2376 |
'role_counts': {
|
| 2377 |
+
'designers': (self.dataset_analysis or {}).get('role_analysis', {}).get('designer_count', 0),
|
| 2378 |
+
'video_professionals': (self.dataset_analysis or {}).get('role_analysis', {}).get('video_professional_count', 0),
|
| 2379 |
+
'photo_professionals': (self.dataset_analysis or {}).get('role_analysis', {}).get('photo_professional_count', 0)
|
| 2380 |
},
|
| 2381 |
'software_counts': {
|
| 2382 |
+
'adobe_only': (self.dataset_analysis or {}).get('adobe_analysis', {}).get('adobe_only_count', 0),
|
| 2383 |
+
'non_adobe_only': (self.dataset_analysis or {}).get('adobe_analysis', {}).get('non_adobe_only_count', 0),
|
| 2384 |
+
'both_adobe_non_adobe': (self.dataset_analysis or {}).get('adobe_analysis', {}).get('both_apps_count', 0),
|
| 2385 |
+
'ai_tools': (self.dataset_analysis or {}).get('ai_tools_analysis', {}).get('ai_tools_count', 0)
|
| 2386 |
},
|
| 2387 |
+
'top_adobe_apps': (self.dataset_analysis or {}).get('software_analysis', {}).get('adobe_apps_frequency', Counter()).most_common(5),
|
| 2388 |
+
'top_non_adobe_apps': (self.dataset_analysis or {}).get('software_analysis', {}).get('non_adobe_apps_frequency', Counter()).most_common(5),
|
| 2389 |
'cross_disciplinary': {
|
| 2390 |
+
'non_video_with_video_tools': (self.dataset_analysis or {}).get('cross_disciplinary_analysis', {}).get('non_video_with_video_tools_count', 0),
|
| 2391 |
+
'non_photo_with_photo_tools': (self.dataset_analysis or {}).get('cross_disciplinary_analysis', {}).get('non_photo_with_photo_tools_count', 0),
|
| 2392 |
+
'non_design_with_design_tools': (self.dataset_analysis or {}).get('cross_disciplinary_analysis', {}).get('non_design_with_design_tools_count', 0)
|
| 2393 |
},
|
| 2394 |
'persistence_info': {
|
| 2395 |
'backend': self.vector_store.get_stats().get('backend', 'unknown'),
|