GattoNero commited on
Commit
962d9a2
·
verified ·
1 Parent(s): 85986f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -20
app.py CHANGED
@@ -89,26 +89,23 @@ class BasicAgent:
89
  print_coso(f"__call__ file_info: {file_info}")
90
 
91
  # Se è presente un file, gestiscilo
92
- if file_info:
93
- file_name = file_info.get("name", "")
94
- file_data = file_info.get("data", "")
95
-
96
- if file_name.endswith((".png", ".jpg", ".jpeg")):
97
- print("coso Image file detected, processing with GPT-4o")
98
- image = self._load_image(file_data)
99
- response = self._ask_gpt4o_with_image(image, text)
100
- return response
101
-
102
- elif file_name.endswith(".wav") or file_name.endswith(".mp3"):
103
- print("coso Audio file detected, processing with Whisper")
104
- audio_bytes = self._load_bytes(file_data)
105
- transcription = self._transcribe_audio(audio_bytes)
106
- return self._ask_gpt4o(transcription)
107
-
108
- elif file_name.endswith(".txt"):
109
- print("coso Text file detected")
110
- text_content = self._load_text(file_data)
111
- return self._ask_gpt4o(text_content)
112
 
113
 
114
  print_coso("nessun file allegato")
 
89
  print_coso(f"__call__ file_info: {file_info}")
90
 
91
  # Se è presente un file, gestiscilo
92
+
93
+ if file_info.endswith((".png", ".jpg", ".jpeg")):
94
+ print("coso Image file detected, processing with GPT-4o")
95
+ image = self._load_image(file_data)
96
+ response = self._ask_gpt4o_with_image(image, text)
97
+ return response
98
+
99
+ elif file_info.endswith(".wav") or file_name.endswith(".mp3"):
100
+ print("coso Audio file detected, processing with Whisper")
101
+ audio_bytes = self._load_bytes(file_data)
102
+ transcription = self._transcribe_audio(audio_bytes)
103
+ return self._ask_gpt4o(transcription)
104
+
105
+ elif file_info.endswith(".txt"):
106
+ print("coso Text file detected")
107
+ text_content = self._load_text(file_data)
108
+ return self._ask_gpt4o(text_content)
 
 
 
109
 
110
 
111
  print_coso("nessun file allegato")