n0v33n
commited on
Commit
·
c6123ec
1
Parent(s):
df0e7d9
Resolving Timeout error
Browse files
agent.py
CHANGED
@@ -23,7 +23,7 @@ class AnalysisDescription(BaseModel):
|
|
23 |
metadata: Dict[str, Any]
|
24 |
confidence_score: float
|
25 |
|
26 |
-
MODEL = "mistral-
|
27 |
|
28 |
def play_wav(url: str, save_path: str = "/tmp/audio.wav"):
|
29 |
try:
|
@@ -242,9 +242,15 @@ def simulate_analyze_json_data(json_data: Dict[str, Any], analysis_type: str = "
|
|
242 |
def simulate_text_to_speech(text: str, voice_settings: Dict[str, Any] = None) -> str:
|
243 |
print(f"Converting to speech: {text[:100]}...")
|
244 |
save_path = "/tmp/generated_speech.wav"
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
|
249 |
async def process_document_workflow(client: Mistral, file_path: str, document_type: str = "climate_report"):
|
250 |
print("Starting document processing workflow...")
|
|
|
23 |
metadata: Dict[str, Any]
|
24 |
confidence_score: float
|
25 |
|
26 |
+
MODEL = "mistral-large-latest"
|
27 |
|
28 |
def play_wav(url: str, save_path: str = "/tmp/audio.wav"):
|
29 |
try:
|
|
|
242 |
def simulate_text_to_speech(text: str, voice_settings: Dict[str, Any] = None) -> str:
|
243 |
print(f"Converting to speech: {text[:100]}...")
|
244 |
save_path = "/tmp/generated_speech.wav"
|
245 |
+
try:
|
246 |
+
tts = gTTS(text=text, lang="en")
|
247 |
+
tts.save(save_path)
|
248 |
+
if not os.path.exists(save_path):
|
249 |
+
raise FileNotFoundError(f"Failed to save audio to {save_path}")
|
250 |
+
return f"file://{os.path.abspath(save_path)}"
|
251 |
+
except Exception as e:
|
252 |
+
print(f"Error generating speech: {str(e)}")
|
253 |
+
return f"Error: {str(e)}"
|
254 |
|
255 |
async def process_document_workflow(client: Mistral, file_path: str, document_type: str = "climate_report"):
|
256 |
print("Starting document processing workflow...")
|
app.py
CHANGED
@@ -29,6 +29,11 @@ def initialize_client_and_agents(api_key: str):
|
|
29 |
"json_analyzer_agent_id": json_analyzer_agent.id,
|
30 |
"speech_agent_id": speech_agent.id
|
31 |
}
|
|
|
|
|
|
|
|
|
|
|
32 |
except Exception as e:
|
33 |
return None, f"Error initializing client: {str(e)}"
|
34 |
return client, agents
|
@@ -241,4 +246,4 @@ with gr.Blocks(css=custom_css) as demo:
|
|
241 |
)
|
242 |
|
243 |
if __name__ == "__main__":
|
244 |
-
demo.launch()
|
|
|
29 |
"json_analyzer_agent_id": json_analyzer_agent.id,
|
30 |
"speech_agent_id": speech_agent.id
|
31 |
}
|
32 |
+
print("Agents initialized successfully.")
|
33 |
+
print(f"Document Agent ID: {doc_agent.id}")
|
34 |
+
print(f"Image Agent ID: {image_agent.id}")
|
35 |
+
print(f"JSON Analyzer Agent ID: {json_analyzer_agent.id}")
|
36 |
+
print(f"Speech Agent ID: {speech_agent.id}")
|
37 |
except Exception as e:
|
38 |
return None, f"Error initializing client: {str(e)}"
|
39 |
return client, agents
|
|
|
246 |
)
|
247 |
|
248 |
if __name__ == "__main__":
|
249 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|