kdamevski commited on
Commit
31a8d29
·
1 Parent(s): 2d144e4

Upload folder using huggingface_hub

Browse files
.pytest_cache/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Created by pytest automatically.
2
+ *
.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
.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.
.pytest_cache/v/cache/lastfailed ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "test/test_chatgpt4uavs.py::test_red_house": true,
3
+ "test/test_chatgpt4uavs.py::test_take_off": true,
4
+ "test/test_chatgpt4uavs.py::test_land": true,
5
+ "test/test_chatgpt4uavs.py::test_picture": true,
6
+ "test/test_chatgpt4uavs.py::test_snap_pic": true,
7
+ "test/test_chatgpt4uavs.py::test_purple_house": true,
8
+ "test/test_chatgpt4uavs.py::test_parking_garage": true,
9
+ "test/test_chatgpt4uavs.py::test_gym": true,
10
+ "test/test_chatgpt4uavs.py::test_cease_flight": true,
11
+ "test/test_chatgpt4uavs.py::test_stop_flight": true,
12
+ "test/test_chatgpt4uavs.py::test_lift_off": true,
13
+ "test/test_chatgpt4uavs.py::test_no_location1": true,
14
+ "test/test_chatgpt4uavs.py::test_no_location2": true,
15
+ "test/test_chatgpt4uavs.py::test_no_location3": true,
16
+ "test/test_fewshot.py::test_multiple_actions": true,
17
+ "test/test_fewshot.py::test_multiple_actions_and_locations": true,
18
+ "test/test_fewshot.py::test_action_and_location": true,
19
+ "test/test_fewshot.py::test_action_and_location_synonyms": true,
20
+ "test/test_fewshot.py::test_action_synonyms": true,
21
+ "test/test_fewshot.py::test_action_synonyms2": true,
22
+ "test/test_fewshot.py::test_action_synonyms3": true,
23
+ "test/test_fewshot.py::test_red_house": true,
24
+ "test/test_fewshot.py::test_land": true,
25
+ "test/test_fewshot.py::test_purple_house": true,
26
+ "test/test_fewshot.py::test_parking_garage": true,
27
+ "test/test_fewshot.py::test_gym": true,
28
+ "test/test_fewshot.py::test_cease_flight": true,
29
+ "test/test_fewshot.py::test_no_location1": true,
30
+ "test/test_fewshot.py::test_no_location3": true,
31
+ "test/test_fewshot.py::test_location_no_action": true,
32
+ "test/test_fewshot.py::test_location_no_action2": true,
33
+ "test/test_fewshot.py::test_location_no_action3": true,
34
+ "test/test_fewshot.py::test_with_extra_words2": true
35
+ }
.pytest_cache/v/cache/nodeids ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "test/test_chatgpt4uavs.py::test_cease_flight",
3
+ "test/test_chatgpt4uavs.py::test_gym",
4
+ "test/test_chatgpt4uavs.py::test_land",
5
+ "test/test_chatgpt4uavs.py::test_lift_off",
6
+ "test/test_chatgpt4uavs.py::test_no_location1",
7
+ "test/test_chatgpt4uavs.py::test_no_location2",
8
+ "test/test_chatgpt4uavs.py::test_no_location3",
9
+ "test/test_chatgpt4uavs.py::test_parking_garage",
10
+ "test/test_chatgpt4uavs.py::test_picture",
11
+ "test/test_chatgpt4uavs.py::test_purple_house",
12
+ "test/test_chatgpt4uavs.py::test_red_house",
13
+ "test/test_chatgpt4uavs.py::test_snap_pic",
14
+ "test/test_chatgpt4uavs.py::test_stop_flight",
15
+ "test/test_chatgpt4uavs.py::test_take_off",
16
+ "test/test_fewshot.py::test_action_and_location",
17
+ "test/test_fewshot.py::test_action_and_location_synonyms",
18
+ "test/test_fewshot.py::test_action_synonyms",
19
+ "test/test_fewshot.py::test_action_synonyms2",
20
+ "test/test_fewshot.py::test_action_synonyms3",
21
+ "test/test_fewshot.py::test_cease_flight",
22
+ "test/test_fewshot.py::test_empty_input",
23
+ "test/test_fewshot.py::test_gym",
24
+ "test/test_fewshot.py::test_invalid_command",
25
+ "test/test_fewshot.py::test_land",
26
+ "test/test_fewshot.py::test_lift_off",
27
+ "test/test_fewshot.py::test_location_no_action",
28
+ "test/test_fewshot.py::test_location_no_action2",
29
+ "test/test_fewshot.py::test_location_no_action3",
30
+ "test/test_fewshot.py::test_multiple_actions",
31
+ "test/test_fewshot.py::test_multiple_actions_and_locations",
32
+ "test/test_fewshot.py::test_no_location1",
33
+ "test/test_fewshot.py::test_no_location2",
34
+ "test/test_fewshot.py::test_no_location3",
35
+ "test/test_fewshot.py::test_no_location4",
36
+ "test/test_fewshot.py::test_parking_garage",
37
+ "test/test_fewshot.py::test_picture",
38
+ "test/test_fewshot.py::test_purple_house",
39
+ "test/test_fewshot.py::test_red_house",
40
+ "test/test_fewshot.py::test_snap_pic",
41
+ "test/test_fewshot.py::test_stop_flight",
42
+ "test/test_fewshot.py::test_take_off",
43
+ "test/test_fewshot.py::test_take_off_synonym",
44
+ "test/test_fewshot.py::test_two_go_to",
45
+ "test/test_fewshot.py::test_with_extra_words",
46
+ "test/test_fewshot.py::test_with_extra_words2"
47
+ ]
.pytest_cache/v/cache/stepwise ADDED
@@ -0,0 +1 @@
 
 
1
+ []
README.md CHANGED
@@ -2,5 +2,5 @@
2
  title: conversational_uav_explorer
