Update app.py
Browse files
app.py
CHANGED
@@ -28,6 +28,9 @@ def load_model():
|
|
28 |
|
29 |
local_llm = load_model()
|
30 |
|
|
|
|
|
|
|
31 |
# Define the tools for the agent
|
32 |
def search_leads(query):
|
33 |
results = [lead for lead in LEADS if query.lower() in lead['name'].lower()]
|
@@ -53,7 +56,7 @@ tools = [
|
|
53 |
)
|
54 |
]
|
55 |
|
56 |
-
#
|
57 |
prompt = PromptTemplate.from_template(
|
58 |
"""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.
|
59 |
|
@@ -70,7 +73,7 @@ Action Input: the input to the action
|
|
70 |
Observation: the result of the action
|
71 |
... (this Thought/Action/Action Input/Observation can repeat N times)
|
72 |
Thought: I now know the final answer
|
73 |
-
Final Answer:
|
74 |
Begin!
|
75 |
|
76 |
Question: {input}
|
@@ -78,13 +81,14 @@ Thought: Let's approach this step-by-step:
|
|
78 |
{agent_scratchpad}"""
|
79 |
)
|
80 |
|
|
|
81 |
agent = create_react_agent(
|
82 |
llm=local_llm,
|
83 |
tools=tools,
|
84 |
prompt=prompt
|
85 |
)
|
86 |
|
87 |
-
# Create the agent executor
|
88 |
agent_executor = AgentExecutor.from_agent_and_tools(
|
89 |
agent=agent,
|
90 |
tools=tools,
|
@@ -113,7 +117,8 @@ if lead_name:
|
|
113 |
with st.spinner("AI is generating a response..."):
|
114 |
response = agent_executor.run(initial_message)
|
115 |
st.write("AI Response:")
|
116 |
-
st.write(response) # The response should be the final output
|
|
|
117 |
|
118 |
|
119 |
st.sidebar.title("About")
|
|
|
28 |
|
29 |
local_llm = load_model()
|
30 |
|
31 |
+
|
32 |
+
from langchain.agents import create_react_agent, AgentExecutor, Tool
|
33 |
+
|
34 |
# Define the tools for the agent
|
35 |
def search_leads(query):
|
36 |
results = [lead for lead in LEADS if query.lower() in lead['name'].lower()]
|
|
|
56 |
)
|
57 |
]
|
58 |
|
59 |
+
# Define the prompt without needing an explicit output key
|
60 |
prompt = PromptTemplate.from_template(
|
61 |
"""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.
|
62 |
|
|
|
73 |
Observation: the result of the action
|
74 |
... (this Thought/Action/Action Input/Observation can repeat N times)
|
75 |
Thought: I now know the final answer
|
76 |
+
Final Answer: [Insert your final response here]
|
77 |
Begin!
|
78 |
|
79 |
Question: {input}
|
|
|
81 |
{agent_scratchpad}"""
|
82 |
)
|
83 |
|
84 |
+
# Create the React agent (output_key is removed)
|
85 |
agent = create_react_agent(
|
86 |
llm=local_llm,
|
87 |
tools=tools,
|
88 |
prompt=prompt
|
89 |
)
|
90 |
|
91 |
+
# Create the agent executor
|
92 |
agent_executor = AgentExecutor.from_agent_and_tools(
|
93 |
agent=agent,
|
94 |
tools=tools,
|
|
|
117 |
with st.spinner("AI is generating a response..."):
|
118 |
response = agent_executor.run(initial_message)
|
119 |
st.write("AI Response:")
|
120 |
+
st.write(response) # The response should now directly be the final output
|
121 |
+
|
122 |
|
123 |
|
124 |
st.sidebar.title("About")
|