Functions
find_task_by_id_function(id)
Finds a task by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The ID of the task to find. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The details of the task, or None if not found. |
Examples:
>>> find_task_by_id_function(1)
"Task Details\nClean the kitchen\nIMPORTANT TASK CREATION TIME: 2020-07-01T12:00:00"
Source code in backend/Multi-Sensory Virtual AAGI/functions/find_task_by_id.py
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
create_task_function()
Creates a task function for an AI assistant.
Returns:
Name | Type | Description |
---|---|---|
str | A string containing the task description, goals, and start time. |
Examples:
>>> create_task_function()
"You are Alex an AI assistant that uses a very Large Language Model.
The user is asking you to perform a task. Write a small description of the task along with the expected goals and any additional information that would be helpful for someone performing this task who has no knowledge of the prior conversation. Clearly mention the start time for the task at the end."
Source code in backend/Multi-Sensory Virtual AAGI/functions/create_task.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
random_thought_function()
Generates a random thought for the AI assistant Alex.
Returns:
Name | Type | Description |
---|---|---|
str | The random thought generated for Alex. |
Side Effects
Loads environment variables from the .env file. Reads from the STATE_DIR environment variable. Reads from the personality.txt, thought_bubble.txt, curiosity.txt, creativity.txt, fear.txt, happiness.txt, sadness.txt, and anger.txt files.
Examples:
>>> random_thought_function()
"What if we could go back in time and watch Leonardo da Vinci paint the Mona Lisa or witness the construction of the pyramids in ancient Egypt? And what about the future?"
Source code in backend/Multi-Sensory Virtual AAGI/functions/random_thought.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
check_success_function(python_script, information, task_details)
Checks if a given task was successful.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
python_script |
str
|
The Python script to be evaluated. |
required |
information |
str
|
The output of the Python script. |
required |
task_details |
str
|
The details of the task. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple | A tuple containing a boolean value and a string. The boolean value indicates if the task was successful, and the string contains the reason for the choice. |
Examples:
>>> check_success_function("from ability_functions.send_email import send_email_function\ndef function(text, receiver):\n send_email_function(text, receiver)\n return "success"\nresponse = function("Hi, i have sent the refund to you!", "Bell")\nwith open("tempfiles/output2792.txt", "w") as f:\n f.write("Result " + response)", "success", "Task details: Send an email to Bell telling him you have sent the refund.")
(True, "The task was successfully completed, Bell has received an email stating that we have sent the refund to him.")
Source code in backend/Multi-Sensory Virtual AAGI/functions/check_success.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
perform_task_function(id)
Performs a task given an id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The id of the task to be performed. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple | A tuple containing the status of the task, the number of seconds to wait for, and the response. |
Examples:
>>> perform_task_function(1)
('done', 0, 'The user has sent an email to John.')
Source code in backend/Multi-Sensory Virtual AAGI/functions/perform_task.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
create_python_script_function(id)
Creates a python script based on the conversation and the tools available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
The id of the conversation. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The python script. |
Examples:
>>> create_python_script_function("2020_08_20_12_00_00")
"import os\nimport sys\n# Get the absolute path to the current directory\ncurrent_dir = os.path.dirname(os.path.abspath(__file__))\n# Add the path to the root directory\nsys.path.append(os.path.join(current_dir, '..'))\n# Import the search_function from the search module, You need to append _function to the name of the tool\nfrom ability_functions.search import search_function\ndef python_function(text):\n # search for relevant information on this topic\n search_response = search_function(text)\n # create an instructions that tells the natural language function to extract the search response and frame it as question\n instructions = "Create a question in words that tells to divide the total amount spent by 10.\nYou can find the total amount spent by analyzing this piece of text\n" + search_response\n # get the question\n question = natural_language_task_function(instructions)\n # pass the question to the calculator function to get the answer\n answer = calculator_function(question)\n # write the result to tempfiles/output{id}.txt file\n with open("tempfiles/output{id}.txt", "w") as f:\n f.write("Search response was " + search_response)\n f.write("After Computation the answer is " + str(answer))\n\n#call the function\npython_function("Total Cost USA Latest Semiconductor Bill")"
Source code in backend/Multi-Sensory Virtual AAGI/functions/create_python_script.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
create_requirements_function(script)
Generates a list of packages for requirements.txt based on a given code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
script |
str
|
The code to generate the list of packages from. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | A list of packages for requirements.txt, or 'empty' if no packages are needed. |
Examples:
>>> create_requirements_function("import numpy as np")
"numpy"
Source code in backend/Multi-Sensory Virtual AAGI/functions/create_requirements.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
check_values_function()
Checks if all values in the emotion files are 0. If so, generates random values between 0 and 1 and writes them to the emotion files.
Returns:
Type | Description |
---|---|
None |
Side Effects
Writes new values to the emotion files.
Examples:
>>> check_values_function()
New values have been written to the Emotion files.
Source code in backend/Multi-Sensory Virtual AAGI/functions/check_values.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
handle_error_function(python_script, requirements, error, id)
Handles errors in python scripts and requirements files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
python_script |
str
|
The python script to be modified. |
required |
requirements |
str
|
The requirements file to be modified. |
required |
error |
str
|
The error message. |
required |
id |
int
|
The id of the conversation. |
required |
Returns:
Name | Type | Description |
---|---|---|
None | No return value. |
Side Effects
Writes modified python script and requirements files to the tempfiles directory.
Examples:
>>> handle_error_function(python_script_template, requirements_template, error_template, 1)
None
Source code in backend/Multi-Sensory Virtual AAGI/functions/handle_error.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
dream_function()
Generates a dream based on the conversation and emotion parameters of the user.
Returns:
Name | Type | Description |
---|---|---|
str | A dream generated by OpenAI's LLMs. |
Examples:
>>> dream_function()
"Ava was exploring a futuristic city filled with skyscrapers, holographic billboards, and flying cars. She was thrilled to see that the city was powered by quantum computing, and robots were everywhere."
Source code in backend/Multi-Sensory Virtual AAGI/functions/dream.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
start_task_message_function(well_defined_task)
Generates a response to a well-defined task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
well_defined_task |
str
|
The task to respond to. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The response to the task. |
Side Effects
Loads environment variables from the .env file.
Examples:
>>> start_task_message_function("Create a new user")
"I have received your task to create a new user. My name is Alex. I will proceed to execute the task accordingly."
Source code in backend/Multi-Sensory Virtual AAGI/functions/start_task_message.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
determine_task_talk_function()
Determines whether a given conversation is a task or talk.
Returns:
Name | Type | Description |
---|---|---|
str | The response from the chatbot. |
Side Effects
Loads environment variables from the .env file. Loads the abilities.json file. Loads the conversation.json file.
Examples:
>>> determine_task_talk_function()
'Talk'
Source code in backend/Multi-Sensory Virtual AAGI/functions/determine_task_talk.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
update_emotion_function(emotion)
Updates the emotion value in the state_of_mind directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emotion |
str
|
The emotion to update. |
required |
Returns:
Type | Description |
---|---|
None |
Side Effects
Writes the updated emotion value to the state_of_mind directory.
Examples:
>>> update_emotion_function('happiness')
None
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_emotions.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
update_emotions_function()
Updates all emotion values in the state_of_mind directory.
Returns:
Type | Description |
---|---|
None |
Side Effects
Writes the updated emotion values to the state_of_mind directory.
Examples:
>>> update_emotions_function()
None
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_emotions.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
summarize(text)
Summarizes a text using OpenAI's GPT-3.5-Turbo model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to summarize. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The summarized text. |
Examples:
>>> summarize("This is a long text.")
"This is a short summary of the text."
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_conversation.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
tiktoken_len(text)
Calculates the length of a text in tokens.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to calculate the length of. |
required |
Returns:
Name | Type | Description |
---|---|---|
int | The length of the text in tokens. |
Examples:
>>> tiktoken_len("Hello world")
2
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_conversation.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
update_conversation_function(user_response, sender, file_path, file_description)
Updates the conversation with a new message and summarizes the conversation if it is too long.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_response |
str
|
The user's response. |
required |
sender |
str
|
The sender of the message. |
required |
file_path |
str
|
The path of the file uploaded by the user. |
required |
file_description |
str
|
The description of the file uploaded by the user. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | An empty string. |
Side Effects
Writes the updated conversation to the conversation.json file.
Examples:
>>> update_conversation_function("Hello!", "User", "", "")
""
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_conversation.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
update_thought_bubble_function()
Updates the thought bubble with a modified version based on a conversation.
Returns:
Type | Description |
---|---|
None |
Side Effects
Writes the modified thought bubble to the file state_of_mind/thought_bubble.txt
Examples:
>>> update_thought_bubble_function()
None
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_thought_bubble.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
file_describe_function(file_path)
Generates a description of a file based on its type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
The path of the file to be described. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | A description of the file. |
Examples:
>>> file_describe_function('example.jpg')
'Image Uploaded. Description of the image.'
Source code in backend/Multi-Sensory Virtual AAGI/functions/file_describe.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
update_task_list_function(well_defined_task, id)
Updates a task list with a new task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
well_defined_task |
str
|
The task to add to the list. |
required |
id |
int
|
The ID of the task. |
required |
Side Effects
Writes the updated task list to a JSON file.
Returns:
Type | Description |
---|---|
None |
Examples:
>>> update_task_list_function("Clean the kitchen", 1)
None
Source code in backend/Multi-Sensory Virtual AAGI/functions/update_task_list.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
talk_function(id)
Talks to an AI assistant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
The ID of the conversation. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The response of the AI assistant. |
Side Effects
Creates a python script, requirements, and output files in the tempfiles directory.
Examples:
>>> talk_function('2020_08_20_12_30_00')
"Hello, how can I help you?"
Source code in backend/Multi-Sensory Virtual AAGI/functions/talk.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
create_python_script_task_function(id)
Creates a python script for a given task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The ID of the task. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The python script for the task. |
Examples:
>>> create_python_script_task_function(1)
'import os\nimport sys\n# Get the absolute path to the current directory\ncurrent_dir = os.path.dirname(os.path.abspath(__file__))\n# Add the path to the root directory\nsys.path.append(os.path.join(current_dir, '..'))\n# Import the search_function from the search module, You need to append _function to the name of the tool\nfrom ability_functions.search import search_function\ndef python_function(text):\n # search for relevant information on this topic\n search_response = search_function(text)\n # create an instructions that tells the natural language function to extract the search response and frame it as question\n instructions = "Create a question in words that tells to divide the total amount spent by 10.\nYou can find the total amount spent by analyzing this piece of text\n" + search_response\n # get the question\n question = natural_language_task_function(instructions)\n # pass the question to the calculator function to get the answer\n answer = calculator_function(question)\n # write the result to tempfiles/output{id}.txt file\n with open("tempfiles/output{id}.txt", "w") as f:\n f.write("Search response was " + search_response)\n f.write("After Computation the answer is " + str(answer))\n#call the function\npython_function("Total Cost USA Latest Semiconductor Bill")'
Source code in backend/Multi-Sensory Virtual AAGI/functions/create_python_script_task.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
mental_simulation_function(id)
Simulates a conversation between Alex and a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The id of the task to be simulated. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The response from the conversation. |
Side Effects
Loads environment variables from the .env file. Loads conversation.json, abilities.json, personality.txt, and thought_bubble.txt from the STATE_DIR.
Examples:
>>> mental_simulation_function(1)
"Alex's response to the conversation."
Source code in backend/Multi-Sensory Virtual AAGI/functions/mental_simulation.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|