3
  app_file: app.py
4
  sdk: gradio
5
- sdk_version: 3.34.0
6
  ---
 
2
  title: conversational_uav_explorer
3
  app_file: app.py
4
  sdk: gradio
5
+ sdk_version: 3.35.2
6
  ---
__pycache__/chatgpt4uavs.cpython-311.pyc CHANGED
Binary files a/__pycache__/chatgpt4uavs.cpython-311.pyc and b/__pycache__/chatgpt4uavs.cpython-311.pyc differ
 
__pycache__/fewshot.cpython-311.pyc CHANGED
Binary files a/__pycache__/fewshot.cpython-311.pyc and b/__pycache__/fewshot.cpython-311.pyc differ
 
__pycache__/maps.cpython-311.pyc CHANGED
Binary files a/__pycache__/maps.cpython-311.pyc and b/__pycache__/maps.cpython-311.pyc differ
 
__pycache__/prompts.cpython-311.pyc CHANGED
Binary files a/__pycache__/prompts.cpython-311.pyc and b/__pycache__/prompts.cpython-311.pyc differ
 
commands.txt CHANGED
@@ -1 +0,0 @@
1
- NONE
 
 
fewshot.py CHANGED
@@ -11,7 +11,7 @@ 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(
 
11
 
12
  def __init__(self) -> None:
13
  os.environ["OPENAI_API_KEY"] = "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"
14
+ self.llm = OpenAI(model_name="text-davinci-003", temperature=0.0)
15
 
16
  def get_transcription(self, text):
17
  transcribe_prompt = PromptTemplate(
prompts.py CHANGED
@@ -9,14 +9,16 @@ Transcription: {text}
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
 
@@ -41,84 +43,84 @@ 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
  {
@@ -139,27 +141,27 @@ examples_few_shot = [
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.",
@@ -172,65 +174,65 @@ examples_few_shot = [
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
- ]
 
 
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" (Take picture), "TAKEOFF" (Take off), "LAND" (Land) or "GOTO" (Go to).
 
 
 
 
 
13
 
14
+ If the action is not one of those actions return "NONE".
15
+
16
+ If the action is "TAKEOFF" (Take off), "LAND" (Land), or "NONE" you don't need any further information for the location.
17
+ If the action is "GOTO" (Go to) or "TAKEPICTURE" (Take picture), you'll need to find where to carry out the action.
18
+
19
+ If the action is "GOTO" (Go to) or "TAKEPICTURE" (Take picture) with no location following it, return "NONE".
20
+
21
+ If you can't find the actions "TAKEPICTURE" (Take picture), "TAKEOFF" (Take off), "LAND" (Land), or "GOTO" (Go to), return "NONE".
22
 
23
  You need to return the command in this format: <command> \t<goal>
24
 
 
43
  # Location only
44
  {
45
  "sentence": "Kroger on N Lombardy St.",
46
+ "command": "GOTO \tKroger on N Lombardy St"
47
  },
48
  {
49
  "sentence": "CVS at Main St.",
50
+ "command": "GOTO \tCVS at Main St"
51
  },
52
  {
53
  "sentence": "Short Pump Town Center.",
54
+ "command": "GOTO \tShort Pump Town Center"
55
  },
56
  {
57
  "sentence": "Can Can Brasserie.",
58
+ "command": "GOTO \tCan Can Brasserie"
59
  },
60
  {
61
  "sentence": "Walgreens.",
62
+ "command": "GOTO \tWalgreens"
63
  },
64
  {
65
  "sentence": "Best Buy in Colonial Heights.",
66
+ "command": "GOTO \tBest Buy in Colonial Heights"
67
  },
68
  {
69
  "sentence": "The red house to the left.",
70
+ "command": "GOTO \tred house to the left"
71
  },
72
  {
73
  "sentence": "The Science Museum.",
74
+ "command": "GOTO \tScience Museum"
75
  },
76
  {
77
  "sentence": "South Park Mall.",
78
+ "command": "GOTO \tSouth Park Mall"
79
  },
80
  # Commands that don't require a location
81
  {
82
  "sentence": "Take off now.",
83
+ "command": "TAKEOFF"
84
  },
85
  {
86
  "sentence": "Take off from where you are.",
87
+ "command": "TAKEOFF"
88
  },
89
  {
90
  "sentence": "Take off.",
91
+ "command": "TAKEOFF"
92
  },
93
  {
94
  "sentence": "Take off at your position.",
95
+ "command": "TAKEOFF"
96
  },
97
  {
98
  "sentence": "Take off from where you are at.",
99
+ "command": "TAKEOFF"
100
  },
101
  {
102
  "sentence": "Lift off.",
103
+ "command": "TAKEOFF"
104
  },
105
  {
106
  "sentence": "Land now.",
107
+ "command": "LAND"
108
  },
109
  {
110
  "sentence": "Cease flight.",
111
+ "command": "LAND"
112
  },
113
  {
114
  "sentence": "Stop the flight.",
115
+ "command": "LAND"
116
  },
117
  {
118
  "sentence": "Stop flying.",
119
+ "command": "LAND"
120
  },
121
  {
122
  "sentence": "Take flight.",
123
+ "command": "TAKEOFF"
124
  },
125
  # Commands that require a location but don't have any
126
  {
 
141
  },
142
  {
143
  "sentence": "Proceed to.",
144
+ "command": "NONE"
145
  },
146
  {
147
  "sentence": "Push to.",
148
+ "command": "NONE"
149
  },
150
  {
151
  "sentence": "Advance to.",
152
+ "command": "NONE"
153
  },
154
  {
155
  "sentence": "Make your way to.",
156
+ "command": "NONE"
157
  },
158
  {
159
  "sentence": "Travel to.",
160
+ "command": "NONE"
161
  },
162
  {
163
  "sentence": "Go to.",
164
+ "command": "NONE"
165
  },
166
  {
167
  "sentence": "Take a picture.",
 
174
  # Commands with one action and one location
175
  {
176
  "sentence": "Fly to the Sonic on West Cary St.",
177
+ "command": "GOTO \tSonic on West Cary St."
178
  },
179
  {
180
  "sentence": "Check out the gym at Cary St.",
181
+ "command": "GOTO \tgym at Cary St"
182
  },
183
  {
184
  "sentence": "Investigate the Rite Aid on Broad and Belevidere.",
185
+ "command": "GOTO \tRite Aid on Broad and Belevidere"
186
  },
187
  {
188
  "sentence": "Go to Papa Johns at 1200 W Main St.",
189
+ "command": "GOTO \tPapa Johns at 1200 W Main St"
190
  },
191
  {
192
  "sentence": "Go to the orange house on W Grace St.",
193
+ "command": "GOTO \torange house on W Grace St"
194
  },
195
  {
196
  "sentence": "Travel to Cabell Library at VCU.",
197
+ "command": "GOTO \tCabell Library at VCU"
198
  },
 
199
  {
200
+ "sentence": "Take a picture of the park.",
201
+ "command": "TAKEPICTURE \tpark"
202
  },
 
203
  {
204
+ "sentence": "Take a picture of the Kroger on Lombardy St.",
205
+ "command": "TAKEPICTURE \tKroger on Lombardy St"
206
  },
207
+ # Commands with one action and one location but with extra words
208
  {
209
+ "sentence": "Please check out the CVS on W Broad St.",
210
+ "command": "GOTO \tCVS on W Broad St"
211
  },
212
+ # Commands with multiple actions
213
  {
214
+ "sentence": "Go to the purple house on to the left and take a picture.",
215
+ "command": "GOTO \tpurple house on to the left\nTAKEPICTURE \tpurple house on to the left"
216
  },
217
  {
218
+ "sentence": "Go to Kroger on Iron Bridge and take a picture.",
219
+ "command": "GOTO \tKroger on Iron Bridge\nTAKEPICTURE \tKroger on Iron Bridge"
220
  },
 
221
  {
222
+ "sentence": "Take a picture of the light blue building on Harrowgate Road, then go to the Wawa on Route 1.",
223
+ "command": "TAKEPICTURE \tlight blue building on Harrowgate Road\nGOTO \tWawa on Route 1"
224
  },
225
  {
226
+ "sentence": "Check out the yellow house on Clay St, then go to the Commons on W Main St.",
227
+ "command": "GOTO \tyellow house on Clay St\nGOTO \tCommons on W Main St"
228
  },
229
  {
230
  "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.",
231
+ "command": "GOTO \t7/11 on W Grace St\nGOTO \tBarnes and Noble on W Broad S\nTAKEPICTURE \tBarnes and Noble on W Broad St"
232
  },
233
  {
234
  "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.",
235
+ "command": "GOTO \tgrey one story flat on Happy Hill Rd\nGOTO \tFood Lion on Happy Hill Rd\nTAKEPICTURE \tFood Lion on Happy Hill Rd"
236
  }
237
+ # Commands with multiple actions and multiple locations
238
+ ]
requirements.txt ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.1.0
2
+ aiohttp==3.8.4
3
+ aiosignal==1.3.1
4
+ altair==5.0.1
5
+ aniso8601==9.0.1
6
+ antlr4-python3-runtime==4.9.3
7
+ anyio==3.6.2
8
+ argilla==1.1.1
9
+ async-timeout==4.0.2
10
+ attrs==23.1.0
11
+ backoff==2.2.1
12
+ certifi==2023.5.7
13
+ cffi==1.15.1
14
+ chardet==5.1.0
15
+ charset-normalizer==3.1.0
16
+ chromadb==0.3.25
17
+ click==8.1.3
18
+ clickhouse-connect==0.5.25
19
+ coloredlogs==15.0.1
20
+ contourpy==1.0.7
21
+ cryptography==40.0.2
22
+ cycler==0.11.0
23
+ dataclasses-json==0.5.7
24
+ Deprecated==1.2.13
25
+ duckdb==0.8.0
26
+ effdet==0.4.1
27
+ et-xmlfile==1.1.0
28
+ fastapi==0.95.2
29
+ ffmpeg-python==0.2.0
30
+ ffmpy==0.3.0
31
+ filelock==3.12.0
32
+ Flask==2.2.3
33
+ Flask-RESTful==0.3.10
34
+ flatbuffers==23.5.9
35
+ fonttools==4.39.4
36
+ frozenlist==1.3.3
37
+ fsspec==2023.5.0
38
+ future==0.18.3
39
+ gradio==3.35.2
40
+ gradio_client==0.2.7
41
+ h11==0.9.0
42
+ hnswlib==0.7.0
43
+ httpcore==0.11.1
44
+ httptools==0.5.0
45
+ httpx==0.15.5
46
+ huggingface-hub==0.14.1
47
+ humanfriendly==10.0
48
+ idna==3.4
49
+ iniconfig==2.0.0
50
+ iopath==0.1.10
51
+ itsdangerous==2.1.2
52
+ Jinja2==3.1.2
53
+ joblib==1.2.0
54
+ jsonschema==4.17.3
55
+ kiwisolver==1.4.4
56
+ langchain==0.0.129
57
+ layoutparser==0.3.4
58
+ linkify-it-py==2.0.2
59
+ llvmlite==0.40.0
60
+ load-dotenv==0.1.0
61
+ lxml==4.9.2
62
+ lz4==4.3.2
63
+ Markdown==3.4.3
64
+ markdown-it-py==2.2.0
65
+ MarkupSafe==2.1.2
66
+ marshmallow==3.19.0
67
+ marshmallow-enum==1.5.1
68
+ matplotlib==3.7.1
69
+ mdit-py-plugins==0.3.3
70
+ mdurl==0.1.2
71
+ monotonic==1.6
72
+ more-itertools==9.1.0
73
+ mpmath==1.3.0
74
+ msg-parser==1.2.0
75
+ multidict==6.0.4
76
+ mypy-extensions==1.0.0
77
+ networkx==3.1
78
+ nltk==3.8.1
79
+ numba==0.57.0
80
+ numpy==1.24.3
81
+ olefile==0.46
82
+ omegaconf==2.3.0
83
+ onnxruntime==1.15.0
84
+ openai==0.27.2
85
+ openai-whisper==20230314
86
+ opencv-python==4.7.0.72
87
+ openpyxl==3.1.2
88
+ orjson==3.9.1
89
+ overrides==7.3.1
90
+ packaging==23.1
91
+ pandas==1.5.3
92
+ pdf2image==1.16.3
93
+ pdfminer.six==20221105
94
+ pdfplumber==0.9.0
95
+ Pillow==9.5.0
96
+ pluggy==1.2.0
97
+ portalocker==2.7.0
98
+ posthog==3.0.1
99
+ protobuf==4.23.1
100
+ pycocotools==2.0.6
101
+ pycparser==2.21
102
+ pydantic==1.10.8
103
+ pydub==0.25.1
104
+ Pygments==2.15.1
105
+ pyobjc==9.1.1
106
+ pyobjc-core==9.1.1
107
+ pyobjc-framework-Accessibility==9.1.1
108
+ pyobjc-framework-Accounts==9.1.1
109
+ pyobjc-framework-AddressBook==9.1.1
110
+ pyobjc-framework-AdServices==9.1.1
111
+ pyobjc-framework-AdSupport==9.1.1
112
+ pyobjc-framework-AppleScriptKit==9.1.1
113
+ pyobjc-framework-AppleScriptObjC==9.1.1
114
+ pyobjc-framework-ApplicationServices==9.1.1
115
+ pyobjc-framework-AppTrackingTransparency==9.1.1
116
+ pyobjc-framework-AudioVideoBridging==9.1.1
117
+ pyobjc-framework-AuthenticationServices==9.1.1
118
+ pyobjc-framework-AutomaticAssessmentConfiguration==9.1.1
119
+ pyobjc-framework-Automator==9.1.1
120
+ pyobjc-framework-AVFoundation==9.1.1
121
+ pyobjc-framework-AVKit==9.1.1
122
+ pyobjc-framework-AVRouting==9.1.1
123
+ pyobjc-framework-BackgroundAssets==9.1.1
124
+ pyobjc-framework-BusinessChat==9.1.1
125
+ pyobjc-framework-CalendarStore==9.1.1
126
+ pyobjc-framework-CallKit==9.1.1
127
+ pyobjc-framework-CFNetwork==9.1.1
128
+ pyobjc-framework-ClassKit==9.1.1
129
+ pyobjc-framework-CloudKit==9.1.1
130
+ pyobjc-framework-Cocoa==9.1.1
131
+ pyobjc-framework-Collaboration==9.1.1
132
+ pyobjc-framework-ColorSync==9.1.1
133
+ pyobjc-framework-Contacts==9.1.1
134
+ pyobjc-framework-ContactsUI==9.1.1
135
+ pyobjc-framework-CoreAudio==9.1.1
136
+ pyobjc-framework-CoreAudioKit==9.1.1
137
+ pyobjc-framework-CoreBluetooth==9.1.1
138
+ pyobjc-framework-CoreData==9.1.1
139
+ pyobjc-framework-CoreHaptics==9.1.1
140
+ pyobjc-framework-CoreLocation==9.1.1
141
+ pyobjc-framework-CoreMedia==9.1.1
142
+ pyobjc-framework-CoreMediaIO==9.1.1
143
+ pyobjc-framework-CoreMIDI==9.1.1
144
+ pyobjc-framework-CoreML==9.1.1
145
+ pyobjc-framework-CoreMotion==9.1.1
146
+ pyobjc-framework-CoreServices==9.1.1
147
+ pyobjc-framework-CoreSpotlight==9.1.1
148
+ pyobjc-framework-CoreText==9.1.1
149
+ pyobjc-framework-CoreWLAN==9.1.1
150
+ pyobjc-framework-CryptoTokenKit==9.1.1
151
+ pyobjc-framework-DataDetection==9.1.1
152
+ pyobjc-framework-DeviceCheck==9.1.1
153
+ pyobjc-framework-DictionaryServices==9.1.1
154
+ pyobjc-framework-DiscRecording==9.1.1
155
+ pyobjc-framework-DiscRecordingUI==9.1.1
156
+ pyobjc-framework-DiskArbitration==9.1.1
157
+ pyobjc-framework-DVDPlayback==9.1.1
158
+ pyobjc-framework-EventKit==9.1.1
159
+ pyobjc-framework-ExceptionHandling==9.1.1
160
+ pyobjc-framework-ExecutionPolicy==9.1.1
161
+ pyobjc-framework-ExtensionKit==9.1.1
162
+ pyobjc-framework-ExternalAccessory==9.1.1
163
+ pyobjc-framework-FileProvider==9.1.1
164
+ pyobjc-framework-FileProviderUI==9.1.1
165
+ pyobjc-framework-FinderSync==9.1.1
166
+ pyobjc-framework-FSEvents==9.1.1
167
+ pyobjc-framework-GameCenter==9.1.1
168
+ pyobjc-framework-GameController==9.1.1
169
+ pyobjc-framework-GameKit==9.1.1
170
+ pyobjc-framework-GameplayKit==9.1.1
171
+ pyobjc-framework-HealthKit==9.1.1
172
+ pyobjc-framework-ImageCaptureCore==9.1.1
173
+ pyobjc-framework-IMServicePlugIn==9.1.1
174
+ pyobjc-framework-InputMethodKit==9.1.1
175
+ pyobjc-framework-InstallerPlugins==9.1.1
176
+ pyobjc-framework-InstantMessage==9.1.1
177
+ pyobjc-framework-Intents==9.1.1
178
+ pyobjc-framework-IntentsUI==9.1.1
179
+ pyobjc-framework-IOBluetooth==9.1.1
180
+ pyobjc-framework-IOBluetoothUI==9.1.1
181
+ pyobjc-framework-IOSurface==9.1.1
182
+ pyobjc-framework-iTunesLibrary==9.1.1
183
+ pyobjc-framework-KernelManagement==9.1.1
184
+ pyobjc-framework-LatentSemanticMapping==9.1.1
185
+ pyobjc-framework-LaunchServices==9.1.1
186
+ pyobjc-framework-libdispatch==9.1.1
187
+ pyobjc-framework-libxpc==9.1.1
188
+ pyobjc-framework-LinkPresentation==9.1.1
189
+ pyobjc-framework-LocalAuthentication==9.1.1
190
+ pyobjc-framework-LocalAuthenticationEmbeddedUI==9.1.1
191
+ pyobjc-framework-MailKit==9.1.1
192
+ pyobjc-framework-MapKit==9.1.1
193
+ pyobjc-framework-MediaAccessibility==9.1.1
194
+ pyobjc-framework-MediaLibrary==9.1.1
195
+ pyobjc-framework-MediaPlayer==9.1.1
196
+ pyobjc-framework-MediaToolbox==9.1.1
197
+ pyobjc-framework-Metal==9.1.1
198
+ pyobjc-framework-MetalFX==9.1.1
199
+ pyobjc-framework-MetalKit==9.1.1
200
+ pyobjc-framework-MetalPerformanceShaders==9.1.1
201
+ pyobjc-framework-MetalPerformanceShadersGraph==9.1.1
202
+ pyobjc-framework-MetricKit==9.1.1
203
+ pyobjc-framework-MLCompute==9.1.1
204
+ pyobjc-framework-ModelIO==9.1.1
205
+ pyobjc-framework-MultipeerConnectivity==9.1.1
206
+ pyobjc-framework-NaturalLanguage==9.1.1
207
+ pyobjc-framework-NetFS==9.1.1
208
+ pyobjc-framework-Network==9.1.1
209
+ pyobjc-framework-NetworkExtension==9.1.1
210
+ pyobjc-framework-NotificationCenter==9.1.1
211
+ pyobjc-framework-OpenDirectory==9.1.1
212
+ pyobjc-framework-OSAKit==9.1.1
213
+ pyobjc-framework-OSLog==9.1.1
214
+ pyobjc-framework-PassKit==9.1.1
215
+ pyobjc-framework-PencilKit==9.1.1
216
+ pyobjc-framework-PHASE==9.1.1
217
+ pyobjc-framework-Photos==9.1.1
218
+ pyobjc-framework-PhotosUI==9.1.1
219
+ pyobjc-framework-PreferencePanes==9.1.1
220
+ pyobjc-framework-PushKit==9.1.1
221
+ pyobjc-framework-Quartz==9.1.1
222
+ pyobjc-framework-QuickLookThumbnailing==9.1.1
223
+ pyobjc-framework-ReplayKit==9.1.1
224
+ pyobjc-framework-SafariServices==9.1.1
225
+ pyobjc-framework-SafetyKit==9.1.1
226
+ pyobjc-framework-SceneKit==9.1.1
227
+ pyobjc-framework-ScreenCaptureKit==9.1.1
228
+ pyobjc-framework-ScreenSaver==9.1.1
229
+ pyobjc-framework-ScreenTime==9.1.1
230
+ pyobjc-framework-ScriptingBridge==9.1.1
231
+ pyobjc-framework-SearchKit==9.1.1
232
+ pyobjc-framework-Security==9.1.1
233
+ pyobjc-framework-SecurityFoundation==9.1.1
234
+ pyobjc-framework-SecurityInterface==9.1.1
235
+ pyobjc-framework-ServiceManagement==9.1.1
236
+ pyobjc-framework-SharedWithYou==9.1.1
237
+ pyobjc-framework-SharedWithYouCore==9.1.1
238
+ pyobjc-framework-ShazamKit==9.1.1
239
+ pyobjc-framework-Social==9.1.1
240
+ pyobjc-framework-SoundAnalysis==9.1.1
241
+ pyobjc-framework-Speech==9.1.1
242
+ pyobjc-framework-SpriteKit==9.1.1
243
+ pyobjc-framework-StoreKit==9.1.1
244
+ pyobjc-framework-SyncServices==9.1.1
245
+ pyobjc-framework-SystemConfiguration==9.1.1
246
+ pyobjc-framework-SystemExtensions==9.1.1
247
+ pyobjc-framework-ThreadNetwork==9.1.1
248
+ pyobjc-framework-UniformTypeIdentifiers==9.1.1
249
+ pyobjc-framework-UserNotifications==9.1.1
250
+ pyobjc-framework-UserNotificationsUI==9.1.1
251
+ pyobjc-framework-VideoSubscriberAccount==9.1.1
252
+ pyobjc-framework-VideoToolbox==9.1.1
253
+ pyobjc-framework-Virtualization==9.1.1
254
+ pyobjc-framework-Vision==9.1.1
255
+ pyobjc-framework-WebKit==9.1.1
256
+ pypandoc==1.11
257
+ pyparsing==3.0.9
258
+ pyrsistent==0.19.3
259
+ pytesseract==0.3.10
260
+ pytest==7.4.0
261
+ python-dateutil==2.8.2
262
+ python-docx==0.8.11
263
+ python-dotenv==1.0.0
264
+ python-magic==0.4.27
265
+ python-multipart==0.0.6
266
+ python-pptx==0.6.21
267
+ pyttsx3==2.90
268
+ pytz==2023.3
269
+ PyYAML==6.0
270
+ regex==2023.5.5
271
+ requests==2.31.0
272
+ rfc3986==1.5.0
273
+ safetensors==0.3.1
274
+ scipy==1.10.1
275
+ semantic-version==2.10.0
276
+ setuptools-rust==1.5.2
277
+ six==1.16.0
278
+ sniffio==1.3.0
279
+ SQLAlchemy==1.4.48
280
+ starlette==0.27.0
281
+ sympy==1.12
282
+ tenacity==8.2.2
283
+ tiktoken==0.3.1
284
+ timm==0.9.2
285
+ tokenizers==0.13.3
286
+ toolz==0.12.0
287
+ torch==2.0.1
288
+ torchvision==0.15.2
289
+ tqdm==4.65.0
290
+ transformers==4.29.2
291
+ typing-inspect==0.9.0
292
+ typing_extensions==4.6.2
293
+ uc-micro-py==1.0.2
294
+ unstructured==0.6.9
295
+ unstructured-inference==0.4.4
296
+ urllib3==2.0.2
297
+ uvicorn==0.22.0
298
+ uvloop==0.17.0
299
+ Wand==0.6.11
300
+ watchfiles==0.19.0
301
+ websockets==11.0.3
302
+ Werkzeug==2.3.4
303
+ wrapt==1.13.3
304
+ XlsxWriter==3.1.1
305
+ yarl==1.9.2
306
+ zstandard==0.21.0
test/.pytest_cache/v/cache/lastfailed CHANGED
@@ -1,23 +1,5 @@
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
  }
 
1
  {
2
  "test_chatgpt4uavs.py::test_red_house": true,
3
+ "test_chatgpt4uavs.py": true,
4
+ "test_fewshot.py": true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
test/.pytest_cache/v/cache/nodeids CHANGED
@@ -1,56 +1,4 @@
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
  ]
 
1
  [
 
 
 
 
 
 
 
 
 
 
2
  "test_chatgpt4uavs.py::test_red_house",
3
+ "test_fewshot.py::test_red_house"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ]
test/__pycache__/test_chatgpt4uavs.cpython-311-pytest-7.4.0.pyc CHANGED
Binary files a/test/__pycache__/test_chatgpt4uavs.cpython-311-pytest-7.4.0.pyc and b/test/__pycache__/test_chatgpt4uavs.cpython-311-pytest-7.4.0.pyc differ
 
test/__pycache__/test_fewshot.cpython-311-pytest-7.4.0.pyc CHANGED
Binary files a/test/__pycache__/test_fewshot.cpython-311-pytest-7.4.0.pyc and b/test/__pycache__/test_fewshot.cpython-311-pytest-7.4.0.pyc differ
 
test/test_fewshot.py CHANGED
@@ -2,27 +2,27 @@ 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):
@@ -31,6 +31,7 @@ def test_red_house(fewshot):
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)
@@ -38,6 +39,13 @@ def test_take_off(fewshot):
38
  assert command == "takeoff"
39
 
40
 
 
 
 
 
 
 
 
41
  def test_land(fewshot):
42
  text = "Land now."
43
  output = fewshot.get_command(text)
@@ -49,20 +57,14 @@ 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):
@@ -99,50 +101,49 @@ def test_stop_flight(fewshot):
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)
@@ -163,7 +164,7 @@ def test_location_no_action3(fewshot):
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)
@@ -176,46 +177,53 @@ def test_with_extra_words2(fewshot):
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")
 
 
 
 
 
 
 
