Skip to content

Instantly share code, notes, and snippets.

@pavlovmilen
Created May 13, 2025 08:20
Show Gist options
  • Save pavlovmilen/e3d9c834220daced8bcbd598d5b9efcd to your computer and use it in GitHub Desktop.
Save pavlovmilen/e3d9c834220daced8bcbd598d5b9efcd to your computer and use it in GitHub Desktop.
upload_ai_report function
import os
from azure.storage.blob import BlobServiceClient
from datetime import datetime
from dotenv import load_dotenv
load_dotenv()
connection_string = os.getenv('storage_connection_string')
def upload_ai_report(report_summary: str, ticker: str):
"""
Uploads a summary to Azure Blob Storage.
Args:
summary (str): The summary to upload.
ticker (str): The ticker symbol.
"""
print("Uploading summary...")
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
summary_container = 'agent-reports'
summary_container_client = blob_service_client.get_container_client(summary_container)
# Create timestamp in format YYYYMMDD_HHMMSS
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
blob_name = f'{ticker}_{timestamp}_summary.txt'
blob_client = summary_container_client.get_blob_client(blob_name)
blob_client.upload_blob(report_summary, overwrite=True)
print(f"Summary uploaded as '{blob_name}'.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment