diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/contacts.py | 7 | ||||
-rw-r--r-- | tools/email_tool.py | 6 | ||||
-rw-r--r-- | tools/get_user_inputs.py | 2 | ||||
-rw-r--r-- | tools/search.py | 1 | ||||
-rw-r--r-- | tools/summarize.py | 20 | ||||
-rw-r--r-- | tools/vocode.py | 19 |
6 files changed, 35 insertions, 20 deletions
diff --git a/tools/contacts.py b/tools/contacts.py index afdc8a4..a37455f 100644 --- a/tools/contacts.py +++ b/tools/contacts.py @@ -11,10 +11,15 @@ CONTACTS = [ "name": "Greg", "phone" : os.getenv("TEST_PHONE_NUMBER"), "email": "grsi2038@colorado.edu" + }, + { + "name": "Hunter", + "phone": "+19178737978", + "email": "hunter.mcrobie@gmail.com" } ] @tool("get_all_contacts") -def get_all_contacts(placeholder: str) -> List[dict]: +def get_all_contacts(contact_name: str) -> List[dict]: """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/email_tool.py b/tools/email_tool.py index 932a7e5..da2f072 100644 --- a/tools/email_tool.py +++ b/tools/email_tool.py @@ -14,6 +14,9 @@ toolkit = GmailToolkit() tools = toolkit.get_tools() +my_information = "Use this information whenever needed User information " + open("info.txt").read() + " . Your task " + + @tool("email tasks") def email_tasks(input: str) -> bool: """draft/send/search/get email and return whatever you get. @@ -27,7 +30,8 @@ def email_tasks(input: str) -> bool: for example, `send an email to grsi2038@colorado.edu asking him if he is still looking for a job and that he should continue doing whatever he his doing because he will eventually find it` will email grsi2038@colorado.edu """ - prompt = input + prompt = my_information + input + #print(input) llm = OpenAI(temperature=0) agent = initialize_agent( diff --git a/tools/get_user_inputs.py b/tools/get_user_inputs.py index 3b59a3a..e219bab 100644 --- a/tools/get_user_inputs.py +++ b/tools/get_user_inputs.py @@ -16,7 +16,7 @@ INPUTS = {} @tool("get_desired_inputs") def get_desired_inputs(input: str) -> dict: - """ + """Use this between tools to get the desired inputs for the next tool. You will be given a task that will be performed by an autonomous agent on behalf of a user. You will gather any necessary data from the user to complete the specified task before executing the task. """ diff --git a/tools/search.py b/tools/search.py new file mode 100644 index 0000000..5355513 --- /dev/null +++ b/tools/search.py @@ -0,0 +1 @@ +from langchain.utilities import SerpAPIWrapper
\ No newline at end of file diff --git a/tools/summarize.py b/tools/summarize.py index d90c49d..fa0bf44 100644 --- a/tools/summarize.py +++ b/tools/summarize.py @@ -4,29 +4,25 @@ 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 +from langchain.prompts.prompt import PromptTemplate -load_dotenv() -toolkit = GmailToolkit() -tools = toolkit.get_tools() +load_dotenv() @tool("summarize") def summarize(input: str) -> bool: """ Summarize the response to the input prompt. """ - prompt = input + data = input llm = OpenAI(temperature=0) - agent = initialize_agent( - prompt=prompt, - llm=llm, - agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, - ) - return agent.run(prompt) + template = "Human: Can you summarize this in a couple of sentences: {data}" + prompt = PromptTemplate(input_variables=["data"], template=template) + pred = llm.predict(prompt.format(data=data)) + return pred + #preferred_forums[make] = [make_url] diff --git a/tools/vocode.py b/tools/vocode.py index 975cb4c..496bc54 100644 --- a/tools/vocode.py +++ b/tools/vocode.py @@ -11,6 +11,8 @@ from vocode.streaming.models.transcriber import ( PunctuationEndpointingConfig, ) +from vocode.streaming.models.telephony import TwilioConfig + load_dotenv() @@ -26,18 +28,19 @@ import time LOOP = asyncio.new_event_loop() asyncio.set_event_loop(LOOP) +my_information = "Use this information whenever needed User information " + open("info.txt").read() + " . Your task " @tool("call phone number") def call_phone_number(input: str) -> str: - """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. Verifies the phone number from the user before calling. 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 input to this tool is a pipe separated list of a phone number, a prompt (including history), 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'. - should only use this tool once it has found an adequate phone number to call. + e.g. phone_number|prompt|initial_message - 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. + should only use this tool once it has found and verified adequate phone number to call. """ phone_number, prompt, initial_message = input.split("|",2) print(phone_number, prompt, initial_message) @@ -48,9 +51,15 @@ def call_phone_number(input: str) -> str: config_manager=RedisConfigManager(), agent_config=ChatGPTAgentConfig( initial_message=BaseMessage(text=initial_message), - prompt_preamble=prompt, + prompt_preamble=my_information + prompt, generate_responses=True, + allow_agent_to_be_cut_off=False ), + twilio_config=TwilioConfig( + account_sid=os.environ["TWILIO_ACCOUNT_SID"], + auth_token=os.environ["TWILIO_AUTH_TOKEN"], + record=True + ), synthesizer_config=ElevenLabsSynthesizerConfig.from_telephone_output_device( api_key=os.getenv("ELEVENLABS_API_KEY"), voice_id=os.getenv("ELEVENLABS_VOICE_ID"), |