Skip to content

Commit

Permalink
email inbox agent
Browse files Browse the repository at this point in the history
  • Loading branch information
JayZeeDesign committed Nov 2, 2023
1 parent 6cf479e commit 0f1228a
Show file tree
Hide file tree
Showing 6 changed files with 728 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.env
__pycache__/custom_tools.cpython-310.pyc
email_pairs.csv
faq.csv
past_email_mbox.csv
Sent.mbox
54 changes: 54 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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})
Loading

0 comments on commit 0f1228a

Please sign in to comment.