From 704b6407b4e51800376e73fe934a762e94b30d9d Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 14 Oct 2023 04:39:41 -0600 Subject: rebased --- tools/contacts.py | 5 +++-- tools/summarize.py | 32 ++++++++++++++++++++++++++++++++ tools/vocode.py | 15 +++++---------- 3 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 tools/summarize.py (limited to 'tools') diff --git a/tools/contacts.py b/tools/contacts.py index 4f4a3be..afdc8a4 100644 --- a/tools/contacts.py +++ b/tools/contacts.py @@ -9,11 +9,12 @@ import os CONTACTS = [ { "name": "Greg", - "phone" : os.getenv("TEST_PHONE_NUMBER") + "phone" : os.getenv("TEST_PHONE_NUMBER"), + "email": "grsi2038@colorado.edu" } ] @tool("get_all_contacts") def get_all_contacts(placeholder: str) -> List[dict]: - """Returns all contacts in the user's phone book.""" + """Returns all contacts in the user's phone book which includes email and phone numbers.""" return CONTACTS \ No newline at end of file diff --git a/tools/summarize.py b/tools/summarize.py new file mode 100644 index 0000000..d90c49d --- /dev/null +++ b/tools/summarize.py @@ -0,0 +1,32 @@ +import logging +import asyncio +import os +from langchain.agents import tool +from dotenv import load_dotenv + +from langchain.agents.agent_toolkits import GmailToolkit + +from langchain.llms import OpenAI +from langchain.agents import initialize_agent, AgentType + +load_dotenv() +toolkit = GmailToolkit() + +tools = toolkit.get_tools() + +@tool("summarize") +def summarize(input: str) -> bool: + """ + Summarize the response to the input prompt. + """ + prompt = input + + llm = OpenAI(temperature=0) + agent = initialize_agent( + prompt=prompt, + llm=llm, + agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, + ) + + return agent.run(prompt) + diff --git a/tools/vocode.py b/tools/vocode.py index d50c8a3..975cb4c 100644 --- a/tools/vocode.py +++ b/tools/vocode.py @@ -29,8 +29,8 @@ asyncio.set_event_loop(LOOP) @tool("call phone number") def call_phone_number(input: str) -> str: - """Use when you need to make a phone call. Calls a phone number as a bot and returns a transcript of the conversation. - + """calls a phone number as a bot and returns a transcript of the conversation. + make sure you call `get all contacts` first to get a list of phone numbers to call. the input to this tool is a pipe separated list of a phone number, a prompt, and the first thing the bot should say. The prompt should instruct the bot with what to do on the call and be in the 3rd person, like 'the assistant is performing this task' instead of 'perform this task'. @@ -39,7 +39,8 @@ def call_phone_number(input: str) -> str: for example, `+15555555555|the assistant is explaining the meaning of life|i'm going to tell you the meaning of life` will call +15555555555, say 'i'm going to tell you the meaning of life', and instruct the assistant to tell the human what the meaning of life is. """ - phone_number, prompt, initial_message = input.split("|", 2) + phone_number, prompt, initial_message = input.split("|",2) + print(phone_number, prompt, initial_message) call = OutboundCall( base_url=os.environ["BASE_URL"], to_phone=phone_number, @@ -60,10 +61,4 @@ def call_phone_number(input: str) -> str: logger=logging.Logger("OutboundCall"), ) LOOP.run_until_complete(call.start()) - while True: - maybe_transcript = get_transcript(call.conversation_id) - if maybe_transcript: - delete_transcript(call.conversation_id) - return maybe_transcript - else: - time.sleep(1) + return "Call Started" -- cgit v1.2.3