2
  import re
3
  from fewshot import FewShot4UAVs
4
 
5
+
6
  @pytest.fixture
7
  def fewshot():
8
  return FewShot4UAVs()
9
 
 
10
 
11
+ # format: <command> \t<goal>
12
  def parse_command(text):
13
  tokens = re.split(' \t|\n|: ', text.lower())
14
  print(tokens)
15
+ if len(tokens) >= 2:
16
+ return tokens[1]
17
  else:
18
+ return 'none'
19
+
20
 
 
21
  def parse_multiple_commands(text):
22
  text = text.lstrip('\n')
23
  lines = text.split("\n")
24
+ first_action = lines[0].split()[0].lower()
25
+ second_action = lines[1].split()[0].lower()
26
  return first_action, second_action
27
 
28
  def test_red_house(fewshot):
 
31
  command = parse_command(output)
32
  assert command == "goto"
33
 
34
+
35
  def test_take_off(fewshot):
36
  text = "Take off from where you are."
37
  output = fewshot.get_command(text)
 
39
  assert command == "takeoff"
40
 
41
 
42
+ def test_take_off_synonym(fewshot):
43
+ text = "Lift off."
44
+ output = fewshot.get_command(text)
45
+ command = parse_command(output)
46
+ assert command == "takeoff"
47
+
48
+
49
  def test_land(fewshot):
