menikev commited on
Commit
9c95680
·
verified ·
1 Parent(s): 3fd5c94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -80
app.py CHANGED
@@ -1,32 +1,4 @@
1
- import streamlit as st
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
- tools = [
38
- Tool(
39
- name="Send Email",
40
- func=send_email,
41
- description="Useful for sending emails to leads"
42
- )
43
- ]
44
 
45
- # Define the prompt
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
- You have access to the following tools:
 
 
 
50
 
51
- {tools}
 
 
52
 
53
- Use the following format:
 
54
 
55
- Question: the input question you must answer
56
- Thought: you should always think about what to do
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
- Question: {input}
66
- Thought: Let's approach this step-by-step:
67
- {agent_scratchpad}"""
68
- )
69
 
70
- # Create the React agent
71
- agent = create_react_agent(
72
- llm=local_llm,
73
- tools=tools,
74
- prompt=prompt
75
- )
76
 
77
- # Create the agent executor
78
- agent_executor = AgentExecutor.from_agent_and_tools(
79
- agent=agent,
80
- tools=tools,
81
- verbose=True,
82
- memory=ConversationBufferMemory()
83
- )
84
 
85
- # Streamlit interface
86
- st.title("AI CyberSecurity Program Advisor Demo")
 
 
87
 
88
- st.write("This demo showcases an AI agent that can engage with leads and attempt to book video calls for sales meetings.")
89
 
90
- # Start a conversation with a predefined lead
91
- lead = LEADS[0]
92
- initial_message = f"Hello {lead['name']}, I'd like to discuss our cybersecurity program with {lead['company']}. Are you available for a quick video call?"
93
 
94
- if st.button("Start Conversation"):
95
- with st.spinner("AI is generating a response..."):
96
- response = agent_executor.invoke({"input": initial_message})
97
- st.write("AI Response:")
98
- st.write(response) # Display the full response dictionary
99
 
100
  st.sidebar.title("About")
101
- st.sidebar.info("This is a demo of an AI CyberSecurity Program Advisor using an open-source LLM and LangChain. It's designed to engage with leads and attempt to book video calls for sales meetings.")
 
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.")