Spaces:
Running
Running
File size: 1,171 Bytes
f7506e5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from agents import Agent, function_tool, ModelSettings
from messenger import send_email, push
import os
from dotenv import load_dotenv
load_dotenv(override=True)
MODEL_NAME = os.getenv("DEFAULT_MODEL_NAME", "gpt-5.4-mini")
USE_EMAIL = os.getenv("USE_EMAIL", "true").lower() == "true"
settings = ModelSettings(tool_choice="required")
@function_tool
def send_email_tool(subject: str, text_body: str, html_body: str) -> str:
"""
Send out an email with the given subject and body to all sales prospects
Args:
subject: The subject of the email
text_body: The body of the email as plain text
html_body: The HTML body of the email
"""
if USE_EMAIL:
send_email(subject, text_body, html_body)
else:
push(f"Subject: {subject}\n\n{text_body}")
return "Email sent successfully"
INSTRUCTIONS = """
You are provided with a detailed report. Use your tool to send an email, converting the report into
a clean, well presented HTML email with an appropriate subject line.
"""
email_agent = Agent(name="Email Agent", instructions=INSTRUCTIONS, tools=[send_email_tool], model=MODEL_NAME, model_settings=settings) |