diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-14 04:39:41 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-14 04:39:41 -0600 |
commit | 704b6407b4e51800376e73fe934a762e94b30d9d (patch) | |
tree | f51b5c0bd74abd7b836746f3f2222d282bbd541e /tools | |
parent | d433b974d9f15f9a7ab57ba592a4858e7977726d (diff) |
rebased
Diffstat (limited to 'tools')
-rw-r--r-- | tools/contacts.py | 5 | ||||
-rw-r--r-- | tools/summarize.py | 32 | ||||
-rw-r--r-- | tools/vocode.py | 15 |
3 files changed, 40 insertions, 12 deletions
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" |