menikev commited on
Commit
ecc0e05
·
verified ·
1 Parent(s): b38937a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
3
  from langchain_core.prompts import PromptTemplate
4
- from langchain_core.runnables import RunnableSequence
5
  from langchain_huggingface import HuggingFacePipeline
6
  from langchain.agents import create_react_agent, AgentExecutor, Tool
7
  from langchain.memory import ConversationBufferMemory
@@ -54,27 +53,34 @@ tools = [
54
  ]
55
 
56
  # Set up the agent
57
- prefix = """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.
 
58
 
59
- You have access to the following tools:"""
60
 
61
- suffix = """Begin!
62
 
63
- {chat_history}
64
- Human: {human_input}
65
- AI: Let's approach this step-by-step:"""
66
 
67
- prompt = PromptTemplate(
68
- template=prefix + "{agent_scratchpad}" + suffix,
69
- input_variables=["human_input", "chat_history", "agent_scratchpad"]
70
- )
 
 
 
 
 
 
71
 
72
- llm_chain = RunnableSequence(prompt, local_llm)
73
- memory = ConversationBufferMemory(memory_key="chat_history")
 
 
74
 
75
  agent = create_react_agent(local_llm, tools, prompt)
76
  agent_executor = AgentExecutor.from_agent_and_tools(
77
- agent=agent, tools=tools, verbose=True, memory=memory
78
  )
79
 
80
  # Streamlit interface
 
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
 
53
  ]
54
 
55
  # Set up the agent
56
+ prompt = PromptTemplate.from_template(
57
+ """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.
58
 
59
+ You have access to the following tools:
60
 
61
+ {tools}
62
 
63
+ Use the following format:
 
 
64
 
65
+ Question: the input question you must answer
66
+ Thought: you should always think about what to do
67
+ Action: the action to take, should be one of [{tool_names}]
68
+ Action Input: the input to the action
69
+ Observation: the result of the action
70
+ ... (this Thought/Action/Action Input/Observation can repeat N times)
71
+ Thought: I now know the final answer
72
+ Final Answer: the final answer to the original input question
73
+
74
+ Begin!
75
 
76
+ Question: {input}
77
+ Thought: Let's approach this step-by-step:
78
+ {agent_scratchpad}"""
79
+ )
80
 
81
  agent = create_react_agent(local_llm, tools, prompt)
82
  agent_executor = AgentExecutor.from_agent_and_tools(
83
+ agent=agent, tools=tools, verbose=True, memory=ConversationBufferMemory()
84
  )
85
 
86
  # Streamlit interface