Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .gitignore +3 -0
- .idea/.gitignore +8 -0
- .idea/conversational_uav_explorer.iml +11 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- .idea/workspace.xml +225 -0
- README.md +3 -9
- __pycache__/app.cpython-311.pyc +0 -0
- __pycache__/chatgpt4uavs.cpython-311.pyc +0 -0
- __pycache__/fewshot.cpython-311.pyc +0 -0
- __pycache__/maps.cpython-311.pyc +0 -0
- __pycache__/prompts.cpython-311.pyc +0 -0
- app.py +62 -0
- chatgpt4uavs.py +63 -0
- commands.txt +1 -0
- fewshot.py +62 -0
- flagged/audio/1b4e7759ac1ceebefc089ec30abaf61b720de43b/tmpgvgxcf4v.wav +0 -0
- flagged/log.csv +6 -0
- maps.py +66 -0
- prompts.py +236 -0
- rasa_bot/actions/__init__.py +0 -0
- rasa_bot/actions/actions.py +61 -0
- rasa_bot/config.yml +48 -0
- rasa_bot/credentials.yml +33 -0
- rasa_bot/data/nlu.yml +100 -0
- rasa_bot/data/rules.yml +39 -0
- rasa_bot/data/stories.yml +2 -0
- rasa_bot/domain.yml +89 -0
- rasa_bot/endpoints.yml +42 -0
- rasa_bot/index.html +2 -0
- rasa_bot/tests/test_stories.yml +91 -0
- test/.pytest_cache/.gitignore +2 -0
- test/.pytest_cache/CACHEDIR.TAG +4 -0
- test/.pytest_cache/README.md +8 -0
- test/.pytest_cache/v/cache/lastfailed +23 -0
- test/.pytest_cache/v/cache/nodeids +56 -0
- test/.pytest_cache/v/cache/stepwise +1 -0
- test/__pycache__/test_chatgpt4uavs.cpython-311-pytest-7.4.0.pyc +0 -0
- test/__pycache__/test_fewshot.cpython-311-pytest-7.4.0.pyc +0 -0
- test/commands.txt +3 -0
- test/test_chatgpt4uavs.py +95 -0
- test/test_fewshot.py +221 -0
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
.rasa
|
| 3 |
+
*.tar.gz
|
.idea/.gitignore
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Default ignored files
|
| 2 |
+
/shelf/
|
| 3 |
+
/workspace.xml
|
| 4 |
+
# Editor-based HTTP Client requests
|
| 5 |
+
/httpRequests/
|
| 6 |
+
# Datasource local storage ignored files
|
| 7 |
+
/dataSources/
|
| 8 |
+
/dataSources.local.xml
|
.idea/conversational_uav_explorer.iml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<module type="PYTHON_MODULE" version="4">
|
| 3 |
+
<component name="NewModuleRootManager">
|
| 4 |
+
<content url="file://$MODULE_DIR$" />
|
| 5 |
+
<orderEntry type="inheritedJdk" />
|
| 6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
| 7 |
+
</component>
|
| 8 |
+
<component name="TestRunnerService">
|
| 9 |
+
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
| 10 |
+
</component>
|
| 11 |
+
</module>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<component name="InspectionProjectProfileManager">
|
| 2 |
+
<settings>
|
| 3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
| 4 |
+
<version value="1.0" />
|
| 5 |
+
</settings>
|
| 6 |
+
</component>
|
.idea/misc.xml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
| 4 |
+
</project>
|
.idea/modules.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="ProjectModuleManager">
|
| 4 |
+
<modules>
|
| 5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/conversational_uav_explorer.iml" filepath="$PROJECT_DIR$/.idea/conversational_uav_explorer.iml" />
|
| 6 |
+
</modules>
|
| 7 |
+
</component>
|
| 8 |
+
</project>
|
.idea/vcs.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="VcsDirectoryMappings">
|
| 4 |
+
<mapping directory="" vcs="Git" />
|
| 5 |
+
</component>
|
| 6 |
+
</project>
|
.idea/workspace.xml
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="AutoImportSettings">
|
| 4 |
+
<option name="autoReloadType" value="SELECTIVE" />
|
| 5 |
+
</component>
|
| 6 |
+
<component name="ChangeListManager">
|
| 7 |
+
<list default="true" id="fa28c5e7-7701-41dc-9f17-0b006dec0c27" name="Changes" comment="" />
|
| 8 |
+
<option name="SHOW_DIALOG" value="false" />
|
| 9 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
| 10 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
| 11 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
| 12 |
+
</component>
|
| 13 |
+
<component name="FileTemplateManagerImpl">
|
| 14 |
+
<option name="RECENT_TEMPLATES">
|
| 15 |
+
<list>
|
| 16 |
+
<option value="Python Script" />
|
| 17 |
+
</list>
|
| 18 |
+
</option>
|
| 19 |
+
</component>
|
| 20 |
+
<component name="Git.Settings">
|
| 21 |
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
| 22 |
+
</component>
|
| 23 |
+
<component name="MarkdownSettingsMigration">
|
| 24 |
+
<option name="stateVersion" value="1" />
|
| 25 |
+
</component>
|
| 26 |
+
<component name="ProjectId" id="2SUEII49IU90EiR8PXYGn1KOxtV" />
|
| 27 |
+
<component name="ProjectViewState">
|
| 28 |
+
<option name="hideEmptyMiddlePackages" value="true" />
|
| 29 |
+
<option name="showLibraryContents" value="true" />
|
| 30 |
+
</component>
|
| 31 |
+
<component name="PropertiesComponent">{
|
| 32 |
+
"keyToString": {
|
| 33 |
+
"ASKED_ADD_EXTERNAL_FILES": "true",
|
| 34 |
+
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
| 35 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
| 36 |
+
"WebServerToolWindowFactoryState": "false",
|
| 37 |
+
"last_opened_file_path": "C:/Users/melos/OneDrive/Desktop/conversational_uav_explorer",
|
| 38 |
+
"node.js.detected.package.eslint": "true",
|
| 39 |
+
"node.js.detected.package.tslint": "true",
|
| 40 |
+
"node.js.selected.package.eslint": "(autodetect)",
|
| 41 |
+
"node.js.selected.package.tslint": "(autodetect)",
|
| 42 |
+
"nodejs_package_manager_path": "npm",
|
| 43 |
+
"vue.rearranger.settings.migration": "true"
|
| 44 |
+
}
|
| 45 |
+
}</component>
|
| 46 |
+
<component name="RunManager" selected="Python.maps">
|
| 47 |
+
<configuration name="maps" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
| 48 |
+
<module name="conversational_uav_explorer" />
|
| 49 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 50 |
+
<option name="PARENT_ENVS" value="true" />
|
| 51 |
+
<envs>
|
| 52 |
+
<env name="PYTHONUNBUFFERED" value="1" />
|
| 53 |
+
</envs>
|
| 54 |
+
<option name="SDK_HOME" value="" />
|
| 55 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
| 56 |
+
<option name="IS_MODULE_SDK" value="true" />
|
| 57 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 58 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 59 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
| 60 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/maps.py" />
|
| 61 |
+
<option name="PARAMETERS" value="" />
|
| 62 |
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
| 63 |
+
<option name="EMULATE_TERMINAL" value="false" />
|
| 64 |
+
<option name="MODULE_MODE" value="false" />
|
| 65 |
+
<option name="REDIRECT_INPUT" value="false" />
|
| 66 |
+
<option name="INPUT_FILE" value="" />
|
| 67 |
+
<method v="2" />
|
| 68 |
+
</configuration>
|
| 69 |
+
<configuration name="pytest for test_fewshot.test_action_and_location" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
|
| 70 |
+
<module name="conversational_uav_explorer" />
|
| 71 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 72 |
+
<option name="PARENT_ENVS" value="true" />
|
| 73 |
+
<option name="SDK_HOME" value="" />
|
| 74 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
|
| 75 |
+
<option name="IS_MODULE_SDK" value="true" />
|
| 76 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 77 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 78 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
| 79 |
+
<option name="_new_keywords" value="""" />
|
| 80 |
+
<option name="_new_parameters" value="""" />
|
| 81 |
+
<option name="_new_additionalArguments" value="""" />
|
| 82 |
+
<option name="_new_target" value=""test_fewshot.test_action_and_location"" />
|
| 83 |
+
<option name="_new_targetType" value=""PYTHON"" />
|
| 84 |
+
<method v="2" />
|
| 85 |
+
</configuration>
|
| 86 |
+
<configuration name="pytest for test_fewshot.test_action_synonyms" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
|
| 87 |
+
<module name="conversational_uav_explorer" />
|
| 88 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 89 |
+
<option name="PARENT_ENVS" value="true" />
|
| 90 |
+
<option name="SDK_HOME" value="" />
|
| 91 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
|
| 92 |
+
<option name="IS_MODULE_SDK" value="true" />
|
| 93 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 94 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 95 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
| 96 |
+
<option name="_new_keywords" value="""" />
|
| 97 |
+
<option name="_new_parameters" value="""" />
|
| 98 |
+
<option name="_new_additionalArguments" value="""" />
|
| 99 |
+
<option name="_new_target" value=""test_fewshot.test_action_synonyms"" />
|
| 100 |
+
<option name="_new_targetType" value=""PYTHON"" />
|
| 101 |
+
<method v="2" />
|
| 102 |
+
</configuration>
|
| 103 |
+
<configuration name="pytest for test_fewshot.test_multiple_actions" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
|
| 104 |
+
<module name="conversational_uav_explorer" />
|
| 105 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 106 |
+
<option name="PARENT_ENVS" value="true" />
|
| 107 |
+
<option name="SDK_HOME" value="" />
|
| 108 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
|
| 109 |
+
<option name="IS_MODULE_SDK" value="true" />
|
| 110 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 111 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 112 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
| 113 |
+
<option name="_new_keywords" value="""" />
|
| 114 |
+
<option name="_new_parameters" value="""" />
|
| 115 |
+
<option name="_new_additionalArguments" value="""" />
|
| 116 |
+
<option name="_new_target" value=""test_fewshot.test_multiple_actions"" />
|
| 117 |
+
<option name="_new_targetType" value=""PYTHON"" />
|
| 118 |
+
<method v="2" />
|
| 119 |
+
</configuration>
|
| 120 |
+
<configuration name="pytest in test_fewshot.py" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
|
| 121 |
+
<module name="conversational_uav_explorer" />
|
| 122 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 123 |
+
<option name="PARENT_ENVS" value="true" />
|
| 124 |
+
<option name="SDK_HOME" value="" />
|
| 125 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
|
| 126 |
+
<option name="IS_MODULE_SDK" value="true" />
|
| 127 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 128 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 129 |
+
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
| 130 |
+
<option name="_new_keywords" value="""" />
|
| 131 |
+
<option name="_new_parameters" value="""" />
|
| 132 |
+
<option name="_new_additionalArguments" value="""" />
|
| 133 |
+
<option name="_new_target" value=""$PROJECT_DIR$/test/test_fewshot.py"" />
|
| 134 |
+
<option name="_new_targetType" value=""PATH"" />
|
| 135 |
+
<method v="2" />
|
| 136 |
+
</configuration>
|
| 137 |
+
<recent_temporary>
|
| 138 |
+
<list>
|
| 139 |
+
<item itemvalue="Python.maps" />
|
| 140 |
+
<item itemvalue="Python tests.pytest in test_fewshot.py" />
|
| 141 |
+
<item itemvalue="Python tests.pytest for test_fewshot.test_multiple_actions" />
|
| 142 |
+
<item itemvalue="Python tests.pytest for test_fewshot.test_action_and_location" />
|
| 143 |
+
<item itemvalue="Python tests.pytest for test_fewshot.test_action_synonyms" />
|
| 144 |
+
</list>
|
| 145 |
+
</recent_temporary>
|
| 146 |
+
</component>
|
| 147 |
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
| 148 |
+
<component name="TaskManager">
|
| 149 |
+
<task active="true" id="Default" summary="Default task">
|
| 150 |
+
<changelist id="fa28c5e7-7701-41dc-9f17-0b006dec0c27" name="Changes" comment="" />
|
| 151 |
+
<created>1689192677811</created>
|
| 152 |
+
<option name="number" value="Default" />
|
| 153 |
+
<option name="presentableId" value="Default" />
|
| 154 |
+
<updated>1689192677811</updated>
|
| 155 |
+
<workItem from="1689192678834" duration="2688000" />
|
| 156 |
+
<workItem from="1689313695763" duration="114000" />
|
| 157 |
+
<workItem from="1689660636989" duration="28000" />
|
| 158 |
+
<workItem from="1689802045997" duration="646000" />
|
| 159 |
+
<workItem from="1689805054680" duration="656000" />
|
| 160 |
+
<workItem from="1689805721821" duration="7924000" />
|
| 161 |
+
<workItem from="1689814322927" duration="1613000" />
|
| 162 |
+
<workItem from="1689815956482" duration="9411000" />
|
| 163 |
+
<workItem from="1689886290371" duration="9527000" />
|
| 164 |
+
<workItem from="1689902985879" duration="3935000" />
|
| 165 |
+
<workItem from="1689920691521" duration="14931000" />
|
| 166 |
+
<workItem from="1689994173944" duration="7901000" />
|
| 167 |
+
<workItem from="1690007682156" duration="2362000" />
|
| 168 |
+
<workItem from="1690010136833" duration="597000" />
|
| 169 |
+
<workItem from="1690011139369" duration="2038000" />
|
| 170 |
+
<workItem from="1690013441874" duration="3380000" />
|
| 171 |
+
<workItem from="1690037703652" duration="972000" />
|
| 172 |
+
<workItem from="1690055576881" duration="425000" />
|
| 173 |
+
<workItem from="1690057267338" duration="647000" />
|
| 174 |
+
</task>
|
| 175 |
+
<servers />
|
| 176 |
+
</component>
|
| 177 |
+
<component name="TypeScriptGeneratedFilesManager">
|
| 178 |
+
<option name="version" value="3" />
|
| 179 |
+
</component>
|
| 180 |
+
<component name="Vcs.Log.Tabs.Properties">
|
| 181 |
+
<option name="TAB_STATES">
|
| 182 |
+
<map>
|
| 183 |
+
<entry key="MAIN">
|
| 184 |
+
<value>
|
| 185 |
+
<State />
|
| 186 |
+
</value>
|
| 187 |
+
</entry>
|
| 188 |
+
</map>
|
| 189 |
+
</option>
|
| 190 |
+
</component>
|
| 191 |
+
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
| 192 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_no_location2.coverage" NAME="pytest for test_fewshot.test_no_location2 Coverage Results" MODIFIED="1689893948500" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 193 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$ttset.coverage" NAME="ttset Coverage Results" MODIFIED="1690015177857" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 194 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_with_extra_words2.coverage" NAME="pytest for test_fewshot.test_with_extra_words2 Coverage Results" MODIFIED="1689926023348" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 195 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$maps.coverage" NAME="maps Coverage Results" MODIFIED="1690057976258" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 196 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_snap_pic.coverage" NAME="pytest for test_fewshot.test_snap_pic Coverage Results" MODIFIED="1689925270325" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 197 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_location_no_action3.coverage" NAME="pytest for test_fewshot.test_location_no_action3 Coverage Results" MODIFIED="1689925926183" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 198 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_action_synonyms.coverage" NAME="pytest for test_fewshot.test_action_synonyms Coverage Results" MODIFIED="1690016099701" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 199 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_two_go_to.coverage" NAME="pytest for test_fewshot.test_two_go_to Coverage Results" MODIFIED="1690016001030" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 200 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_take_off.coverage" NAME="pytest for test_fewshot.test_take_off Coverage Results" MODIFIED="1689903256717" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 201 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_picture.coverage" NAME="pytest for test_fewshot.test_picture Coverage Results" MODIFIED="1689924583093" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 202 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_purple_house.coverage" NAME="pytest for test_fewshot.test_purple_house Coverage Results" MODIFIED="1689872035146" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 203 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_invalid_command.coverage" NAME="pytest for test_fewshot.test_invalid_command Coverage Results" MODIFIED="1689919785430" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 204 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_multiple_actions.coverage" NAME="pytest for test_fewshot.test_multiple_actions Coverage Results" MODIFIED="1690037995937" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 205 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_action_and_location.coverage" NAME="pytest for test_fewshot.test_action_and_location Coverage Results" MODIFIED="1690016118401" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 206 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_in_test_fewshot_py.coverage" NAME="pytest in test_fewshot.py Coverage Results" MODIFIED="1690055658911" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 207 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_action_and_location_synonyms.coverage" NAME="pytest for test_fewshot.test_action_and_location_synonyms Coverage Results" MODIFIED="1690016083172" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 208 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_invalid_command2.coverage" NAME="pytest for test_fewshot.test_invalid_command2 Coverage Results" MODIFIED="1689919761343" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 209 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$gradio_theme.coverage" NAME="gradio_theme Coverage Results" MODIFIED="1690008184752" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 210 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_location_no_action4.coverage" NAME="pytest for test_fewshot.test_location_no_action4 Coverage Results" MODIFIED="1689926082281" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 211 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$app.coverage" NAME="app Coverage Results" MODIFIED="1690013150974" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 212 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$testing.coverage" NAME="testing Coverage Results" MODIFIED="1689806315429" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 213 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_no_location1.coverage" NAME="pytest for test_fewshot.test_no_location1 Coverage Results" MODIFIED="1689810960745" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 214 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_parking_garage.coverage" NAME="pytest for test_fewshot.test_parking_garage Coverage Results" MODIFIED="1689923732887" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 215 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_multiple_actions_and_locations.coverage" NAME="pytest for test_fewshot.test_multiple_actions_and_locations Coverage Results" MODIFIED="1690016038424" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 216 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_red_house.coverage" NAME="pytest for test_fewshot.test_red_house Coverage Results" MODIFIED="1689903222333" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 217 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_with_extra_words.coverage" NAME="pytest for test_fewshot.test_with_extra_words Coverage Results" MODIFIED="1689925241350" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 218 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_location_no_action2.coverage" NAME="pytest for test_fewshot.test_location_no_action2 Coverage Results" MODIFIED="1689925965485" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 219 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_in_test_chatgpt4uavs_py.coverage" NAME="pytest in test_chatgpt4uavs.py Coverage Results" MODIFIED="1689811486444" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 220 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_no_location3.coverage" NAME="pytest for test_fewshot.test_no_location3 Coverage Results" MODIFIED="1689894610483" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 221 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot.coverage" NAME="pytest for test_fewshot Coverage Results" MODIFIED="1689924456081" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 222 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_location_no_action.coverage" NAME="pytest for test_fewshot.test_location_no_action Coverage Results" MODIFIED="1689925977067" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 223 |
+
<SUITE FILE_PATH="coverage/conversational_uav_explorer$pytest_for_test_fewshot_test_gym.coverage" NAME="pytest for test_fewshot.test_gym Coverage Results" MODIFIED="1689892873253" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
|
| 224 |
+
</component>
|
| 225 |
+
</project>
|
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🌖
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 3.39.0
|
| 8 |
app_file: app.py
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: conversational_uav_explorer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.34.0
|
| 6 |
---
|
|
|
|
|
|
__pycache__/app.cpython-311.pyc
ADDED
|
Binary file (4.23 kB). View file
|
|
|
__pycache__/chatgpt4uavs.cpython-311.pyc
ADDED
|
Binary file (2.32 kB). View file
|
|
|
__pycache__/fewshot.cpython-311.pyc
ADDED
|
Binary file (3.65 kB). View file
|
|
|
__pycache__/maps.cpython-311.pyc
ADDED
|
Binary file (3.89 kB). View file
|
|
|
__pycache__/prompts.cpython-311.pyc
ADDED
|
Binary file (6.44 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from prompts import prompt_chat_response
|
| 4 |
+
from fewshot import FewShot4UAVs
|
| 5 |
+
|
| 6 |
+
openai.api_key = "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"
|
| 7 |
+
|
| 8 |
+
fewshot = FewShot4UAVs()
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def transcribe(audio):
|
| 12 |
+
messages = [
|
| 13 |
+
{"role": "system",
|
| 14 |
+
"content": prompt_chat_response}
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
audio_file = open(audio, "rb")
|
| 18 |
+
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
| 19 |
+
|
| 20 |
+
original_transcript = transcript["text"]
|
| 21 |
+
messages.append({"role": "user", "content": original_transcript, "name": "Operator"})
|
| 22 |
+
|
| 23 |
+
formatted_command_text = fewshot.get_command(original_transcript)
|
| 24 |
+
messages.append({"role": "function", "content": formatted_command_text, "name": "UAV"})
|
| 25 |
+
|
| 26 |
+
response = openai.ChatCompletion.create(
|
| 27 |
+
model="gpt-3.5-turbo",
|
| 28 |
+
messages=messages
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
uav_response = response["choices"][0]["message"]["content"]
|
| 32 |
+
messages.append({"role": "assistant", "content": uav_response, "name": "Assistant"})
|
| 33 |
+
|
| 34 |
+
chat_transcript = ""
|
| 35 |
+
for message in messages:
|
| 36 |
+
if message['role'] != 'system':
|
| 37 |
+
chat_transcript += f"{message['name']}: {message['content']} \n\n"
|
| 38 |
+
|
| 39 |
+
return chat_transcript
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
with gr.Blocks(theme='sudeepshouche/minimalist') as demo:
|
| 43 |
+
gr.Markdown("""
|
| 44 |
+
# Conversational UAV Explorer
|
| 45 |
+
Press record and speak into the microphone to give a command. Make sure to stop recording before pressing "Give Command."\n\n
|
| 46 |
+
Commands: Take picture, Go to, Land, Take off""")
|
| 47 |
+
with gr.Row().style():
|
| 48 |
+
audio_input = gr.Audio(source="microphone", type="filepath")
|
| 49 |
+
output = gr.Textbox(label="Transcript")
|
| 50 |
+
with gr.Row():
|
| 51 |
+
with gr.Column():
|
| 52 |
+
submit_btn = gr.Button("Give command", variant="primary")
|
| 53 |
+
submit_btn.click(fn=transcribe, inputs=audio_input, outputs=output, api_name="record")
|
| 54 |
+
with gr.Accordion("Examples:"):
|
| 55 |
+
gr.Markdown("Take a picture of the second floor of the green house.\n\n"
|
| 56 |
+
"Go to the brick house across the street.\n\n"
|
| 57 |
+
"Head to Libby Hill Park on E Franklin St.\n\n"
|
| 58 |
+
"Check out the Whole Foods on W Broad St.\n\n"
|
| 59 |
+
"Take off at your position.\n\n"
|
| 60 |
+
"Land now.")
|
| 61 |
+
|
| 62 |
+
demo.launch(share=True)
|
chatgpt4uavs.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Necessary imports
|
| 2 |
+
import os
|
| 3 |
+
from langchain.llms import OpenAI
|
| 4 |
+
from langchain.prompts import PromptTemplate
|
| 5 |
+
from langchain.chains import LLMChain
|
| 6 |
+
from langchain.chains import SimpleSequentialChain
|
| 7 |
+
from prompts import prompt_transcribe, prompt_command
|
| 8 |
+
|
| 9 |
+
# API Key
|
| 10 |
+
os.environ["OPENAI_API_KEY"] = "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"
|
| 11 |
+
|
| 12 |
+
# Initializing OpenAI as the large language model
|
| 13 |
+
llm = OpenAI(temperature=0.0)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def get_transcription(text):
|
| 17 |
+
# Transcription prompt
|
| 18 |
+
transcribe_prompt = PromptTemplate(
|
| 19 |
+
input_variables=["text"],
|
| 20 |
+
template=prompt_transcribe
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Creating transcription chain
|
| 24 |
+
sentence_chain = LLMChain(llm=llm,
|
| 25 |
+
prompt=transcribe_prompt,
|
| 26 |
+
output_key="sentence")
|
| 27 |
+
|
| 28 |
+
return sentence_chain
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Method takes in the transcription chain to link them together with a sequential chain, which is then returned.
|
| 32 |
+
def format_command(chain):
|
| 33 |
+
# Prompt Creation
|
| 34 |
+
command = PromptTemplate(
|
| 35 |
+
input_variables=["sentence"],
|
| 36 |
+
template=prompt_command
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
# Chain Creation
|
| 40 |
+
command_chain = LLMChain(llm=llm, prompt=command, output_key="output")
|
| 41 |
+
|
| 42 |
+
# Initializing chain needed to connect using the parameters
|
| 43 |
+
sentence_chain = chain
|
| 44 |
+
|
| 45 |
+
# Connecting the two created chains via the SimpleSequentialChain.
|
| 46 |
+
sentence_command_chain = SimpleSequentialChain(
|
| 47 |
+
chains=[sentence_chain, command_chain], verbose=True
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# Returning the new combined chain
|
| 51 |
+
return sentence_command_chain
|
| 52 |
+
|
| 53 |
+
def to_file(text):
|
| 54 |
+
f = open("commands.txt", "w")
|
| 55 |
+
f.write(text)
|
| 56 |
+
f.close()
|
| 57 |
+
|
| 58 |
+
# Method to get the actual formatted command
|
| 59 |
+
def get_command(text):
|
| 60 |
+
command = format_command(get_transcription(text))
|
| 61 |
+
to_file(command.run(text))
|
| 62 |
+
return command.run(text)
|
| 63 |
+
|
commands.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
NONE
|
fewshot.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from langchain.llms import OpenAI
|
| 3 |
+
from langchain.prompts import PromptTemplate
|
| 4 |
+
from langchain.prompts.few_shot import FewShotPromptTemplate
|
| 5 |
+
from langchain.chains import LLMChain
|
| 6 |
+
from langchain.chains import SimpleSequentialChain
|
| 7 |
+
from prompts import prompt_transcribe, prompt_command, examples_few_shot
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class FewShot4UAVs:
|
| 11 |
+
|
| 12 |
+
def __init__(self) -> None:
|
| 13 |
+
os.environ["OPENAI_API_KEY"] = "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"
|
| 14 |
+
self.llm = OpenAI(temperature=0.0)
|
| 15 |
+
|
| 16 |
+
def get_transcription(self, text):
|
| 17 |
+
transcribe_prompt = PromptTemplate(
|
| 18 |
+
input_variables=["text"],
|
| 19 |
+
template=prompt_transcribe
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
sentence_chain = LLMChain(llm=self.llm,
|
| 23 |
+
prompt=transcribe_prompt,
|
| 24 |
+
output_key="sentence")
|
| 25 |
+
|
| 26 |
+
return sentence_chain
|
| 27 |
+
|
| 28 |
+
def format_command(self, chain):
|
| 29 |
+
command = PromptTemplate(
|
| 30 |
+
input_variables=["sentence", "command"],
|
| 31 |
+
template="sentence: {sentence}\n{command}"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
few_shot_prompt = FewShotPromptTemplate(
|
| 35 |
+
examples=examples_few_shot,
|
| 36 |
+
example_prompt=command,
|
| 37 |
+
suffix="sentence: {sentence}",
|
| 38 |
+
input_variables=["sentence"]
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
command_chain = LLMChain(llm=self.llm, prompt=few_shot_prompt, output_key="output")
|
| 42 |
+
|
| 43 |
+
sentence_chain = chain
|
| 44 |
+
|
| 45 |
+
sentence_command_chain = SimpleSequentialChain(
|
| 46 |
+
chains=[sentence_chain, command_chain], verbose=True
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
return sentence_command_chain
|
| 50 |
+
|
| 51 |
+
def to_file(self, text):
|
| 52 |
+
try:
|
| 53 |
+
with open("commands.txt", "w") as f:
|
| 54 |
+
f.write(text)
|
| 55 |
+
print("Command successfully written to the file.")
|
| 56 |
+
except Exception as e:
|
| 57 |
+
print(f"Error: {e}")
|
| 58 |
+
|
| 59 |
+
def get_command(self, text):
|
| 60 |
+
command = self.format_command(self.get_transcription(text))
|
| 61 |
+
self.to_file(command.run(text))
|
| 62 |
+
return command.run(text)
|
flagged/audio/1b4e7759ac1ceebefc089ec30abaf61b720de43b/tmpgvgxcf4v.wav
ADDED
|
Binary file (39.1 kB). View file
|
|
|
flagged/log.csv
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
audio,output,flag,username,timestamp
|
| 2 |
+
C:\Users\melos\OneDrive\Desktop\conversational_uav_explorer\flagged\audio\1b4e7759ac1ceebefc089ec30abaf61b720de43b\tmpgvgxcf4v.wav,"<p><strong>Operator</strong>: Go to the Kroger across the street.</p>
|
| 3 |
+
<p><strong>UAV</strong>:
|
| 4 |
+
GOTO Kroger across the street</p>
|
| 5 |
+
<p><strong>Assistant</strong>: Acknowledged. Proceeding to Kroger across the street.</p>
|
| 6 |
+
",,,2023-07-22 03:55:53.983036
|
maps.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import googlemaps
|
| 2 |
+
from datetime import datetime
|
| 3 |
+
from pprint import pprint
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class AddressLocator:
|
| 7 |
+
def __init__(self):
|
| 8 |
+
self.maps = googlemaps.Client(key='AIzaSyAFUBwCyykt-8nfOYqGvUZbXV0dMnQYTJ4')
|
| 9 |
+
|
| 10 |
+
# Takes the name of a place and returns the exact address
|
| 11 |
+
def get_location(self, sentence):
|
| 12 |
+
sentence = sentence.lower()
|
| 13 |
+
commands = ["take picture", "go to", "land", "take off"]
|
| 14 |
+
for command in commands:
|
| 15 |
+
if command in sentence:
|
| 16 |
+
address_start_index = sentence.index(command) + len(command) + 1
|
| 17 |
+
address = sentence[address_start_index:].strip()
|
| 18 |
+
try:
|
| 19 |
+
response = self.maps.places(query=address)
|
| 20 |
+
results = response.get('results')
|
| 21 |
+
if results:
|
| 22 |
+
return results[0]['formatted_address']
|
| 23 |
+
else:
|
| 24 |
+
return None
|
| 25 |
+
except Exception as e:
|
| 26 |
+
print(e)
|
| 27 |
+
return None
|
| 28 |
+
return None
|
| 29 |
+
|
| 30 |
+
# Takes the name of a place and returns the route from one location to a single destination
|
| 31 |
+
def compute_route(self, uav_location, destination):
|
| 32 |
+
now = datetime.now()
|
| 33 |
+
directions_result = self.maps.directions(uav_location, destination,
|
| 34 |
+
mode="driving",
|
| 35 |
+
optimize_waypoints=True,
|
| 36 |
+
departure_time=now
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
directions = directions_result[0]['legs'][0]['steps']
|
| 40 |
+
instructions = [step['html_instructions'] for step in directions]
|
| 41 |
+
text_instructions = [self.strip_html_tags(instruction) for instruction in instructions]
|
| 42 |
+
return text_instructions
|
| 43 |
+
|
| 44 |
+
@staticmethod
|
| 45 |
+
def strip_html_tags(text):
|
| 46 |
+
import re
|
| 47 |
+
clean = re.compile('<.*?>')
|
| 48 |
+
return re.sub(clean, '', text)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# Testing
|
| 52 |
+
address_locator = AddressLocator()
|
| 53 |
+
|
| 54 |
+
# Placeholder
|
| 55 |
+
# uav_location = "Current location"
|
| 56 |
+
|
| 57 |
+
loc = address_locator.get_location("Go to Chick-fil-a on W Broad St")
|
| 58 |
+
print(loc)
|
| 59 |
+
|
| 60 |
+
loc2 = address_locator.get_location("Go to Roots on W Grace St")
|
| 61 |
+
print(loc2)
|
| 62 |
+
|
| 63 |
+
res = address_locator.compute_route(loc, loc2)
|
| 64 |
+
|
| 65 |
+
for direction in res:
|
| 66 |
+
print(direction)
|
prompts.py
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Creating a Prompt and Chain with the transcription so it can be passed to the official Command Prompt via
|
| 2 |
+
# Simple Sequential chain Transcription template
|
| 3 |
+
prompt_transcribe = """You are to pass the audio transcription to the next
|
| 4 |
+
chain. Do not alter the transcription in any way.
|
| 5 |
+
|
| 6 |
+
Transcription: {text}
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
# Prompt template
|
| 10 |
+
prompt_command = """You are in control of an Unmanned Aerial Vehicle or UAV.
|
| 11 |
+
You are going to be given a sentence command, you need to find the action of
|
| 12 |
+
the sentence. The action will be, TAKEPICTURE, TAKEOFF, LAND or GOTO. If the
|
| 13 |
+
action is not one of those actions return "NONE". ONLY give those commands or
|
| 14 |
+
"NONE", NEVER anything else. If the action is "TAKEOFF", "LAND" or "NONE" you
|
| 15 |
+
don't need any further information for the location. If the action is "GOTO" or
|
| 16 |
+
"TAKEPICTURE", you'll need to find where to carry out the action. If the action
|
| 17 |
+
is "GOTO" or "TAKEPICTURE" with no location following return "None".
|
| 18 |
+
|
| 19 |
+
If you can't find the actions Take Picture, Take Off, Land, or Go To, return "NONE".
|
| 20 |
+
|
| 21 |
+
You need to return the command in this format: <command> \t<goal>
|
| 22 |
+
|
| 23 |
+
However, if you get a sentence with multiple commands here is what you need to do:
|
| 24 |
+
For example take the sentence, "Go to the Walmart in Petersburg and take a picture."
|
| 25 |
+
The format of the command needs to be: <first command> \t<goal>\n\n<second command> \t<goal>
|
| 26 |
+
|
| 27 |
+
Sentence: {sentence}
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
prompt_chat_response = """You are an AI-powered chatbot integrated into a UAV
|
| 31 |
+
(Unmanned Aerial Vehicle) system. Your purpose is to receive and execute
|
| 32 |
+
commands from an officer. Your role is to understand and carry out these commands
|
| 33 |
+
efficiently. You must acknowledge the command if you understand it. Use 2-3
|
| 34 |
+
sentences to respond to the officer's instructions, ask for clarification if
|
| 35 |
+
needed, and provide updates on the execution status of the given commands.
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
# Creating examples for each command that the llm can use to help format our commands.
|
| 39 |
+
# Also passing the transcription to the Command Prompt Template.
|
| 40 |
+
examples_few_shot = [
|
| 41 |
+
# Location only
|
| 42 |
+
{
|
| 43 |
+
"sentence": "Kroger on N Lombardy St.",
|
| 44 |
+
"command": "command: GOTO \tKroger on N Lombardy St"""
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"sentence": "CVS at Main St.",
|
| 48 |
+
"command": "command: GOTO \tCVS at Main St"""
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"sentence": "Short Pump Town Center.",
|
| 52 |
+
"command": "command: GOTO \tShort Pump Town Center"""
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"sentence": "Can Can Brasserie.",
|
| 56 |
+
"command": "command: GOTO \tCan Can Brasserie"""
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"sentence": "Walgreens.",
|
| 60 |
+
"command": "command: GOTO \tWalgreens"""
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"sentence": "Best Buy in Colonial Heights.",
|
| 64 |
+
"command": "command: GOTO \tBest Buy in Colonial Heights"""
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"sentence": "The red house to the left.",
|
| 68 |
+
"command": "command: GOTO \tred house to the left"""
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"sentence": "The Science Museum.",
|
| 72 |
+
"command": "command: GOTO \tScience Museum"""
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"sentence": "South Park Mall.",
|
| 76 |
+
"command": "command: GOTO \tSouth Park Mall"""
|
| 77 |
+
},
|
| 78 |
+
# Commands that don't require a location
|
| 79 |
+
{
|
| 80 |
+
"sentence": "Take off now.",
|
| 81 |
+
"command": "command: TAKEOFF"""
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"sentence": "Take off from where you are.",
|
| 85 |
+
"command": "command: TAKEOFF"
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"sentence": "Take off.",
|
| 89 |
+
"command": "command: TAKEOFF"
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"sentence": "Take off at your position.",
|
| 93 |
+
"command": "command: TAKEOFF"
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"sentence": "Take off from where you are at.",
|
| 97 |
+
"command": "command: TAKEOFF"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"sentence": "Lift off.",
|
| 101 |
+
"command": "command: TAKEOFF"
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"sentence": "Land now.",
|
| 105 |
+
"command": "command: LAND"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"sentence": "Cease flight.",
|
| 109 |
+
"command": "command: LAND"
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"sentence": "Stop the flight.",
|
| 113 |
+
"command": "command: LAND"
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"sentence": "Stop flying.",
|
| 117 |
+
"command": "command: LAND"""
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"sentence": "Take flight.",
|
| 121 |
+
"command": "command: TAKEOFF"""
|
| 122 |
+
},
|
| 123 |
+
# Commands that require a location but don't have any
|
| 124 |
+
{
|
| 125 |
+
"sentence": "Take a pic.",
|
| 126 |
+
"command": "NONE"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"sentence": "Take a photo.",
|
| 130 |
+
"command": "NONE"
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"sentence": "Snap a photo.",
|
| 134 |
+
"command": "NONE"
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"sentence": "Snap a pic.",
|
| 138 |
+
"command": "NONE"
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"sentence": "Proceed to.",
|
| 142 |
+
"command": "NONE"""
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"sentence": "Push to.",
|
| 146 |
+
"command": "NONE"""
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"sentence": "Advance to.",
|
| 150 |
+
"command": "NONE"""
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"sentence": "Make your way to.",
|
| 154 |
+
"command": "NONE"""
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"sentence": "Travel to.",
|
| 158 |
+
"command": "NONE"""
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"sentence": "Go to.",
|
| 162 |
+
"command": "NONE"""
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"sentence": "Take a picture.",
|
| 166 |
+
"command": "NONE"
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"sentence": "Take a picture when you can please.",
|
| 170 |
+
"command": "NONE"
|
| 171 |
+
},
|
| 172 |
+
# Commands with one action and one location
|
| 173 |
+
{
|
| 174 |
+
"sentence": "Fly to the Sonic on West Cary St.",
|
| 175 |
+
"command": "command: GOTO \tSonic on West Cary St."
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
"sentence": "Check out the gym at Cary St.",
|
| 179 |
+
"command": "command: GOTO \tgym at Cary St"
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"sentence": "Investigate the Rite Aid on Broad and Belevidere.",
|
| 183 |
+
"command": "command: GOTO \tRite Aid on Broad and Belevidere"
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"sentence": "Go to Papa Johns at 1200 W Main St.",
|
| 187 |
+
"command": "command: GOTO \tPapa Johns at 1200 W Main St"""
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"sentence": "Go to the orange house on W Grace St.",
|
| 191 |
+
"command": "command: GOTO \torange house on W Grace St"""
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"sentence": "Travel to Cabell Library at VCU.",
|
| 195 |
+
"command": "command: GOTO \tCabell Library at VCU"""
|
| 196 |
+
},
|
| 197 |
+
# Commands with one action and one location but with extra words
|
| 198 |
+
{
|
| 199 |
+
"sentence": "Please check out the CVS on W Broad St.",
|
| 200 |
+
"command": "command: GOTO \tCVS on W Broad St"
|
| 201 |
+
},
|
| 202 |
+
# Commands with multiple actions
|
| 203 |
+
{
|
| 204 |
+
"sentence": "Go to the purple house on to the left and take a picture",
|
| 205 |
+
"command": "command: GOTO \tpurple house on to the left\ncommand: TAKEPICTURE \tpurple house on to the left"
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
"sentence": "Fly to Kroger on Iron Bridge and take a picure",
|
| 209 |
+
"command": "command: GOTO \tKroger on Iron Bridge\ncommand: TAKEPICTURE \tKroger on Iron Bridge"
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"sentence": "Travel to the McDonalds on Route 1 and land",
|
| 213 |
+
"command": "command: GOTO \tMcDonalds on Route 1\ncommand: LAND"
|
| 214 |
+
},
|
| 215 |
+
{
|
| 216 |
+
"sentence": "Take off, go to the Walgreens on W Hundred Rd, then land",
|
| 217 |
+
"command": "command: TAKEOFF\ncommand: GOTO \tWalgreens on W Hundred Rd\ncommand: LAND"
|
| 218 |
+
},
|
| 219 |
+
# Commands with multiple actions and multiple locations
|
| 220 |
+
{
|
| 221 |
+
"sentence": "Take a picture of the light blue building on Harrowgate Road, then go to the Wawa on Route 1",
|
| 222 |
+
"command": "command: TAKEPICTURE \tlight blue building on Harrowgate Road\ncommand: GOTO \tWawa on Route 1"
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"sentence": "Check out the yellow house on Clay St, then go to the Commons on W Main St",
|
| 226 |
+
"command": "command: GOTO \tyellow house on Clay St\ncommand: GOTO \tCommons on W Main St"
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"sentence": "Investigate the 7/11 on W Grace St, then go to the Barnes and Noble on W Broad St, then take a picture of it.",
|
| 230 |
+
"command": "command: GOTO \t7/11 on W Grace St\ncommand: GOTO \tBarnes and Noble on W Broad S\ncommand: TAKEPICTURE \tBarnes and Noble on W Broad St"
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"sentence": "Go to the grey one story flat on Happy Hill Rd, then go to the Food Lion on the same road, then take a picture of it.",
|
| 234 |
+
"command": "command: GOTO \tgrey one story flat on Happy Hill Rd\ncommand: GOTO \tFood Lion on Happy Hill Rd\ncommand: TAKEPICTURE \tFood Lion on Happy Hill Rd"
|
| 235 |
+
}
|
| 236 |
+
]
|
rasa_bot/actions/__init__.py
ADDED
|
File without changes
|
rasa_bot/actions/actions.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This files contains your custom actions which can be used to run
|
| 2 |
+
# custom Python code.
|
| 3 |
+
#
|
| 4 |
+
# See this guide on how to implement these action:
|
| 5 |
+
# https://rasa.com/docs/rasa/custom-actions
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
import json
|
| 10 |
+
from typing import Any, Text, Dict, List
|
| 11 |
+
|
| 12 |
+
from rasa_sdk import Action, Tracker
|
| 13 |
+
from rasa_sdk.executor import CollectingDispatcher
|
| 14 |
+
from rasa_sdk.events import SlotSet
|
| 15 |
+
|
| 16 |
+
class ActionGreetUser(Action):
|
| 17 |
+
def name(self) -> Text:
|
| 18 |
+
return "action_display_info"
|
| 19 |
+
|
| 20 |
+
async def run(
|
| 21 |
+
self,
|
| 22 |
+
dispatcher: CollectingDispatcher,
|
| 23 |
+
tracker: Tracker,
|
| 24 |
+
domain: Dict[Text, Any],
|
| 25 |
+
):
|
| 26 |
+
s = []
|
| 27 |
+
for item in tracker.latest_message["entities"]:
|
| 28 |
+
n = {
|
| 29 |
+
"entity" : item["entity"],
|
| 30 |
+
"value" : item["value"]
|
| 31 |
+
}
|
| 32 |
+
s.append(n)
|
| 33 |
+
date_picker = {
|
| 34 |
+
"intent" : tracker.latest_message["intent"]["name"],
|
| 35 |
+
"slots" : s
|
| 36 |
+
}
|
| 37 |
+
dispatcher.utter_message(text = json.dumps(date_picker, sort_keys=True, indent=2, separators=(',', ': ')))
|
| 38 |
+
|
| 39 |
+
return []
|
| 40 |
+
|
| 41 |
+
# class ActionExploreTrue(Action):
|
| 42 |
+
# def name(self) -> Text:
|
| 43 |
+
# return "action_explore_t"
|
| 44 |
+
|
| 45 |
+
# def run(self,
|
| 46 |
+
# dispatcher: CollectingDispatcher,
|
| 47 |
+
# tracker: Tracker,
|
| 48 |
+
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
|
| 49 |
+
|
| 50 |
+
# return [SlotSet("explore", True)]
|
| 51 |
+
|
| 52 |
+
# class ActionExploreFalse(Action):
|
| 53 |
+
# def name(self) -> Text:
|
| 54 |
+
# return "action_explore_f"
|
| 55 |
+
|
| 56 |
+
# def run(self,
|
| 57 |
+
# dispatcher: CollectingDispatcher,
|
| 58 |
+
# tracker: Tracker,
|
| 59 |
+
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
|
| 60 |
+
|
| 61 |
+
# return [SlotSet("explore", None)]
|
rasa_bot/config.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The config recipe.
|
| 2 |
+
# https://rasa.com/docs/rasa/model-configuration/
|
| 3 |
+
recipe: default.v1
|
| 4 |
+
|
| 5 |
+
# Configuration for Rasa NLU.
|
| 6 |
+
# https://rasa.com/docs/rasa/nlu/components/
|
| 7 |
+
language: en
|
| 8 |
+
|
| 9 |
+
pipeline:
|
| 10 |
+
# No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
|
| 11 |
+
# If you'd like to customize it, uncomment and adjust the pipeline.
|
| 12 |
+
# See https://rasa.com/docs/rasa/tuning-your-model for more information.
|
| 13 |
+
- name: WhitespaceTokenizer
|
| 14 |
+
- name: RegexFeaturizer
|
| 15 |
+
- name: LexicalSyntacticFeaturizer
|
| 16 |
+
- name: CountVectorsFeaturizer
|
| 17 |
+
- name: CountVectorsFeaturizer
|
| 18 |
+
analyzer: char_wb
|
| 19 |
+
min_ngram: 1
|
| 20 |
+
max_ngram: 4
|
| 21 |
+
- name: KeywordIntentClassifier #added
|
| 22 |
+
- name: DIETClassifier
|
| 23 |
+
epochs: 100
|
| 24 |
+
constrain_similarities: true
|
| 25 |
+
- name: EntitySynonymMapper
|
| 26 |
+
- name: ResponseSelector
|
| 27 |
+
epochs: 100
|
| 28 |
+
constrain_similarities: true
|
| 29 |
+
- name: FallbackClassifier
|
| 30 |
+
threshold: 0.95
|
| 31 |
+
# threshold: 0.3
|
| 32 |
+
# ambiguity_threshold: 0.1
|
| 33 |
+
|
| 34 |
+
# Configuration for Rasa Core.
|
| 35 |
+
# https://rasa.com/docs/rasa/core/policies/
|
| 36 |
+
policies:
|
| 37 |
+
# # No configuration for policies was provided. The following default policies were used to train your model.
|
| 38 |
+
# # If you'd like to customize them, uncomment and adjust the policies.
|
| 39 |
+
# # See https://rasa.com/docs/rasa/policies for more information.
|
| 40 |
+
# - name: MemoizationPolicy
|
| 41 |
+
# - name: RulePolicy
|
| 42 |
+
# - name: UnexpecTEDIntentPolicy
|
| 43 |
+
# max_history: 5
|
| 44 |
+
# epochs: 100
|
| 45 |
+
# - name: TEDPolicy
|
| 46 |
+
# max_history: 5
|
| 47 |
+
# epochs: 100
|
| 48 |
+
# constrain_similarities: true
|
rasa_bot/credentials.yml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file contains the credentials for the voice & chat platforms
|
| 2 |
+
# which your bot is using.
|
| 3 |
+
# https://rasa.com/docs/rasa/messaging-and-voice-channels
|
| 4 |
+
|
| 5 |
+
rest:
|
| 6 |
+
# # you don't need to provide anything here - this channel doesn't
|
| 7 |
+
# # require any credentials
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
#facebook:
|
| 11 |
+
# verify: "<verify>"
|
| 12 |
+
# secret: "<your secret>"
|
| 13 |
+
# page-access-token: "<your page access token>"
|
| 14 |
+
|
| 15 |
+
#slack:
|
| 16 |
+
# slack_token: "<your slack token>"
|
| 17 |
+
# slack_channel: "<the slack channel>"
|
| 18 |
+
# slack_signing_secret: "<your slack signing secret>"
|
| 19 |
+
|
| 20 |
+
socketio:
|
| 21 |
+
user_message_evt: user_uttered
|
| 22 |
+
bot_message_evt: bot_uttered
|
| 23 |
+
session_persistence: false
|
| 24 |
+
|
| 25 |
+
#mattermost:
|
| 26 |
+
# url: "https://<mattermost instance>/api/v4"
|
| 27 |
+
# token: "<bot token>"
|
| 28 |
+
# webhook_url: "<callback URL>"
|
| 29 |
+
|
| 30 |
+
# This entry is needed if you are using Rasa Enterprise. The entry represents credentials
|
| 31 |
+
# for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers.
|
| 32 |
+
rasa:
|
| 33 |
+
url: "http://localhost:5002/api"
|
rasa_bot/data/nlu.yml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
nlu:
|
| 2 |
+
- intent: greet
|
| 3 |
+
examples: |
|
| 4 |
+
- start
|
| 5 |
+
- hi
|
| 6 |
+
- hello
|
| 7 |
+
|
| 8 |
+
- intent: explore
|
| 9 |
+
examples: |
|
| 10 |
+
- Can you explore the [second floor](location) of the [green house](building)?
|
| 11 |
+
- Look around the [top floor](location) of the [house at 601 W Main St](building).
|
| 12 |
+
- Go and look inside the [attic](location) of the [large house across the street](building).
|
| 13 |
+
- Explore the [back](location) of the [five story building](building).
|
| 14 |
+
- Go to the [ground floor](location) of the [red building](building).
|
| 15 |
+
- Move to the [white house](building).
|
| 16 |
+
- Move to the [bottom](location) of the [white house](building).
|
| 17 |
+
- Move to the [house at 25232 N Washington Dr](building).
|
| 18 |
+
- Explore the [front](location) of the [house on 43143 Brookside Pl](building).
|
| 19 |
+
- Explore the [west side](location) of the [house](building).
|
| 20 |
+
- Explore the [east side](location) of the [big yellow building](building).
|
| 21 |
+
|
| 22 |
+
- intent: take_picture
|
| 23 |
+
examples: |
|
| 24 |
+
- Take a [picture](picture_type).
|
| 25 |
+
- Take a [picture](picture_type) inside the [nearby blue house](location).
|
| 26 |
+
- Take [several pictures](picture_type) of the location.
|
| 27 |
+
- Take a [picture](picture_type) of the [third floor of the blue house](location).
|
| 28 |
+
- Take a [picture](picture_type) of the [front of the house](location).
|
| 29 |
+
- Take a [picture](picture_type) of the [west side of the red building](location).
|
| 30 |
+
|
| 31 |
+
- intent: monitor
|
| 32 |
+
examples: |
|
| 33 |
+
- Monitor the house at the [NE corner of the intersection of Main and Cary](location).
|
| 34 |
+
- Watch for activity at the [orange house](location).
|
| 35 |
+
- Monitor the [orange house](location).
|
| 36 |
+
- Monitor this location.
|
| 37 |
+
|
| 38 |
+
- intent: move/stop
|
| 39 |
+
examples: |
|
| 40 |
+
- stop the drone
|
| 41 |
+
- stop flight
|
| 42 |
+
- stop activity
|
| 43 |
+
- stop
|
| 44 |
+
|
| 45 |
+
- intent: move/land
|
| 46 |
+
examples: |
|
| 47 |
+
- land the drone
|
| 48 |
+
- land here
|
| 49 |
+
- something land something
|
| 50 |
+
- land at nearest location
|
| 51 |
+
|
| 52 |
+
- intent: move/come_back
|
| 53 |
+
examples: |
|
| 54 |
+
- return to home
|
| 55 |
+
- return to base
|
| 56 |
+
- come back to home
|
| 57 |
+
- come back to base
|
| 58 |
+
- come back to headquarters
|
| 59 |
+
- return to headquarters
|
| 60 |
+
|
| 61 |
+
- intent: move/left
|
| 62 |
+
examples: |
|
| 63 |
+
- move left
|
| 64 |
+
- fly to the left
|
| 65 |
+
- move to the left
|
| 66 |
+
- left
|
| 67 |
+
|
| 68 |
+
- intent: move/right
|
| 69 |
+
examples: |
|
| 70 |
+
- move right
|
| 71 |
+
- fly to the right
|
| 72 |
+
- move to the right
|
| 73 |
+
- right
|
| 74 |
+
|
| 75 |
+
- intent: move/up
|
| 76 |
+
examples: |
|
| 77 |
+
- move up
|
| 78 |
+
- fly up
|
| 79 |
+
- fly upwards
|
| 80 |
+
- up
|
| 81 |
+
- upwards
|
| 82 |
+
|
| 83 |
+
- intent: move/down
|
| 84 |
+
examples: |
|
| 85 |
+
- move down
|
| 86 |
+
- fly down
|
| 87 |
+
- fly downwards
|
| 88 |
+
- down
|
| 89 |
+
- downwards
|
| 90 |
+
|
| 91 |
+
- intent: move/get_closer
|
| 92 |
+
examples: |
|
| 93 |
+
- move closer
|
| 94 |
+
- fly closer
|
| 95 |
+
- get closer
|
| 96 |
+
- closer
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
#use localhost:5005/webhooks/rest/webhook for talking to bot using REST
|
| 100 |
+
#curl -X POST localhost:5005/webhooks/rest/webhook -H "Content-type:application/json" -d "{\"sender\": \"test_user\", \"message\": \"Hi\"}"
|
rasa_bot/data/rules.yml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
rules:
|
| 2 |
+
|
| 3 |
+
- rule: START
|
| 4 |
+
steps:
|
| 5 |
+
- intent: greet
|
| 6 |
+
- action: utter_greet
|
| 7 |
+
|
| 8 |
+
- rule: EXPLORE
|
| 9 |
+
steps:
|
| 10 |
+
- intent: explore
|
| 11 |
+
- action: utter_explore
|
| 12 |
+
- action: action_display_info
|
| 13 |
+
- action: action_restart
|
| 14 |
+
|
| 15 |
+
- rule: TAKE PICTURE
|
| 16 |
+
steps:
|
| 17 |
+
- intent: take_picture
|
| 18 |
+
- action: utter_picture
|
| 19 |
+
- action: action_display_info
|
| 20 |
+
- action: action_restart
|
| 21 |
+
|
| 22 |
+
- rule: MONITOR
|
| 23 |
+
steps:
|
| 24 |
+
- intent: monitor
|
| 25 |
+
- action: utter_monitor
|
| 26 |
+
- action: action_display_info
|
| 27 |
+
- action: action_restart
|
| 28 |
+
|
| 29 |
+
- rule: respond to safety/feedback request
|
| 30 |
+
steps:
|
| 31 |
+
- intent: move
|
| 32 |
+
- action: utter_move
|
| 33 |
+
- action: action_display_info
|
| 34 |
+
- action: action_restart
|
| 35 |
+
|
| 36 |
+
- rule: Ask the user to rephrase whenever they send a message with low NLU confidence
|
| 37 |
+
steps:
|
| 38 |
+
- intent: nlu_fallback
|
| 39 |
+
- action: utter_please_rephrase
|
rasa_bot/data/stories.yml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
rasa_bot/domain.yml
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
entities:
|
| 2 |
+
- building
|
| 3 |
+
- location
|
| 4 |
+
- picture_type
|
| 5 |
+
|
| 6 |
+
slots:
|
| 7 |
+
location:
|
| 8 |
+
type: text
|
| 9 |
+
influence_conversation: false
|
| 10 |
+
mappings:
|
| 11 |
+
- type: from_entity
|
| 12 |
+
entity: location
|
| 13 |
+
building:
|
| 14 |
+
type: text
|
| 15 |
+
influence_conversation: false
|
| 16 |
+
mappings:
|
| 17 |
+
- type: from_entity
|
| 18 |
+
entity: building
|
| 19 |
+
picture_type:
|
| 20 |
+
type: text
|
| 21 |
+
influence_conversation: false
|
| 22 |
+
mappings:
|
| 23 |
+
- type: from_entity
|
| 24 |
+
entity: picture_type
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
intents:
|
| 28 |
+
- explore
|
| 29 |
+
- goodbye
|
| 30 |
+
- greet
|
| 31 |
+
- take_picture
|
| 32 |
+
- monitor
|
| 33 |
+
- move
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
responses:
|
| 37 |
+
utter_greet:
|
| 38 |
+
- text: "Enter instruction"
|
| 39 |
+
utter_explore:
|
| 40 |
+
- condition:
|
| 41 |
+
- type: slot
|
| 42 |
+
name: location
|
| 43 |
+
value: null
|
| 44 |
+
text: "Exploring the {building}"
|
| 45 |
+
- condition:
|
| 46 |
+
- type: slot
|
| 47 |
+
name: building
|
| 48 |
+
value: null
|
| 49 |
+
text: "Exploring the {location}"
|
| 50 |
+
- text: "Exploring the {location} of the {building}."
|
| 51 |
+
utter_picture:
|
| 52 |
+
- condition:
|
| 53 |
+
- type: slot
|
| 54 |
+
name: location
|
| 55 |
+
value: null
|
| 56 |
+
text: "Taking {picture_type}"
|
| 57 |
+
- text: "Taking {picture_type} of {location}"
|
| 58 |
+
utter_monitor:
|
| 59 |
+
- condition:
|
| 60 |
+
- type: slot
|
| 61 |
+
name: location
|
| 62 |
+
value: null
|
| 63 |
+
text: "Monitoring the location"
|
| 64 |
+
- text: "Monitoring the {location}"
|
| 65 |
+
utter_move/stop:
|
| 66 |
+
- text: "Stopping"
|
| 67 |
+
utter_move/land:
|
| 68 |
+
- text: "Landing"
|
| 69 |
+
utter_move/come_back:
|
| 70 |
+
- text: "Returning"
|
| 71 |
+
utter_move/left:
|
| 72 |
+
- text: "Moving left"
|
| 73 |
+
utter_move/right:
|
| 74 |
+
- text: "Moving right"
|
| 75 |
+
utter_move/up:
|
| 76 |
+
- text: "Moving up"
|
| 77 |
+
utter_move/down:
|
| 78 |
+
- text: "Moving down"
|
| 79 |
+
utter_move/get_closer:
|
| 80 |
+
- text: "Moving closer"
|
| 81 |
+
utter_please_rephrase:
|
| 82 |
+
- text: "Could not verify intent, please try again"
|
| 83 |
+
|
| 84 |
+
actions:
|
| 85 |
+
- action_display_info
|
| 86 |
+
|
| 87 |
+
session_config:
|
| 88 |
+
session_expiration_time: 60
|
| 89 |
+
carry_over_slots_to_new_session: false
|
rasa_bot/endpoints.yml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file contains the different endpoints your bot can use.
|
| 2 |
+
|
| 3 |
+
# Server where the models are pulled from.
|
| 4 |
+
# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server
|
| 5 |
+
|
| 6 |
+
#models:
|
| 7 |
+
# url: http://my-server.com/models/default_core@latest
|
| 8 |
+
# wait_time_between_pulls: 10 # [optional](default: 100)
|
| 9 |
+
|
| 10 |
+
# Server which runs your custom actions.
|
| 11 |
+
# https://rasa.com/docs/rasa/custom-actions
|
| 12 |
+
|
| 13 |
+
action_endpoint:
|
| 14 |
+
url: "http://localhost:5055/webhook"
|
| 15 |
+
|
| 16 |
+
# Tracker store which is used to store the conversations.
|
| 17 |
+
# By default the conversations are stored in memory.
|
| 18 |
+
# https://rasa.com/docs/rasa/tracker-stores
|
| 19 |
+
|
| 20 |
+
#tracker_store:
|
| 21 |
+
# type: redis
|
| 22 |
+
# url: <host of the redis instance, e.g. localhost>
|
| 23 |
+
# port: <port of your redis instance, usually 6379>
|
| 24 |
+
# db: <number of your database within redis, e.g. 0>
|
| 25 |
+
# password: <password used for authentication>
|
| 26 |
+
# use_ssl: <whether or not the communication is encrypted, default false>
|
| 27 |
+
|
| 28 |
+
#tracker_store:
|
| 29 |
+
# type: mongod
|
| 30 |
+
# url: <url to your mongo instance, e.g. mongodb://localhost:27017>
|
| 31 |
+
# db: <name of the db within your mongo instance, e.g. rasa>
|
| 32 |
+
# username: <username used for authentication>
|
| 33 |
+
# password: <password used for authentication>
|
| 34 |
+
|
| 35 |
+
# Event broker which all conversation events should be streamed to.
|
| 36 |
+
# https://rasa.com/docs/rasa/event-brokers
|
| 37 |
+
|
| 38 |
+
#event_broker:
|
| 39 |
+
# url: localhost
|
| 40 |
+
# username: username
|
| 41 |
+
# password: password
|
| 42 |
+
# queue: queue
|
rasa_bot/index.html
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div id="rasa-chat-widget" data-websocket-url="http://104.131.188.205:5005/" data-width=1200 data-default-open=true data-initial-payload="Start"></div>
|
| 2 |
+
<script src="https://unpkg.com/@rasahq/rasa-chat" type="application/javascript"></script>
|
rasa_bot/tests/test_stories.yml
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### This file contains tests to evaluate that your bot behaves as expected.
|
| 2 |
+
#### If you want to learn more, please see the docs: https://rasa.com/docs/rasa/testing-your-assistant
|
| 3 |
+
|
| 4 |
+
stories:
|
| 5 |
+
- story: happy path 1
|
| 6 |
+
steps:
|
| 7 |
+
- user: |
|
| 8 |
+
hello there!
|
| 9 |
+
intent: greet
|
| 10 |
+
- action: utter_greet
|
| 11 |
+
- user: |
|
| 12 |
+
amazing
|
| 13 |
+
intent: mood_great
|
| 14 |
+
- action: utter_happy
|
| 15 |
+
|
| 16 |
+
- story: happy path 2
|
| 17 |
+
steps:
|
| 18 |
+
- user: |
|
| 19 |
+
hello there!
|
| 20 |
+
intent: greet
|
| 21 |
+
- action: utter_greet
|
| 22 |
+
- user: |
|
| 23 |
+
amazing
|
| 24 |
+
intent: mood_great
|
| 25 |
+
- action: utter_happy
|
| 26 |
+
- user: |
|
| 27 |
+
bye-bye!
|
| 28 |
+
intent: goodbye
|
| 29 |
+
- action: utter_goodbye
|
| 30 |
+
|
| 31 |
+
- story: sad path 1
|
| 32 |
+
steps:
|
| 33 |
+
- user: |
|
| 34 |
+
hello
|
| 35 |
+
intent: greet
|
| 36 |
+
- action: utter_greet
|
| 37 |
+
- user: |
|
| 38 |
+
not good
|
| 39 |
+
intent: mood_unhappy
|
| 40 |
+
- action: utter_cheer_up
|
| 41 |
+
- action: utter_did_that_help
|
| 42 |
+
- user: |
|
| 43 |
+
yes
|
| 44 |
+
intent: affirm
|
| 45 |
+
- action: utter_happy
|
| 46 |
+
|
| 47 |
+
- story: sad path 2
|
| 48 |
+
steps:
|
| 49 |
+
- user: |
|
| 50 |
+
hello
|
| 51 |
+
intent: greet
|
| 52 |
+
- action: utter_greet
|
| 53 |
+
- user: |
|
| 54 |
+
not good
|
| 55 |
+
intent: mood_unhappy
|
| 56 |
+
- action: utter_cheer_up
|
| 57 |
+
- action: utter_did_that_help
|
| 58 |
+
- user: |
|
| 59 |
+
not really
|
| 60 |
+
intent: deny
|
| 61 |
+
- action: utter_goodbye
|
| 62 |
+
|
| 63 |
+
- story: sad path 3
|
| 64 |
+
steps:
|
| 65 |
+
- user: |
|
| 66 |
+
hi
|
| 67 |
+
intent: greet
|
| 68 |
+
- action: utter_greet
|
| 69 |
+
- user: |
|
| 70 |
+
very terrible
|
| 71 |
+
intent: mood_unhappy
|
| 72 |
+
- action: utter_cheer_up
|
| 73 |
+
- action: utter_did_that_help
|
| 74 |
+
- user: |
|
| 75 |
+
no
|
| 76 |
+
intent: deny
|
| 77 |
+
- action: utter_goodbye
|
| 78 |
+
|
| 79 |
+
- story: say goodbye
|
| 80 |
+
steps:
|
| 81 |
+
- user: |
|
| 82 |
+
bye-bye!
|
| 83 |
+
intent: goodbye
|
| 84 |
+
- action: utter_goodbye
|
| 85 |
+
|
| 86 |
+
- story: bot challenge
|
| 87 |
+
steps:
|
| 88 |
+
- user: |
|
| 89 |
+
are you a bot?
|
| 90 |
+
intent: bot_challenge
|
| 91 |
+
- action: utter_iamabot
|
test/.pytest_cache/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by pytest automatically.
|
| 2 |
+
*
|
test/.pytest_cache/CACHEDIR.TAG
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Signature: 8a477f597d28d172789f06886806bc55
|
| 2 |
+
# This file is a cache directory tag created by pytest.
|
| 3 |
+
# For information about cache directory tags, see:
|
| 4 |
+
# https://bford.info/cachedir/spec.html
|
test/.pytest_cache/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pytest cache directory #
|
| 2 |
+
|
| 3 |
+
This directory contains data from the pytest's cache plugin,
|
| 4 |
+
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
|
| 5 |
+
|
| 6 |
+
**Do not** commit this to version control.
|
| 7 |
+
|
| 8 |
+
See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
|
test/.pytest_cache/v/cache/lastfailed
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"test_chatgpt4uavs.py::test_red_house": true,
|
| 3 |
+
"test_chatgpt4uavs.py::test_take_off": true,
|
| 4 |
+
"test_chatgpt4uavs.py::test_land": true,
|
| 5 |
+
"test_chatgpt4uavs.py::test_picture": true,
|
| 6 |
+
"test_chatgpt4uavs.py::test_snap_pic": true,
|
| 7 |
+
"test_chatgpt4uavs.py::test_purple_house": true,
|
| 8 |
+
"test_chatgpt4uavs.py::test_parking_garage": true,
|
| 9 |
+
"test_chatgpt4uavs.py::test_gym": true,
|
| 10 |
+
"test_chatgpt4uavs.py::test_cease_flight": true,
|
| 11 |
+
"test_chatgpt4uavs.py::test_stop_flight": true,
|
| 12 |
+
"test_chatgpt4uavs.py::test_lift_off": true,
|
| 13 |
+
"test_chatgpt4uavs.py::test_no_location1": true,
|
| 14 |
+
"test_chatgpt4uavs.py::test_no_location2": true,
|
| 15 |
+
"test_chatgpt4uavs.py::test_no_location3": true,
|
| 16 |
+
"test_fewshot.py::test_stop_flight1": true,
|
| 17 |
+
"test_fewshot.py::test_invalid_command2": true,
|
| 18 |
+
"test_fewshot.py::test_location_no_action4": true,
|
| 19 |
+
"test_fewshot.py::test_action_and_location_synonyms": true,
|
| 20 |
+
"test_fewshot.py::test_action_synonyms": true,
|
| 21 |
+
"test_fewshot.py::test_action_and_location": true,
|
| 22 |
+
"test_fewshot.py::test_multiple_actions": true
|
| 23 |
+
}
|
test/.pytest_cache/v/cache/nodeids
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test_chatgpt4uavs.py::test_cease_flight",
|
| 3 |
+
"test_chatgpt4uavs.py::test_gym",
|
| 4 |
+
"test_chatgpt4uavs.py::test_land",
|
| 5 |
+
"test_chatgpt4uavs.py::test_lift_off",
|
| 6 |
+
"test_chatgpt4uavs.py::test_no_location1",
|
| 7 |
+
"test_chatgpt4uavs.py::test_no_location2",
|
| 8 |
+
"test_chatgpt4uavs.py::test_no_location3",
|
| 9 |
+
"test_chatgpt4uavs.py::test_parking_garage",
|
| 10 |
+
"test_chatgpt4uavs.py::test_picture",
|
| 11 |
+
"test_chatgpt4uavs.py::test_purple_house",
|
| 12 |
+
"test_chatgpt4uavs.py::test_red_house",
|
| 13 |
+
"test_chatgpt4uavs.py::test_snap_pic",
|
| 14 |
+
"test_chatgpt4uavs.py::test_stop_flight",
|
| 15 |
+
"test_chatgpt4uavs.py::test_take_off",
|
| 16 |
+
"test_fewshot.py::test_action_and_location",
|
| 17 |
+
"test_fewshot.py::test_action_and_location_synonyms",
|
| 18 |
+
"test_fewshot.py::test_action_synonyms",
|
| 19 |
+
"test_fewshot.py::test_cease_flight",
|
| 20 |
+
"test_fewshot.py::test_empty_input",
|
| 21 |
+
"test_fewshot.py::test_gym",
|
| 22 |
+
"test_fewshot.py::test_invalid_command",
|
| 23 |
+
"test_fewshot.py::test_invalid_command1",
|
| 24 |
+
"test_fewshot.py::test_invalid_command2",
|
| 25 |
+
"test_fewshot.py::test_land",
|
| 26 |
+
"test_fewshot.py::test_lift_off",
|
| 27 |
+
"test_fewshot.py::test_location_no_action",
|
| 28 |
+
"test_fewshot.py::test_location_no_action2",
|
| 29 |
+
"test_fewshot.py::test_location_no_action3",
|
| 30 |
+
"test_fewshot.py::test_location_no_action4",
|
| 31 |
+
"test_fewshot.py::test_multiple_actions",
|
| 32 |
+
"test_fewshot.py::test_multiple_actions1",
|
| 33 |
+
"test_fewshot.py::test_multiple_actions2",
|
| 34 |
+
"test_fewshot.py::test_multiple_actions3",
|
| 35 |
+
"test_fewshot.py::test_multiple_actions4",
|
| 36 |
+
"test_fewshot.py::test_multiple_actions5",
|
| 37 |
+
"test_fewshot.py::test_multiple_actions_and_locations",
|
| 38 |
+
"test_fewshot.py::test_multiple_actions_and_locations1",
|
| 39 |
+
"test_fewshot.py::test_multiple_actions_and_locations2",
|
| 40 |
+
"test_fewshot.py::test_no_location1",
|
| 41 |
+
"test_fewshot.py::test_no_location2",
|
| 42 |
+
"test_fewshot.py::test_no_location3",
|
| 43 |
+
"test_fewshot.py::test_no_location4",
|
| 44 |
+
"test_fewshot.py::test_parking_garage",
|
| 45 |
+
"test_fewshot.py::test_picture",
|
| 46 |
+
"test_fewshot.py::test_purple_house",
|
| 47 |
+
"test_fewshot.py::test_red_house",
|
| 48 |
+
"test_fewshot.py::test_snap_pic",
|
| 49 |
+
"test_fewshot.py::test_stop_flight",
|
| 50 |
+
"test_fewshot.py::test_stop_flight1",
|
| 51 |
+
"test_fewshot.py::test_take_off",
|
| 52 |
+
"test_fewshot.py::test_take_off_synonym",
|
| 53 |
+
"test_fewshot.py::test_two_go_to",
|
| 54 |
+
"test_fewshot.py::test_with_extra_words",
|
| 55 |
+
"test_fewshot.py::test_with_extra_words2"
|
| 56 |
+
]
|
test/.pytest_cache/v/cache/stepwise
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[]
|
test/__pycache__/test_chatgpt4uavs.cpython-311-pytest-7.4.0.pyc
ADDED
|
Binary file (12.5 kB). View file
|
|
|
test/__pycache__/test_fewshot.cpython-311-pytest-7.4.0.pyc
ADDED
|
Binary file (25 kB). View file
|
|
|
test/commands.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
command: GOTO park
|
| 3 |
+
command: TAKEPICTURE red house
|
test/test_chatgpt4uavs.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
import re
|
| 3 |
+
from chatgpt4uavs import get_command
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# format: command: <command> \t<goal>
|
| 7 |
+
def parse_command(text):
|
| 8 |
+
tokens = re.split(' \t|\n|: ', text.lower())
|
| 9 |
+
print(tokens)
|
| 10 |
+
assert tokens[1] == 'command'
|
| 11 |
+
return tokens[2]
|
| 12 |
+
|
| 13 |
+
def test_red_house():
|
| 14 |
+
text = "Go to the red house on W Broad St."
|
| 15 |
+
output = get_command(text)
|
| 16 |
+
command = parse_command(output)
|
| 17 |
+
assert command == "go to"
|
| 18 |
+
|
| 19 |
+
def test_take_off():
|
| 20 |
+
text = "Take off from where you are."
|
| 21 |
+
output = get_command(text)
|
| 22 |
+
command = parse_command(output)
|
| 23 |
+
assert command == "take off"
|
| 24 |
+
|
| 25 |
+
def test_land():
|
| 26 |
+
text = "Land now."
|
| 27 |
+
output = get_command(text)
|
| 28 |
+
command = parse_command(output)
|
| 29 |
+
assert command == "land"
|
| 30 |
+
|
| 31 |
+
def test_picture():
|
| 32 |
+
text = "Take a picture."
|
| 33 |
+
output = get_command(text)
|
| 34 |
+
command = parse_command(output)
|
| 35 |
+
assert command == "take picture"
|
| 36 |
+
|
| 37 |
+
def test_snap_pic():
|
| 38 |
+
text = "Snap a photo."
|
| 39 |
+
output = get_command(text)
|
| 40 |
+
command = parse_command(output)
|
| 41 |
+
assert command == "take picture"
|
| 42 |
+
|
| 43 |
+
def test_purple_house():
|
| 44 |
+
text = "Travel to the purple house on the left side."
|
| 45 |
+
output = get_command(text)
|
| 46 |
+
command = parse_command(output)
|
| 47 |
+
assert command == "go to"
|
| 48 |
+
|
| 49 |
+
def test_parking_garage():
|
| 50 |
+
text = "Fly to the parking garage across the street."
|
| 51 |
+
output = get_command(text)
|
| 52 |
+
command = parse_command(output)
|
| 53 |
+
assert command == "go to"
|
| 54 |
+
|
| 55 |
+
def test_gym():
|
| 56 |
+
text = "Check out the Cary St Gym."
|
| 57 |
+
output = get_command(text)
|
| 58 |
+
command = parse_command(output)
|
| 59 |
+
assert command == "go to"
|
| 60 |
+
|
| 61 |
+
def test_cease_flight():
|
| 62 |
+
text = "Cease flight."
|
| 63 |
+
output = get_command(text)
|
| 64 |
+
command = parse_command(output)
|
| 65 |
+
assert command == "land"
|
| 66 |
+
|
| 67 |
+
def test_stop_flight():
|
| 68 |
+
text = "Stop the flight."
|
| 69 |
+
output = get_command(text)
|
| 70 |
+
command = parse_command(output)
|
| 71 |
+
assert command == "land"
|
| 72 |
+
|
| 73 |
+
def test_lift_off():
|
| 74 |
+
text = "Lift off."
|
| 75 |
+
output = get_command(text)
|
| 76 |
+
command = parse_command(output)
|
| 77 |
+
assert command == "take off"
|
| 78 |
+
|
| 79 |
+
def test_no_location1():
|
| 80 |
+
text = "Check out."
|
| 81 |
+
output = get_command(text)
|
| 82 |
+
command = parse_command(output)
|
| 83 |
+
assert command == "None"
|
| 84 |
+
|
| 85 |
+
def test_no_location2():
|
| 86 |
+
text = "Go to"
|
| 87 |
+
output = get_command(text)
|
| 88 |
+
command = parse_command(output)
|
| 89 |
+
assert command == "None"
|
| 90 |
+
|
| 91 |
+
def test_no_location3():
|
| 92 |
+
text = "Travel to"
|
| 93 |
+
output = get_command(text)
|
| 94 |
+
command = parse_command(output)
|
| 95 |
+
assert command == "None"
|
test/test_fewshot.py
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
import re
|
| 3 |
+
from fewshot import FewShot4UAVs
|
| 4 |
+
|
| 5 |
+
@pytest.fixture
|
| 6 |
+
def fewshot():
|
| 7 |
+
return FewShot4UAVs()
|
| 8 |
+
|
| 9 |
+
# format: <command> \t<goal>
|
| 10 |
+
|
| 11 |
+
# For testing sentences with one action
|
| 12 |
+
def parse_command(text):
|
| 13 |
+
tokens = re.split(' \t|\n|: ', text.lower())
|
| 14 |
+
print(tokens)
|
| 15 |
+
if len(tokens) >= 2 and tokens[1] == 'command':
|
| 16 |
+
return tokens[2]
|
| 17 |
+
else:
|
| 18 |
+
return 'None'
|
| 19 |
+
|
| 20 |
+
# For testing sentences with multiple actions
|
| 21 |
+
def parse_multiple_commands(text):
|
| 22 |
+
text = text.lstrip('\n')
|
| 23 |
+
lines = text.split("\n")
|
| 24 |
+
first_action = lines[0].split()[1].lower()
|
| 25 |
+
second_action = lines[1].split()[1].lower()
|
| 26 |
+
return first_action, second_action
|
| 27 |
+
|
| 28 |
+
def test_red_house(fewshot):
|
| 29 |
+
text = "Go to the red house on W Broad St."
|
| 30 |
+
output = fewshot.get_command(text)
|
| 31 |
+
command = parse_command(output)
|
| 32 |
+
assert command == "goto"
|
| 33 |
+
|
| 34 |
+
def test_take_off(fewshot):
|
| 35 |
+
text = "Take off from where you are."
|
| 36 |
+
output = fewshot.get_command(text)
|
| 37 |
+
command = parse_command(output)
|
| 38 |
+
assert command == "takeoff"
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def test_land(fewshot):
|
| 42 |
+
text = "Land now."
|
| 43 |
+
output = fewshot.get_command(text)
|
| 44 |
+
command = parse_command(output)
|
| 45 |
+
assert command == "land"
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def test_picture(fewshot):
|
| 49 |
+
text = "Take a picture."
|
| 50 |
+
output = fewshot.get_command(text)
|
| 51 |
+
command = parse_command(output)
|
| 52 |
+
assert command == "None"
|
| 53 |
+
|
| 54 |
+
# Testing actions using synonyms
|
| 55 |
+
def test_take_off_synonym(fewshot):
|
| 56 |
+
text = "Lift off."
|
| 57 |
+
output = fewshot.get_command(text)
|
| 58 |
+
command = parse_command(output)
|
| 59 |
+
assert command == "takeoff"
|
| 60 |
+
|
| 61 |
+
def test_snap_pic(fewshot):
|
| 62 |
+
text = "Snap a photo."
|
| 63 |
+
output = fewshot.get_command(text)
|
| 64 |
+
command = parse_command(output)
|
| 65 |
+
assert command == "None"
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def test_purple_house(fewshot):
|
| 69 |
+
text = "Travel to the purple house on the left side."
|
| 70 |
+
output = fewshot.get_command(text)
|
| 71 |
+
command = parse_command(output)
|
| 72 |
+
assert command == "goto"
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def test_parking_garage(fewshot):
|
| 76 |
+
text = "Fly to the parking garage across the street."
|
| 77 |
+
output = fewshot.get_command(text)
|
| 78 |
+
command = parse_command(output)
|
| 79 |
+
assert command == "goto"
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def test_gym(fewshot):
|
| 83 |
+
text = "Check out the Cary St Gym."
|
| 84 |
+
output = fewshot.get_command(text)
|
| 85 |
+
command = parse_command(output)
|
| 86 |
+
assert command == "goto"
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def test_cease_flight(fewshot):
|
| 90 |
+
text = "Cease flight."
|
| 91 |
+
output = fewshot.get_command(text)
|
| 92 |
+
command = parse_command(output)
|
| 93 |
+
assert command == "land"
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def test_stop_flight(fewshot):
|
| 97 |
+
text = "Stop the flight."
|
| 98 |
+
output = fewshot.get_command(text)
|
| 99 |
+
command = parse_command(output)
|
| 100 |
+
assert command == "land"
|
| 101 |
+
|
| 102 |
+
# Testing actions with no location
|
| 103 |
+
def test_no_location1(fewshot):
|
| 104 |
+
text = "Check out."
|
| 105 |
+
output = fewshot.get_command(text)
|
| 106 |
+
command = parse_command(output)
|
| 107 |
+
assert command == "None"
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def test_no_location2(fewshot):
|
| 111 |
+
text = "Go to."
|
| 112 |
+
output = fewshot.get_command(text)
|
| 113 |
+
command = parse_command(output)
|
| 114 |
+
assert command == "None"
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def test_no_location3(fewshot):
|
| 118 |
+
text = "Travel to."
|
| 119 |
+
output = fewshot.get_command(text)
|
| 120 |
+
command = parse_command(output)
|
| 121 |
+
assert command == "None"
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def test_no_location4(fewshot):
|
| 125 |
+
text = "Head to."
|
| 126 |
+
output = fewshot.get_command(text)
|
| 127 |
+
command = parse_command(output)
|
| 128 |
+
assert command == "None"
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
# Testing invalid commands
|
| 132 |
+
def test_empty_input(fewshot):
|
| 133 |
+
text = ""
|
| 134 |
+
output = fewshot.get_command(text)
|
| 135 |
+
command = parse_command(output)
|
| 136 |
+
assert command == "None"
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def test_invalid_command(fewshot):
|
| 140 |
+
text = "Do something."
|
| 141 |
+
output = fewshot.get_command(text)
|
| 142 |
+
command = parse_command(output)
|
| 143 |
+
assert command == "None"
|
| 144 |
+
|
| 145 |
+
# Testing locations with no action specifically stated
|
| 146 |
+
def test_location_no_action(fewshot):
|
| 147 |
+
text = "Willow Lawn."
|
| 148 |
+
output = fewshot.get_command(text)
|
| 149 |
+
command = parse_command(output)
|
| 150 |
+
assert command == "goto"
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def test_location_no_action2(fewshot):
|
| 154 |
+
text = "Whole Foods on W Broad St."
|
| 155 |
+
output = fewshot.get_command(text)
|
| 156 |
+
command = parse_command(output)
|
| 157 |
+
assert command == "goto"
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def test_location_no_action3(fewshot):
|
| 161 |
+
text = "Starbucks at N Robinson St."
|
| 162 |
+
output = fewshot.get_command(text)
|
| 163 |
+
command = parse_command(output)
|
| 164 |
+
assert command == "goto"
|
| 165 |
+
|
| 166 |
+
# Testing with filler words
|
| 167 |
+
def test_with_extra_words(fewshot):
|
| 168 |
+
text = "Please go to the Whole Foods on W Broad St."
|
| 169 |
+
output = fewshot.get_command(text)
|
| 170 |
+
command = parse_command(output)
|
| 171 |
+
assert command == "goto"
|
| 172 |
+
|
| 173 |
+
def test_with_extra_words2(fewshot):
|
| 174 |
+
text = "Go to the Whole Foods on W Broad St please."
|
| 175 |
+
output = fewshot.get_command(text)
|
| 176 |
+
command = parse_command(output)
|
| 177 |
+
assert command == "goto"
|
| 178 |
+
|
| 179 |
+
# Testing multiple actions at the same location
|
| 180 |
+
def test_multiple_actions1(fewshot):
|
| 181 |
+
text = "Check out the Starbucks and then land."
|
| 182 |
+
output = fewshot.get_command(text)
|
| 183 |
+
command = parse_multiple_commands(output)
|
| 184 |
+
assert command == ("goto", "land")
|
| 185 |
+
|
| 186 |
+
def test_multiple_actions2(fewshot):
|
| 187 |
+
text = "Take a picture of the green shed and then take off."
|
| 188 |
+
output = fewshot.get_command(text)
|
| 189 |
+
command = parse_multiple_commands(output)
|
| 190 |
+
assert command == ("takepicture", "takeoff")
|
| 191 |
+
|
| 192 |
+
def test_multiple_actions3(fewshot):
|
| 193 |
+
text = "Go to the park and take a picture."
|
| 194 |
+
output = fewshot.get_command(text)
|
| 195 |
+
command = parse_multiple_commands(output)
|
| 196 |
+
assert command == ("goto", "takepicture")
|
| 197 |
+
|
| 198 |
+
def test_multiple_actions4(fewshot):
|
| 199 |
+
text = "Take a photo and then land."
|
| 200 |
+
output = fewshot.get_command(text)
|
| 201 |
+
command = parse_multiple_commands(output)
|
| 202 |
+
assert command == ("takepicture", "land")
|
| 203 |
+
|
| 204 |
+
def test_multiple_actions5(fewshot):
|
| 205 |
+
text = "Rise and then take a photo."
|
| 206 |
+
output = fewshot.get_command(text)
|
| 207 |
+
command = parse_multiple_commands(output)
|
| 208 |
+
assert command == ("takeoff", "takepicture")
|
| 209 |
+
|
| 210 |
+
# Testing multiple actions with different locations
|
| 211 |
+
def test_multiple_actions_and_locations1(fewshot):
|
| 212 |
+
text = "Go to the maroon shack on Osborn Rd and then take a picture of Thomas Dale High School."
|
| 213 |
+
output = fewshot.get_command(text)
|
| 214 |
+
command = parse_multiple_commands(output)
|
| 215 |
+
assert command == ("goto", "takepicture")
|
| 216 |
+
|
| 217 |
+
def test_multiple_actions_and_locations2(fewshot):
|
| 218 |
+
text = "Travel to the park and take a picture of the red house."
|
| 219 |
+
output = fewshot.get_command(text)
|
| 220 |
+
command = parse_multiple_commands(output)
|
| 221 |
+
assert command == ("goto", "takepicture")
|