Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -469,7 +469,7 @@ class IntelligentAgent:
|
|
469 |
|
470 |
return "\n\n" + "="*50 + "\n".join(formatted_content) + "\n" + "="*50
|
471 |
|
472 |
-
def _detect_and_process_direct_attachments(self,
|
473 |
"""
|
474 |
Detect and process attachments that are directly attached to questions (not as URLs).
|
475 |
Returns (image_files, audio_files, code_files)
|
@@ -484,10 +484,7 @@ class IntelligentAgent:
|
|
484 |
# Check for attachments in various fields
|
485 |
attachments = []
|
486 |
|
487 |
-
|
488 |
-
attachment_fields = ['file_name']
|
489 |
-
|
490 |
-
for field in attachment_fields:
|
491 |
if field in question_data:
|
492 |
field_data = question_data[field]
|
493 |
if isinstance(field_data, list):
|
@@ -810,6 +807,7 @@ Answer:"""
|
|
810 |
try:
|
811 |
# Detect and process URLs
|
812 |
print(f"2. Detecting and processing URLs...")
|
|
|
813 |
url_context = self._extract_and_process_urls(question_text)
|
814 |
|
815 |
if self.debug:
|
@@ -820,7 +818,8 @@ Answer:"""
|
|
820 |
try:
|
821 |
# Detect and download attachments
|
822 |
print(f"3. Searching for images, audio or code attachments...")
|
823 |
-
|
|
|
824 |
|
825 |
# Process attachments to get context
|
826 |
attachment_context = self._process_attachments(image_files, audio_files, code_files)
|
|
|
469 |
|
470 |
return "\n\n" + "="*50 + "\n".join(formatted_content) + "\n" + "="*50
|
471 |
|
472 |
+
def _detect_and_process_direct_attachments(self, attachment_name) -> Tuple[List[str], List[str], List[str]]:
|
473 |
"""
|
474 |
Detect and process attachments that are directly attached to questions (not as URLs).
|
475 |
Returns (image_files, audio_files, code_files)
|
|
|
484 |
# Check for attachments in various fields
|
485 |
attachments = []
|
486 |
|
487 |
+
for field in [attachment_name]:
|
|
|
|
|
|
|
488 |
if field in question_data:
|
489 |
field_data = question_data[field]
|
490 |
if isinstance(field_data, list):
|
|
|
807 |
try:
|
808 |
# Detect and process URLs
|
809 |
print(f"2. Detecting and processing URLs...")
|
810 |
+
|
811 |
url_context = self._extract_and_process_urls(question_text)
|
812 |
|
813 |
if self.debug:
|
|
|
818 |
try:
|
819 |
# Detect and download attachments
|
820 |
print(f"3. Searching for images, audio or code attachments...")
|
821 |
+
attachment_name = question_data.get('file_name', '')
|
822 |
+
image_files, audio_files, code_files = self._detect_and_process_direct_attachments(attachment_name)
|
823 |
|
824 |
# Process attachments to get context
|
825 |
attachment_context = self._process_attachments(image_files, audio_files, code_files)
|