Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,4 @@
|
|
1 |
-
|
2 |
-
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
3 |
-
from langchain_core.prompts import PromptTemplate
|
4 |
-
from langchain_huggingface import HuggingFacePipeline
|
5 |
-
from langchain.agents import create_react_agent, AgentExecutor, Tool
|
6 |
-
from langchain.memory import ConversationBufferMemory
|
7 |
-
|
8 |
-
# Mock lead data
|
9 |
-
LEADS = [
|
10 |
-
{"name": "John Doe", "email": "[email protected]", "company": "TechCorp"},
|
11 |
-
]
|
12 |
-
|
13 |
-
# Set up the open-source LLM
|
14 |
-
@st.cache_resource
|
15 |
-
def load_model():
|
16 |
-
model_name = "google/flan-t5-large"
|
17 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
18 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
19 |
-
pipe = pipeline(
|
20 |
-
"text2text-generation",
|
21 |
-
model=model,
|
22 |
-
tokenizer=tokenizer,
|
23 |
-
max_length=512
|
24 |
-
)
|
25 |
-
return HuggingFacePipeline(pipeline=pipe)
|
26 |
-
|
27 |
-
local_llm = load_model()
|
28 |
-
|
29 |
-
# Define the tools for the agent
|
30 |
def send_email(to_email, subject, body):
|
31 |
# For demo purposes, we'll just print the email details
|
32 |
st.write(f"Email sent to: {to_email}")
|
@@ -34,68 +6,55 @@ def send_email(to_email, subject, body):
|
|
34 |
st.write(f"Body: {body}")
|
35 |
return "Email sent successfully"
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
name="Send Email",
|
40 |
-
func=send_email,
|
41 |
-
description="Useful for sending emails to leads"
|
42 |
-
)
|
43 |
-
]
|
44 |
|
45 |
-
|
46 |
-
prompt = PromptTemplate.from_template(
|
47 |
-
"""You are an AI CyberSecurity Program Advisor. Your goal is to engage with leads and get them to book a video call for an in-person sales meeting. You have access to a list of leads and can send emails.
|
48 |
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
-
|
|
|
|
|
52 |
|
53 |
-
|
|
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
Action: the action to take, should be one of [{tool_names}]
|
58 |
-
Action Input: the input to the action
|
59 |
-
Observation: the result of the action
|
60 |
-
... (this Thought/Action/Action Input/Observation can repeat N times)
|
61 |
-
Thought: I now know the final answer
|
62 |
-
Final Answer: [Insert your final response here]
|
63 |
-
Begin!
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
)
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
agent_executor = AgentExecutor.from_agent_and_tools(
|
79 |
-
agent=agent,
|
80 |
-
tools=tools,
|
81 |
-
verbose=True,
|
82 |
-
memory=ConversationBufferMemory()
|
83 |
-
)
|
84 |
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
st.
|
99 |
|
100 |
st.sidebar.title("About")
|
101 |
-
st.sidebar.info("This is a demo of an AI CyberSecurity Program Advisor
|
|
|
1 |
+
# Mock function to send an email
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
def send_email(to_email, subject, body):
|
3 |
# For demo purposes, we'll just print the email details
|
4 |
st.write(f"Email sent to: {to_email}")
|
|
|
6 |
st.write(f"Body: {body}")
|
7 |
return "Email sent successfully"
|
8 |
|
9 |
+
# Streamlit interface
|
10 |
+
st.title("AI CyberSecurity Program Advisor")
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
st.write("Welcome! Please provide your details to schedule a video call to discuss our cybersecurity program.")
|
|
|
|
|
13 |
|
14 |
+
# Collect user information
|
15 |
+
name = st.text_input("Your Name")
|
16 |
+
email = st.text_input("Your Email Address")
|
17 |
+
preferred_date = st.date_input("Preferred Date for the Video Call")
|
18 |
|
19 |
+
# Zoom meeting details
|
20 |
+
zoom_link = """
|
21 |
+
Lawrence Emenike is inviting you to a scheduled Zoom meeting.
|
22 |
|
23 |
+
Topic: Lawrence Emenike's Zoom Meeting
|
24 |
+
Time: Aug 10, 2024 05:00 PM West Central Africa
|
25 |
|
26 |
+
Join Zoom Meeting
|
27 |
+
https://us04web.zoom.us/j/73793374638?pwd=S0TEJ30da7dhQ8viOdafMzPfCVzoLJ.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
Meeting ID: 737 9337 4638
|
30 |
+
Passcode: 9cNPkn
|
31 |
+
"""
|
|
|
32 |
|
33 |
+
if st.button("Schedule Video Call"):
|
34 |
+
if name and email and preferred_date:
|
35 |
+
# Compose the email
|
36 |
+
subject = "Invitation to Discuss Cybersecurity Program"
|
37 |
+
body = f"""
|
38 |
+
Hi {name},
|
39 |
|
40 |
+
Thank you for your interest in our cybersecurity program. We would like to invite you to a video call to discuss how our program can benefit your organization.
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
Here are the details:
|
43 |
+
|
44 |
+
Preferred Date: {preferred_date}
|
45 |
+
Zoom Meeting Link: {zoom_link}
|
46 |
|
47 |
+
Looking forward to our discussion!
|
48 |
|
49 |
+
Best regards,
|
50 |
+
Lawrence Emenike
|
51 |
+
"""
|
52 |
|
53 |
+
# Send the email
|
54 |
+
send_email(email, subject, body)
|
55 |
+
st.success("Your video call has been scheduled, and an email has been sent!")
|
56 |
+
else:
|
57 |
+
st.error("Please fill in all the required fields.")
|
58 |
|
59 |
st.sidebar.title("About")
|
60 |
+
st.sidebar.info("This is a demo of an AI CyberSecurity Program Advisor. It's designed to help you schedule a video call to discuss our cybersecurity program.")
|