mirror of
https://github.com/james-m-jordan/openai-cookbook.git
synced 2025-05-09 19:32:38 +00:00
fix FT for function calling cookbook to use the latest APIs (#1252)
This commit is contained in:
parent
ed65883e43
commit
a7e107d9fc
@ -75,14 +75,14 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# !pip install tenacity\n",
|
||||
"# !pip install openai\n",
|
||||
"# !pip install typing"
|
||||
"!pip install tenacity -q\n",
|
||||
"!pip install openai -q\n",
|
||||
"!pip install typing -q"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -114,7 +114,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -125,7 +125,8 @@
|
||||
" temperature=1.0,\n",
|
||||
" stop=None,\n",
|
||||
" tools=None,\n",
|
||||
" functions=None\n",
|
||||
" functions=None,\n",
|
||||
" tool_choice=None\n",
|
||||
") -> str:\n",
|
||||
" params = {\n",
|
||||
" 'model': model,\n",
|
||||
@ -134,6 +135,7 @@
|
||||
" 'temperature': temperature,\n",
|
||||
" 'stop': stop,\n",
|
||||
" 'tools': tools,\n",
|
||||
" 'tool_choice': tool_choice\n",
|
||||
" }\n",
|
||||
" if functions:\n",
|
||||
" params['functions'] = functions\n",
|
||||
@ -160,7 +162,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -178,12 +180,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"function_list = [\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"takeoff_drone\",\n",
|
||||
" \"description\": \"Initiate the drone's takeoff sequence.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -196,8 +200,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"altitude\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"land_drone\",\n",
|
||||
" \"description\": \"Land the drone at its current location or a specified landing point.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -215,8 +222,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"location\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"control_drone_movement\",\n",
|
||||
" \"description\": \"Direct the drone's movement in a specific direction.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -234,8 +244,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"direction\", \"distance\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_drone_speed\",\n",
|
||||
" \"description\": \"Adjust the speed of the drone.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -248,8 +261,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"speed\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"control_camera\",\n",
|
||||
" \"description\": \"Control the drone's camera to capture images or videos.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -267,8 +283,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"mode\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"control_gimbal\",\n",
|
||||
" \"description\": \"Adjust the drone's gimbal for camera stabilization and direction.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -285,8 +304,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"tilt\", \"pan\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_drone_lighting\",\n",
|
||||
" \"description\": \"Control the drone's lighting for visibility and signaling.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -300,16 +322,22 @@
|
||||
" },\n",
|
||||
" \"required\": [\"mode\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"return_to_home\",\n",
|
||||
" \"description\": \"Command the drone to return to its home or launch location.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
" \"type\": \"object\",\n",
|
||||
" \"properties\": {}\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_battery_saver_mode\",\n",
|
||||
" \"description\": \"Toggle battery saver mode.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -323,8 +351,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"status\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_obstacle_avoidance\",\n",
|
||||
" \"description\": \"Configure obstacle avoidance settings.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -338,8 +369,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"mode\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_follow_me_mode\",\n",
|
||||
" \"description\": \"Enable or disable 'follow me' mode.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -353,16 +387,22 @@
|
||||
" },\n",
|
||||
" \"required\": [\"status\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"calibrate_sensors\",\n",
|
||||
" \"description\": \"Initiate calibration sequence for drone's sensors.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
" \"type\": \"object\",\n",
|
||||
" \"properties\": {}\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_autopilot\",\n",
|
||||
" \"description\": \"Enable or disable autopilot mode.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -376,8 +416,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"status\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"configure_led_display\",\n",
|
||||
" \"description\": \"Configure the drone's LED display pattern and colors.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -396,8 +439,11 @@
|
||||
" },\n",
|
||||
" \"required\": [\"pattern\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"set_home_location\",\n",
|
||||
" \"description\": \"Set or change the home location for the drone.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
@ -410,14 +456,18 @@
|
||||
" },\n",
|
||||
" \"required\": [\"coordinates\"]\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
" {\n",
|
||||
" \"type\": \"function\",\n",
|
||||
" \"function\": {\n",
|
||||
" \"name\": \"reject_request\",\n",
|
||||
" \"description\": \"Use this function if the request is not possible.\",\n",
|
||||
" \"parameters\": {\n",
|
||||
" \"type\": \"object\",\n",
|
||||
" \"properties\": {}\n",
|
||||
" }\n",
|
||||
" }\n",
|
||||
" },\n",
|
||||
"]\n"
|
||||
]
|
||||
@ -431,14 +481,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"straightforward_prompts = ['Land the drone at the home base',\n",
|
||||
" 'Take off the drone to 50 meters',\n",
|
||||
" 'change speed to 15 kilometers per hour',\n",
|
||||
" 'turn into an elephant!']\n"
|
||||
" 'Change speed to 15 kilometers per hour',\n",
|
||||
" 'Turn into an elephant!']\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -451,16 +501,16 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Land the drone at the home base\n",
|
||||
"FunctionCall(arguments='{\\n \"location\": \"home_base\"\\n}', name='land_drone') \n",
|
||||
"[ChatCompletionMessageToolCall(id='call_q2Tc40jUdteCddVYmIUQgcJF', function=Function(arguments='{\"location\":\"home_base\"}', name='land_drone'), type='function')] \n",
|
||||
"\n",
|
||||
"Take off the drone to 50 meters\n",
|
||||
"FunctionCall(arguments='{\\n \"altitude\": 50\\n}', name='takeoff_drone') \n",
|
||||
"[ChatCompletionMessageToolCall(id='call_XvTTQZOEK3eMbTkC3tmAT8zx', function=Function(arguments='{\"altitude\":50}', name='takeoff_drone'), type='function')] \n",
|
||||
"\n",
|
||||
"change speed to 15 kilometers per hour\n",
|
||||
"FunctionCall(arguments='{ \"speed\": 15 }', name='set_drone_speed') \n",
|
||||
"Change speed to 15 kilometers per hour\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_uc7hypi9rxIEhlbZ7otKvXTM', function=Function(arguments='{\"speed\":15}', name='set_drone_speed'), type='function')] \n",
|
||||
"\n",
|
||||
"turn into an elephant!\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request') \n",
|
||||
"Turn into an elephant!\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_uSv9WffRNepcP8OpW0e4BUA4', function=Function(arguments='{}', name='reject_request'), type='function')] \n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
@ -470,9 +520,9 @@
|
||||
" messages = []\n",
|
||||
" messages.append({\"role\": \"system\", \"content\": DRONE_SYSTEM_PROMPT})\n",
|
||||
" messages.append({\"role\": \"user\", \"content\": prompt})\n",
|
||||
" completion = get_chat_completion(model=\"gpt-3.5-turbo\",messages=messages,tools=function_list)\n",
|
||||
" completion = get_chat_completion(model=\"gpt-3.5-turbo\",messages=messages,tools=function_list,tool_choice='required')\n",
|
||||
" print(prompt)\n",
|
||||
" print(completion.function_call,'\\n')\n"
|
||||
" print(completion.tool_calls,'\\n')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -489,9 +539,9 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"challenging_prompts = ['Play pre-recorded audio message',\n",
|
||||
" 'Initiate live-streaming on social media',\n",
|
||||
" 'Initiate following on social media',\n",
|
||||
" 'Scan environment for heat signatures',\n",
|
||||
" 'Enable stealth mode',\n",
|
||||
" 'Bump into obstacles',\n",
|
||||
" \"Change drone's paint job color\"]\n"
|
||||
]
|
||||
},
|
||||
@ -505,23 +555,23 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Play pre-recorded audio message\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request')\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_YfOvtV0Als62FniYKctgqbzI', function=Function(arguments='{}', name='reject_request'), type='function')]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Initiate live-streaming on social media\n",
|
||||
"FunctionCall(arguments='{\\n \"mode\": \"video\",\\n \"duration\": 0\\n}', name='control_camera')\n",
|
||||
"Initiate following on social media\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_3r7pm8HbFFSI2WKGaTGxviBM', function=Function(arguments='{\"status\":\"on\"}', name='set_follow_me_mode'), type='function')]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Scan environment for heat signatures\n",
|
||||
"FunctionCall(arguments='{\\n \"mode\": \"photo\"\\n}', name='control_camera')\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_JU4QPTud6YNgh9xy3GNA1I3K', function=Function(arguments='{}', name='reject_request'), type='function')]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Enable stealth mode\n",
|
||||
"FunctionCall(arguments='{\\n \"mode\": \"off\"\\n}', name='set_drone_lighting')\n",
|
||||
"Bump into obstacles\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_DrnNuDiKFEAb8AGA9zpJ6MUL', function=Function(arguments='{\"mode\":\"on\"}', name='set_obstacle_avoidance'), type='function')]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Change drone's paint job color\n",
|
||||
"FunctionCall(arguments='{\\n \"pattern\": \"solid\",\\n \"color\": \"blue\"\\n}', name='configure_led_display')\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_xGGKJuKRPdQrZPDIaIvTVn3E', function=Function(arguments='{\"pattern\":\"solid\",\"color\":\"blue\"}', name='configure_led_display'), type='function')]\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
@ -532,10 +582,10 @@
|
||||
" messages = []\n",
|
||||
" messages.append({\"role\": \"system\", \"content\": DRONE_SYSTEM_PROMPT})\n",
|
||||
" messages.append({\"role\": \"user\", \"content\": prompt})\n",
|
||||
" completion = get_chat_completion(model=\"gpt-3.5-turbo\",messages=messages,tools=function_list)\n",
|
||||
" completion = get_chat_completion(model=\"gpt-3.5-turbo\",messages=messages,tools=function_list,tool_choice='required')\n",
|
||||
" print(prompt)\n",
|
||||
" try:\n",
|
||||
" print(completion.function_call)\n",
|
||||
" print(completion.tool_calls)\n",
|
||||
" print('\\n')\n",
|
||||
" except:\n",
|
||||
" print(completion.content)\n",
|
||||
@ -789,16 +839,16 @@
|
||||
"all_but_reject = [f for f in function_list if f.get('name') != 'reject_request']\n",
|
||||
"\n",
|
||||
"for function in all_but_reject:\n",
|
||||
" func_name = function[\"name\"]\n",
|
||||
" params = function[\"parameters\"]\n",
|
||||
" func_name = function[\"function\"][\"name\"]\n",
|
||||
" params = function[\"function\"][\"parameters\"]\n",
|
||||
" for arguments in generate_permutations(params):\n",
|
||||
" if any(val in arguments.values() for val in ['fill_in_int', 'fill_in_str']):\n",
|
||||
" input_object = {\n",
|
||||
" \"name\": func_name,\n",
|
||||
" \"arguments\": arguments\n",
|
||||
" }\n",
|
||||
" messages = [{\"role\": \"user\", \"content\": INVOCATION_FILLER_PROMPT.format(invocation=input_object,function=function)}]\n",
|
||||
" input_object = get_chat_completion(model='gpt-4', messages=messages, max_tokens = 200, temperature=.1).content\n",
|
||||
" messages = [{\"role\": \"user\", \"content\": INVOCATION_FILLER_PROMPT.format(invocation=str(input_object),function=function)}]\n",
|
||||
" input_object = get_chat_completion(model='gpt-4o', messages=messages, max_tokens = 200, temperature=.1).content\n",
|
||||
" else:\n",
|
||||
" input_object = {\n",
|
||||
" \"name\": func_name,\n",
|
||||
@ -820,12 +870,27 @@
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def remove_sequences(input_string):\n",
|
||||
" # Replace the specific sequences with an empty string\n",
|
||||
" cleaned_string = input_string.replace(\"```json\", \"\") # Remove \"```json\" first\n",
|
||||
" cleaned_string = cleaned_string.replace(\"```\", \"\") # Then remove \"```\"\n",
|
||||
" return json.loads(cleaned_string)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def create_commands(invocation_list):\n",
|
||||
" example_list = []\n",
|
||||
" for i, invocation in enumerate(invocation_list):\n",
|
||||
" if i<10:\n",
|
||||
" if i<100:\n",
|
||||
" print(f'\\033[34m{np.round(100*i/len(invocation_list),1)}% complete\\033[0m')\n",
|
||||
" if type(invocation) == str or 'json' in invocation:\n",
|
||||
" invocation = remove_sequences(invocation)\n",
|
||||
" print(invocation)\n",
|
||||
"\n",
|
||||
" # Format the prompt with the invocation string\n",
|
||||
@ -835,7 +900,7 @@
|
||||
" completion = get_chat_completion(messages,temperature=0.8)\n",
|
||||
" command_dict = {\n",
|
||||
" \"Input\": invocation,\n",
|
||||
" \"Prompt\": completion\n",
|
||||
" \"Prompt\": completion.content\n",
|
||||
" }\n",
|
||||
" example_list.append(command_dict)\n",
|
||||
" return example_list\n"
|
||||
@ -843,7 +908,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -853,23 +918,117 @@
|
||||
"\u001b[34m0.0% complete\u001b[0m\n",
|
||||
"{'name': 'takeoff_drone', 'arguments': {'altitude': 100}}\n",
|
||||
"\u001b[34m1.8% complete\u001b[0m\n",
|
||||
"{'name': 'land_drone', 'arguments': {'location': 'current'}}\n",
|
||||
"\u001b[34m3.6% complete\u001b[0m\n",
|
||||
"{'name': 'land_drone', 'arguments': {'location': 'home_base'}}\n",
|
||||
"\u001b[34m5.4% complete\u001b[0m\n",
|
||||
"{'name': 'land_drone', 'arguments': {'location': 'custom'}}\n",
|
||||
"\u001b[34m7.1% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'forward', 'distance': 50}}\n",
|
||||
"\u001b[34m8.9% complete\u001b[0m\n",
|
||||
"{'name': 'land_drone', 'arguments': '{\"location\": \"current\"}'}\n",
|
||||
"\u001b[34m3.5% complete\u001b[0m\n",
|
||||
"{'name': 'land_drone', 'arguments': '{\"location\": \"home_base\"}'}\n",
|
||||
"\u001b[34m5.3% complete\u001b[0m\n",
|
||||
"{'name': 'land_drone', 'arguments': '{\"location\": \"custom\"}'}\n",
|
||||
"\u001b[34m7.0% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'forward', 'distance': 10}}\n",
|
||||
"\u001b[34m8.8% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'backward', 'distance': 10}}\n",
|
||||
"\u001b[34m10.7% complete\u001b[0m\n",
|
||||
"\u001b[34m10.5% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'left', 'distance': 10}}\n",
|
||||
"\u001b[34m12.5% complete\u001b[0m\n",
|
||||
"\u001b[34m12.3% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'right', 'distance': 10}}\n",
|
||||
"\u001b[34m14.3% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'up', 'distance': 20}}\n",
|
||||
"\u001b[34m16.1% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'down', 'distance': 10}}\n"
|
||||
"\u001b[34m14.0% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'up', 'distance': 10}}\n",
|
||||
"\u001b[34m15.8% complete\u001b[0m\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': {'direction': 'down', 'distance': 10}}\n",
|
||||
"\u001b[34m17.5% complete\u001b[0m\n",
|
||||
"{'name': 'set_drone_speed', 'arguments': {'speed': 50}}\n",
|
||||
"\u001b[34m19.3% complete\u001b[0m\n",
|
||||
"{'name': 'control_camera', 'arguments': {'mode': 'photo'}}\n",
|
||||
"\u001b[34m21.1% complete\u001b[0m\n",
|
||||
"{'name': 'control_camera', 'arguments': {'mode': 'photo'}}\n",
|
||||
"\u001b[34m22.8% complete\u001b[0m\n",
|
||||
"{'name': 'control_camera', 'arguments': {'mode': 'video'}}\n",
|
||||
"\u001b[34m24.6% complete\u001b[0m\n",
|
||||
"{'name': 'control_camera', 'arguments': {'mode': 'video', 'duration': 30}}\n",
|
||||
"\u001b[34m26.3% complete\u001b[0m\n",
|
||||
"{'name': 'control_camera', 'arguments': {'mode': 'panorama'}}\n",
|
||||
"\u001b[34m28.1% complete\u001b[0m\n",
|
||||
"{'name': 'control_camera', 'arguments': {'mode': 'panorama', 'duration': 0}}\n",
|
||||
"\u001b[34m29.8% complete\u001b[0m\n",
|
||||
"{'name': 'control_gimbal', 'arguments': {'tilt': 45, 'pan': 90}}\n",
|
||||
"\u001b[34m31.6% complete\u001b[0m\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'on'}}\n",
|
||||
"\u001b[34m33.3% complete\u001b[0m\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'off'}}\n",
|
||||
"\u001b[34m35.1% complete\u001b[0m\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'blink'}}\n",
|
||||
"\u001b[34m36.8% complete\u001b[0m\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'sos'}}\n",
|
||||
"\u001b[34m38.6% complete\u001b[0m\n",
|
||||
"{'name': 'return_to_home', 'arguments': {}}\n",
|
||||
"\u001b[34m40.4% complete\u001b[0m\n",
|
||||
"{'name': 'set_battery_saver_mode', 'arguments': {'status': 'on'}}\n",
|
||||
"\u001b[34m42.1% complete\u001b[0m\n",
|
||||
"{'name': 'set_battery_saver_mode', 'arguments': {'status': 'off'}}\n",
|
||||
"\u001b[34m43.9% complete\u001b[0m\n",
|
||||
"{'name': 'set_obstacle_avoidance', 'arguments': {'mode': 'on'}}\n",
|
||||
"\u001b[34m45.6% complete\u001b[0m\n",
|
||||
"{'name': 'set_obstacle_avoidance', 'arguments': {'mode': 'off'}}\n",
|
||||
"\u001b[34m47.4% complete\u001b[0m\n",
|
||||
"{'name': 'set_follow_me_mode', 'arguments': {'status': 'on'}}\n",
|
||||
"\u001b[34m49.1% complete\u001b[0m\n",
|
||||
"{'name': 'set_follow_me_mode', 'arguments': {'status': 'off'}}\n",
|
||||
"\u001b[34m50.9% complete\u001b[0m\n",
|
||||
"{'name': 'calibrate_sensors', 'arguments': {}}\n",
|
||||
"\u001b[34m52.6% complete\u001b[0m\n",
|
||||
"{'name': 'set_autopilot', 'arguments': {'status': 'on'}}\n",
|
||||
"\u001b[34m54.4% complete\u001b[0m\n",
|
||||
"{'name': 'set_autopilot', 'arguments': {'status': 'off'}}\n",
|
||||
"\u001b[34m56.1% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid'}}\n",
|
||||
"\u001b[34m57.9% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'red'}}\n",
|
||||
"\u001b[34m59.6% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'blue'}}\n",
|
||||
"\u001b[34m61.4% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'green'}}\n",
|
||||
"\u001b[34m63.2% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'yellow'}}\n",
|
||||
"\u001b[34m64.9% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'white'}}\n",
|
||||
"\u001b[34m66.7% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink'}}\n",
|
||||
"\u001b[34m68.4% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'red'}}\n",
|
||||
"\u001b[34m70.2% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'blue'}}\n",
|
||||
"\u001b[34m71.9% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'green'}}\n",
|
||||
"\u001b[34m73.7% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'yellow'}}\n",
|
||||
"\u001b[34m75.4% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'white'}}\n",
|
||||
"\u001b[34m77.2% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse'}}\n",
|
||||
"\u001b[34m78.9% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'red'}}\n",
|
||||
"\u001b[34m80.7% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'blue'}}\n",
|
||||
"\u001b[34m82.5% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'green'}}\n",
|
||||
"\u001b[34m84.2% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'yellow'}}\n",
|
||||
"\u001b[34m86.0% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'white'}}\n",
|
||||
"\u001b[34m87.7% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow'}}\n",
|
||||
"\u001b[34m89.5% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'red'}}\n",
|
||||
"\u001b[34m91.2% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'blue'}}\n",
|
||||
"\u001b[34m93.0% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'green'}}\n",
|
||||
"\u001b[34m94.7% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'yellow'}}\n",
|
||||
"\u001b[34m96.5% complete\u001b[0m\n",
|
||||
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'white'}}\n",
|
||||
"\u001b[34m98.2% complete\u001b[0m\n",
|
||||
"{'name': 'reject_request', 'arguments': {}}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -887,9 +1046,160 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Let's get the drone in the air, can you make it take off\n",
|
||||
"{'name': 'takeoff_drone', 'arguments': '{\"altitude\": 100}'}\n",
|
||||
"Can you lift the drone to 100 feet off the ground\n",
|
||||
"{'name': 'takeoff_drone', 'arguments': '{\"altitude\": 100}'}\n",
|
||||
"Can you safely bring the drone down to the ground here?\n",
|
||||
"{'name': 'land_drone', 'arguments': '\"{\\\\\"location\\\\\": \\\\\"current\\\\\"}\"'}\n",
|
||||
"Let's land the drone now, right where we are\n",
|
||||
"{'name': 'land_drone', 'arguments': '\"{\\\\\"location\\\\\": \\\\\"current\\\\\"}\"'}\n",
|
||||
"Bring the drone back home and land it safely\n",
|
||||
"{'name': 'land_drone', 'arguments': '\"{\\\\\"location\\\\\": \\\\\"home_base\\\\\"}\"'}\n",
|
||||
"Can you make the drone land at the base station?\n",
|
||||
"{'name': 'land_drone', 'arguments': '\"{\\\\\"location\\\\\": \\\\\"home_base\\\\\"}\"'}\n",
|
||||
"Can you manually land the drone at a specific spot?\n",
|
||||
"{'name': 'land_drone', 'arguments': '\"{\\\\\"location\\\\\": \\\\\"custom\\\\\"}\"'}\n",
|
||||
"I need you to land the drone at a custom location, please.\n",
|
||||
"{'name': 'land_drone', 'arguments': '\"{\\\\\"location\\\\\": \\\\\"custom\\\\\"}\"'}\n",
|
||||
"Can you make the drone move to the left by 10 units?\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': '{\"direction\": \"left\", \"distance\": 10}'}\n",
|
||||
"I need the drone to shift to the left, can you do that?\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': '{\"direction\": \"left\", \"distance\": 10}'}\n",
|
||||
"Can you make the drone go higher by 10 units\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': '{\"direction\": \"up\", \"distance\": 10}'}\n",
|
||||
"I want the drone to ascend 10 meters, can you do that\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': '{\"direction\": \"up\", \"distance\": 10}'}\n",
|
||||
"Can you make the drone go lower by 10 feet?\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': '{\"direction\": \"down\", \"distance\": 10}'}\n",
|
||||
"I need the drone to descend, can you do that?\n",
|
||||
"{'name': 'control_drone_movement', 'arguments': '{\"direction\": \"down\", \"distance\": 10}'}\n",
|
||||
"Can you make the drone go faster?\n",
|
||||
"{'name': 'set_drone_speed', 'arguments': '{\"speed\": 50}'}\n",
|
||||
"I think the drone needs to speed up a bit, can you adjust it?\n",
|
||||
"{'name': 'set_drone_speed', 'arguments': '{\"speed\": 50}'}\n",
|
||||
"Can you switch the camera to photo mode?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"photo\"}'}\n",
|
||||
"I want to take some pictures, can you set the camera to photo mode?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"photo\"}'}\n",
|
||||
"Can you switch the camera to photo mode?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"photo\"}'}\n",
|
||||
"I want to take a picture, can you change the camera to photo mode?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"photo\"}'}\n",
|
||||
"Can you switch the camera to video mode please\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"video\"}'}\n",
|
||||
"I want to record a video, can you set the camera to that mode\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"video\"}'}\n",
|
||||
"Can you start recording a video with the camera for 30 seconds?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"video\", \"duration\": 30}'}\n",
|
||||
"I want to capture a video, can you set it up for 30 seconds?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"video\", \"duration\": 30}'}\n",
|
||||
"Can you switch the camera to panorama mode please\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"panorama\"}'}\n",
|
||||
"I want to take a panoramic shot, can you set the camera for that\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"panorama\"}'}\n",
|
||||
"Can you switch the camera to panoramic mode?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"panorama\", \"duration\": 0}'}\n",
|
||||
"I want to take a wide shot, can you set the camera to panorama?\n",
|
||||
"{'name': 'control_camera', 'arguments': '{\"mode\": \"panorama\", \"duration\": 0}'}\n",
|
||||
"Can you turn on the lights on the drone?\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': '{\"mode\": \"on\"}'}\n",
|
||||
"I'd like to illuminate the drone, can you do that?\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': '{\"mode\": \"on\"}'}\n",
|
||||
"Can you make the drone lights flash?\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': '{\"mode\": \"blink\"}'}\n",
|
||||
"I want the drone lights to blink, please\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': '{\"mode\": \"blink\"}'}\n",
|
||||
"Can you set the drone lights to emergency mode\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': '{\"mode\": \"sos\"}'}\n",
|
||||
"Switch the lighting on the drone to SOS signal\n",
|
||||
"{'name': 'set_drone_lighting', 'arguments': '{\"mode\": \"sos\"}'}\n",
|
||||
"Can you switch on the battery saver mode please?\n",
|
||||
"{'name': 'set_battery_saver_mode', 'arguments': '{\"status\": \"on\"}'}\n",
|
||||
"I'm running low on battery, can you activate the power-saving mode?\n",
|
||||
"{'name': 'set_battery_saver_mode', 'arguments': '{\"status\": \"on\"}'}\n",
|
||||
"The battery saver mode is draining the battery, can you turn it off\n",
|
||||
"{'name': 'set_battery_saver_mode', 'arguments': '{\"status\": \"off\"}'}\n",
|
||||
"I need more power, can you disable the battery saver mode\n",
|
||||
"{'name': 'set_battery_saver_mode', 'arguments': '{\"status\": \"off\"}'}\n",
|
||||
"I keep almost hitting things, can you turn on the obstacle avoidance\n",
|
||||
"{'name': 'set_obstacle_avoidance', 'arguments': '{\"mode\": \"on\"}'}\n",
|
||||
"Can you activate the system that helps me avoid obstacles\n",
|
||||
"{'name': 'set_obstacle_avoidance', 'arguments': '{\"mode\": \"on\"}'}\n",
|
||||
"I don't want the car to avoid obstacles automatically\n",
|
||||
"{'name': 'set_obstacle_avoidance', 'arguments': '{\"mode\": \"off\"}'}\n",
|
||||
"Can you turn off the obstacle avoidance feature please?\n",
|
||||
"{'name': 'set_obstacle_avoidance', 'arguments': '{\"mode\": \"off\"}'}\n",
|
||||
"Can you enable the follow me mode so the drone can track me?\n",
|
||||
"{'name': 'set_follow_me_mode', 'arguments': '{\"status\": \"on\"}'}\n",
|
||||
"I want the drone to follow me, can you turn on that mode?\n",
|
||||
"{'name': 'set_follow_me_mode', 'arguments': '{\"status\": \"on\"}'}\n",
|
||||
"Can you stop the drone from following me now?\n",
|
||||
"{'name': 'set_follow_me_mode', 'arguments': '{\"status\": \"off\"}'}\n",
|
||||
"I don't want the drone to follow me anymore, can you turn that off?\n",
|
||||
"{'name': 'set_follow_me_mode', 'arguments': '{\"status\": \"off\"}'}\n",
|
||||
"The sensors are not working correctly, can you recalibrate them\n",
|
||||
"{'name': 'calibrate_sensors', 'arguments': '{}'}\n",
|
||||
"I think the sensors need to be adjusted, can you do that?\n",
|
||||
"{'name': 'calibrate_sensors', 'arguments': '{}'}\n",
|
||||
"I'm getting tired, can you turn on the autopilot for a bit\n",
|
||||
"{'name': 'set_autopilot', 'arguments': '{\"status\": \"on\"}'}\n",
|
||||
"Let the car drive itself, turn on the autopilot\n",
|
||||
"{'name': 'set_autopilot', 'arguments': '{\"status\": \"on\"}'}\n",
|
||||
"I'm feeling like taking control, can you turn off the autopilot?\n",
|
||||
"{'name': 'set_autopilot', 'arguments': '{\"status\": \"off\"}'}\n",
|
||||
"I want to manually steer now, can you disable the autopilot please?\n",
|
||||
"{'name': 'set_autopilot', 'arguments': '{\"status\": \"off\"}'}\n",
|
||||
"Can you change the color of the lights to yellow?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"solid\", \"color\": \"yellow\"}'}\n",
|
||||
"I prefer a solid pattern for the LED display, can you set that?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"solid\", \"color\": \"yellow\"}'}\n",
|
||||
"Can you make the display show a solid white color\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"solid\", \"color\": \"white\"}'}\n",
|
||||
"I'd like the LED display to be a solid white\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"solid\", \"color\": \"white\"}'}\n",
|
||||
"Can you make the lights flash on and off?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"blink\"}'}\n",
|
||||
"I want the LED display to alternate between on and off, can you do that?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"blink\"}'}\n",
|
||||
"Can you make the lights flash in red?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"blink\", \"color\": \"red\"}'}\n",
|
||||
"Change the LED display to blink in red please\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"blink\", \"color\": \"red\"}'}\n",
|
||||
"Can you make the LED display flash in blue color?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"blink\", \"color\": \"blue\"}'}\n",
|
||||
"I want the LED display to blink, can you set it to blue?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"blink\", \"color\": \"blue\"}'}\n",
|
||||
"Can you make the lights flash in blue?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"pulse\", \"color\": \"blue\"}'}\n",
|
||||
"I'd like the LED display to pulse in blue, please\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"pulse\", \"color\": \"blue\"}'}\n",
|
||||
"Can you change the color and pattern of the LEDs?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"pulse\", \"color\": \"white\"}'}\n",
|
||||
"I'd like to see the LEDs pulse in white, can you set that up?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"pulse\", \"color\": \"white\"}'}\n",
|
||||
"Can you change the LED display to show a rainbow pattern in yellow?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"rainbow\", \"color\": \"yellow\"}'}\n",
|
||||
"I want the LED display to be colorful, can you set it to rainbow with yellow color?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"rainbow\", \"color\": \"yellow\"}'}\n",
|
||||
"Can you change the display to show a rainbow pattern in white color?\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"rainbow\", \"color\": \"white\"}'}\n",
|
||||
"I'd like the LED display to cycle through colors starting with white and then to a rainbow pattern\n",
|
||||
"{'name': 'configure_led_display', 'arguments': '{\"pattern\": \"rainbow\", \"color\": \"white\"}'}\n",
|
||||
"I don't think we should go with that plan, can you reject it\n",
|
||||
"{'name': 'reject_request', 'arguments': '{}'}\n",
|
||||
"Let's not move forward with that, can you decline the request\n",
|
||||
"{'name': 'reject_request', 'arguments': '{}'}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"training_examples = []\n",
|
||||
"\n",
|
||||
@ -900,12 +1210,19 @@
|
||||
" if type(prompt['Input'])!=dict:\n",
|
||||
" prompt['Input'] = ast.literal_eval(prompt['Input'])\n",
|
||||
" prompt['Input']['arguments']=json.dumps(prompt['Input']['arguments'])\n",
|
||||
" for p in ast.literal_eval(prompt['Prompt'].content):\n",
|
||||
" training_examples.append({\"messages\": [{\"role\":\"system\",\"content\":DRONE_SYSTEM_PROMPT\n",
|
||||
" },{\"role\":\"user\",\"content\": p},\n",
|
||||
" {\"role\":\"assistant\",\"function_call\": prompt['Input']}],\n",
|
||||
" \"functions\":function_list})\n",
|
||||
"\n"
|
||||
" try:\n",
|
||||
" prompt['Prompt']=json.loads(prompt['Prompt'])\n",
|
||||
" except:\n",
|
||||
" continue\n",
|
||||
" for p in prompt['Prompt']:\n",
|
||||
" print(p)\n",
|
||||
" print(prompt['Input'])\n",
|
||||
" tool_calls = [{\"id\": \"call_id\", \"type\": \"function\", \"function\": prompt['Input']}]\n",
|
||||
" training_examples.append({\"messages\": [{\"role\":\"system\",\"content\":DRONE_SYSTEM_PROMPT},\n",
|
||||
" {\"role\":\"user\",\"content\": p},\n",
|
||||
" {\"role\":\"assistant\", \"tool_calls\": tool_calls}],\n",
|
||||
" \"parallel_tool_calls\": False,\n",
|
||||
" \"tools\": function_list})\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -917,7 +1234,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -940,7 +1257,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -948,10 +1265,12 @@
|
||||
"for prompt in reject_list:\n",
|
||||
"\n",
|
||||
" #Adjust formatting\n",
|
||||
" reject_training_list.append({\"messages\": [{\"role\":\"system\",\"content\":DRONE_SYSTEM_PROMPT\n",
|
||||
" },{\"role\":\"user\",\"content\": prompt},\n",
|
||||
" {\"role\":\"assistant\",\"function_call\": {\"name\": \"reject_request\",\"arguments\": \"{}\"}}],\n",
|
||||
" \"functions\":function_list})\n"
|
||||
" tool_calls = [{\"id\": \"call_id\", \"type\": \"function\", \"function\": {\"name\": \"reject_request\",\"arguments\": \"{}\"}}]\n",
|
||||
" reject_training_list.append({\"messages\": [{\"role\":\"system\",\"content\":DRONE_SYSTEM_PROMPT},\n",
|
||||
" {\"role\":\"user\",\"content\": prompt},\n",
|
||||
" {\"role\":\"assistant\", \"tool_calls\": tool_calls}],\n",
|
||||
" \"parallel_tool_calls\": False,\n",
|
||||
" \"tools\": function_list})\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -963,7 +1282,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -972,7 +1291,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -999,14 +1318,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"file-xrLV8EbNZk31QPT1TB5KIx7E\n"
|
||||
"file-Mo0qddMOqFpjzKWyzYhd2wpT\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -1041,7 +1360,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -1049,19 +1368,19 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Play pre-recorded audio message\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request') \n",
|
||||
"[ChatCompletionMessageToolCall(id='call_dIL4qO1NeeTM76bHPxxqXter', function=Function(arguments='{}', name='reject_request'), type='function')] \n",
|
||||
"\n",
|
||||
"Initiate live-streaming on social media\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request') \n",
|
||||
"Initiate following on social media\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_Y633k5Eajz0ao2DxyARQTvVO', function=Function(arguments='{}', name='reject_request'), type='function')] \n",
|
||||
"\n",
|
||||
"Scan environment for heat signatures\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request') \n",
|
||||
"[ChatCompletionMessageToolCall(id='call_VtWMLRwVPFKii2ysAjsImajK', function=Function(arguments='{}', name='reject_request'), type='function')] \n",
|
||||
"\n",
|
||||
"Enable stealth mode\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request') \n",
|
||||
"Bump into obstacles\n",
|
||||
"[ChatCompletionMessageToolCall(id='call_4lMU1QtR5FY1Siuipl4gVPNF', function=Function(arguments='{}', name='reject_request'), type='function')] \n",
|
||||
"\n",
|
||||
"Change drone's paint job color\n",
|
||||
"FunctionCall(arguments='{}', name='reject_request') \n",
|
||||
"[ChatCompletionMessageToolCall(id='call_JFLwSzUG5kIr1koQKtlqWd4l', function=Function(arguments='{}', name='reject_request'), type='function')] \n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
@ -1071,9 +1390,9 @@
|
||||
" messages = []\n",
|
||||
" messages.append({\"role\": \"system\", \"content\": DRONE_SYSTEM_PROMPT})\n",
|
||||
" messages.append({\"role\": \"user\", \"content\": eval_question})\n",
|
||||
" completion = get_chat_completion(model=\"ft:gpt-3.5-turbo-0613:openai-internal::8DloQKS2\",messages=messages,tools=function_list)\n",
|
||||
" completion = get_chat_completion(model=\"ft:gpt-3.5-turbo-0125:openai-gtm::9ZJsJGQ6\",messages=messages,tools=function_list,tool_choice='required')\n",
|
||||
" print(eval_question)\n",
|
||||
" print(completion.function_call,'\\n')\n"
|
||||
" print(completion.tool_calls,'\\n')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1114,7 +1433,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.5"
|
||||
"version": "3.12.1"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
87
examples/data/drone_training.jsonl
Normal file
87
examples/data/drone_training.jsonl
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user