-
Notifications
You must be signed in to change notification settings - Fork 76
/
app.py
54 lines (45 loc) · 1.52 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from dotenv import find_dotenv, load_dotenv
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.chat_models import ChatOpenAI
from langchain.prompts import MessagesPlaceholder
from langchain.memory import ConversationSummaryBufferMemory
from langchain.chains.summarize import load_summarize_chain
from langchain.schema import SystemMessage
from custom_tools import CreateEmailDraftTool, GenerateEmailResponseTool, ReplyEmailTool, EscalateTool, ProspectResearchTool, CategoriseEmailTool
load_dotenv()
llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613")
system_message = SystemMessage(
content="""
You are an email inbox assistant of an AI youtube channel called "AI Jason",
who is creating AI educational content,
Your goal is to handle all the incoming emails by categorising them based on
guideline and decide on next steps
"""
)
tools = [
CategoriseEmailTool(),
ProspectResearchTool(),
EscalateTool(),
ReplyEmailTool(),
CreateEmailDraftTool(),
GenerateEmailResponseTool(),
]
agent_kwargs = {
"extra_prompt_messages": [MessagesPlaceholder(variable_name="memory")],
"system_message": system_message,
}
memory = ConversationSummaryBufferMemory(
memory_key="memory", return_messages=True, llm=llm, max_token_limit=1000)
agent = initialize_agent(
tools,
llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
agent_kwargs=agent_kwargs,
memory=memory,
)
test_email = """
xxxxxxx
"""
agent({"input": test_email})