Spaces:
Build error
Build error
Update app.py
Browse files236 unmodified lines237238239240241242243244325 unmodified lines570571572573574575576577578579580581582236 unmodified lines# summarized_response = summarize_document(query_response)return query_response#asyncdef send_email_with_attachment(recipient_email, subject, body, attachment_path):try:from fastapi import FastAPI325 unmodified lines# email sendif len(user_email) > 0:# Send email with the chart image attachedsend_email_with_attachment(recipient_email=user_email,subject="Warehouse Inventory Report",body=response.get("output", "").split(":")[0],# attachment_path=chart_pathattachment_path=os.getenv("IMAGE_PATH"))if "send email to" in user_question:try:236 unmodified lines237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297325 unmodified lines623624625626627628629630631632633634635636637638639640641642643236 unmodified lines# summarized_response = summarize_document(query_response)return query_response#mailjet APIdef send_email_with_attachment_mailjet(recipient_email, subject, body, attachment_path):from mailjet_rest import Clientimport osimport base64# Replace these with your Mailjet API credentialsapi_key = '9ce0aa1f8eb21d9e2ed2433a5702185b'api_secret = '434e366db9b8c421eef99f6f92129fad'# Initialize the Mailjet clientmailjet = Client(auth=(api_key, api_secret), version='v3.1')# Define the email details with an attachmentdata = {'Messages': [{"From": {"Email": "lakshmi.vairamani@redmindtechnologies.com","Name": "Redmind Technologies"},"To": [{"Email": "recipient_email","Name": "Lakshmi"}],"Subject": subject,"TextPart": body,"CustomID": "AppGettingStartedTest","Attachments": [{"ContentType": "image/png", # Replace with the correct MIME type of your image"Filename": "your_image_name.png", # Name of the image as it will appear in the email"Base64Content": attachment_path # Base64-encoded image content}]}]}# Send the emailresult = mailjet.send.create(data=data)print(result)# Check if the email was sent successfullyif result.status_code == 200:print("Email sent successfully with attachment!")else:print(f"Failed to send email. Status code: {result.status_code}")print(result.json())#smtp libdef send_email_with_attachment(recipient_email, subject, body, attachment_path):try:from fastapi import FastAPI325 unmodified lines# email sendif len(user_email) > 0:# Send email with the chart image attachedsend_email_with_attachment_mailjet(recipient_email=user_email,subject="Warehouse Inventory Report",body=response.get("output", "").split(":")[0],# attachment_path=chart_pathattachment_path=img_str))# Send email with the chart image attached"""send_email_with_attachment(recipient_email=user_email,subject="Warehouse Inventory Report",body=response.get("output", "").split(":")[0],# attachment_path=chart_pathattachment_path=os.getenv("IMAGE_PATH"))"""if "send email to" in user_question:try:
app.py+64-3