50
  text = "Land now."
51
  output = fewshot.get_command(text)
 
57
  text = "Take a picture."
58
  output = fewshot.get_command(text)
59
  command = parse_command(output)
60
+ assert command == "none"
61
 
 
 
 
 
 
 
62
 
63
  def test_snap_pic(fewshot):
64
  text = "Snap a photo."
65
  output = fewshot.get_command(text)
66
  command = parse_command(output)
67
+ assert command == "none"
68
 
69
 
70
  def test_purple_house(fewshot):
 
101
  command = parse_command(output)
102
  assert command == "land"
103
 
104
+
105
  def test_no_location1(fewshot):
106
  text = "Check out."
107
  output = fewshot.get_command(text)
108
  command = parse_command(output)
109
+ assert command == "none"
110
 
111
 
112
  def test_no_location2(fewshot):
113
  text = "Go to."
114
  output = fewshot.get_command(text)
115
  command = parse_command(output)
116
+ assert command == "none"
117
 
118
 
119
  def test_no_location3(fewshot):
120
  text = "Travel to."
121
  output = fewshot.get_command(text)
122
  command = parse_command(output)
123
+ assert command == "none"
124
 
125
 
126
  def test_no_location4(fewshot):
127
  text = "Head to."
128
  output = fewshot.get_command(text)
