-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cf479e
commit 0f1228a
Showing
6 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
Oops, something went wrong.