Update app.py
Browse files
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 |
-
|
|
|
|
| 58 |
|
| 59 |
-
You have access to the following tools:
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
Human: {human_input}
|
| 65 |
-
AI: Let's approach this step-by-step:"""
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
| 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=
|
| 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
|