129
  command = parse_command(output)
130
+ assert command == "none"
131
 
132
 
 
133
  def test_empty_input(fewshot):
134
  text = ""
135
  output = fewshot.get_command(text)
136
  command = parse_command(output)
137
+ assert command == "none"
138
 
139
 
140
  def test_invalid_command(fewshot):
141
  text = "Do something."
142
  output = fewshot.get_command(text)
143
  command = parse_command(output)
144
+ assert command == "none"
145
+
146
 
 
147
  def test_location_no_action(fewshot):
148
  text = "Willow Lawn."
149
  output = fewshot.get_command(text)
 
164
  command = parse_command(output)
165
  assert command == "goto"
166
 
167
+
168
  def test_with_extra_words(fewshot):
169
  text = "Please go to the Whole Foods on W Broad St."
170
  output = fewshot.get_command(text)
 
177
  command = parse_command(output)
178
  assert command == "goto"
179
 
180
+
181
+ def test_multiple_actions(fewshot):
182
+ text = "Take a photo and then take off."
183
  output = fewshot.get_command(text)
184
  command = parse_multiple_commands(output)
185
+ assert command == ('takephoto', 'takeoff')
186
+
187
 
188
+ def test_two_go_to(fewshot):
189
+ text = "Go to the Kroger on Lombardy St and then go to Roots on W Grace St."
190
  output = fewshot.get_command(text)
