Update app.py
Browse files
app.py
CHANGED
@@ -83,9 +83,15 @@ def generate_email_content(api_key, prompt):
|
|
83 |
max_tokens=1024,
|
84 |
stream=False # Disable streaming for simplicity
|
85 |
)
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
except Exception as e:
|
90 |
logging.error(f"Error generating email content: {e}")
|
91 |
return "Error generating email content."
|
|
|
83 |
max_tokens=1024,
|
84 |
stream=False # Disable streaming for simplicity
|
85 |
)
|
86 |
+
|
87 |
+
# Access the response content correctly based on the Nvidia API structure
|
88 |
+
if hasattr(response, 'choices') and len(response.choices) > 0:
|
89 |
+
email_content = response.choices[0].message.content
|
90 |
+
logging.info("Email content generated successfully.")
|
91 |
+
return email_content
|
92 |
+
else:
|
93 |
+
logging.error("Error: No choices found in the response.")
|
94 |
+
return "Error generating email content: No valid choices."
|
95 |
except Exception as e:
|
96 |
logging.error(f"Error generating email content: {e}")
|
97 |
return "Error generating email content."
|