191
  command = parse_multiple_commands(output)
192
+ assert command == ('goto', 'goto')
193
+
194
 
195
+ def test_multiple_actions_and_locations(fewshot):
196
+ text = "Fly to the park and take a picture of the red house."
197
  output = fewshot.get_command(text)
198
  command = parse_multiple_commands(output)
199
+ assert command == ('goto', 'takephoto')
200
 
201
+ def test_action_and_location(fewshot):
202
+ text = "Fly to the park and take a picture."
203
  output = fewshot.get_command(text)
204
  command = parse_multiple_commands(output)
205
+ assert command == ('goto', 'takephoto')
206
 
207
+ def test_action_and_location_synonyms(fewshot):
208
+ text = "Hover and head to the closest park."
209
  output = fewshot.get_command(text)
210
  command = parse_multiple_commands(output)
211
+ assert command == ('takeoff', 'goto')
212
 
213
+ def test_action_synonyms(fewshot):
214
+ text = "Ascend and then take a photo."
 
215
  output = fewshot.get_command(text)
216
  command = parse_multiple_commands(output)
217
+ assert command == ('takeoff', 'takephoto')
218
+
219
+ def test_action_synonyms2(fewshot):
220
+ text = "Descend and then take a photo."
221
  output = fewshot.get_command(text)
222
  command = parse_multiple_commands(output)
223
+ assert command == ('land', 'takephoto')
224
+
225
+ def test_action_synonyms3(fewshot):
226
+ text = "Descend"
227
+ output = fewshot.get_command(text)
228
+ command = parse_command(output)
229
+ assert command == 'land'
uav_api.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, jsonify, request
2
+ from flask_restful import Resource, Api
3
+ import requests
4
+ from gradio_client import Client
5
+
6
+ app = Flask(__name__)
7
+ api = Api(app)
8
+
9
+
10
+ def get_latest_command():
11
+ client = Client("http://127.0.0.1:7860")
12
+ result = client.predict(
13
+ "https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav",
14
+ api_name="/record"
15
+ )
16
+ lines = result.split('\n')
17
+ command = None
18
+ for line in lines:
19
+ if "UAV:" in line:
20
+ command = line.split("UAV:", 1)[-1].strip()
21
+ break
22
+ return command
23
+
24
+
25
+ def send_command_to_uav_controller(command):
26
+ url = "http://localhost:8080" # replace with address for UAV's C++ code later
27
+ data = {"command": command}
28
+ response = requests.post(url, json=data)
29
+ return response.text
30
+
31
+
32
+ class Command(Resource):
33
+ def get(self):
34
+ latest_command = get_latest_command()
35
+ return jsonify({"latest_command": latest_command})
36
+
37
+ def post(self):
38
+ latest_command = get_latest_command()
39
+ if latest_command:
40
+ response = send_command_to_uav_controller(latest_command)
41
+ return jsonify({"status": "Command sent to UAV controller.", "response": response}), 200
42
+ else:
43
+ return jsonify({"status": "No command available."}), 404
44
+
45
+ def put(self):
46
+ pass
47
+
48
+ def delete(self):
49
+ pass
50
+
51
+
52
+ api.add_resource(Command, '/command')
53
+
54
+ if __name__ == '__main__':
55
+ app.run(debug=True)