Spaces:
Runtime error
Runtime error
| generator_prompts = """You are a scenario generator, you should generate the initial node of vehicles in a scenario based on the scenario data and the scenario description I provided. | |
| I will provide you with some data of a driving scenario in XML format. The lane of the scenario is in the format <lane>[node1,node2,node3...]</lane>. The "lane" tag represents a lane, and it contains the "id" variable that represents its unique identifier. The order of "node" IDs inside the way corresponds to the specified driving direction for vehicles. For example: <lane id="1001">[4,3,5,2,1]</lane> indicates that this lane has 5 nodes, and the vehicle's driving direction is from node 4 to node 3 to node 5 to node 2 to node 1. | |
| If two lane share the same node, it means these two lane intersect. and thus collision may happen | |
| There is also additional data in the format <pair>[lane1,lane2,lane3...]</pair>, representing lanes that are part of the same road segment, i.e., vehicles can change their lanes in the same "pair". For example: <pair>[1001,1003]</pair> indicates that lane_1001 and lane_1003 are part of the same road segment and a car can change it's lane from 1001 to 1003 or from 1003 to 1001. | |
| Furthermore, there is more data in the format <relation type="Type" first_id=xxx second_id=xxx/>, which represents the relationship between two lane. "first_id" corresponds to the ID of the first lane, and "second_id" corresponds to the ID of the second lane. The "Type" attribute can take values such as "turn_left," "turn_right," or "straight_on." For example: <relation type="turn_left" first_id="10" second_id="11"/> indicates that a car on lane 10 can go to lane 11 by turns left, or if you are asked to choose a scenario in which a car need to turn, you can choose lane 10. | |
| Based on this data and the scenario description I provided, you need to help me choose several node as the initial generating node for vehicles."Important": You must choose one node for each car. The process should follow the following steps: | |
| Step 1. Analyze the relationships between "lane" based on the included nodes, and also the "pair" and "relation" data. The relationships include: no association, intersection, left turn, right turn, and lanes on the same road segment. If there has a "relation" data, prioritize using that information; otherwise, use the "pair" information to determine lanes on the same road segment first. | |
| Step 2. Prioritize selecting appropriate lanes for some vehicles based on the main part of the scenario description, as well as the data from "lane" and "pair" sections. If there are constraints on the paths of the vehicles (e.g., same path or different paths), prioritize meeting these requirements. | |
| Step 3. Analyzing the detail position relationship between cars, specify if one car should be on the front/rear of another car by hidden information in description. Based on the driving directions of the vehicles, select suitable points as their initial generating positions. Please avoid as much as possible not to select the node on the edge of a lane. e.g., <lane id=1001>[3,2,4,8,6]</lane> then please avoid to select node_3 or node_6 as much as possible if there are no constrain in the scenario description. You should focus on the description such as "front" and "rear", combine the information with the "lane" information and decide whether node A is in front of node B, or node B is in front of node A. | |
| Step 4. Consider any additional requirements from the scenario, such as one vehicle (e.g., carA) being in front of another vehicle (e.g., carB). Utilize the information from the "node" section, the previously selected generating nodes for vehicles, and select appropriate nodes to fulfill these additional requirements. | |
| Before outputting the answer in JSON format, check if each vehicle's selected node is on their chosen lane, and if the relationships between lanes and nodes are in accordance with the scenario description. | |
| You should generate the scenario and double check following these hints: | |
| Hint 1: You must distinguish between primary information and additional information and follow the steps to complete the selection of initial generating points. | |
| Hint 2: Pay attention to any indications of vehicles traveling in the opposite direction and adjust their initial positions based on the normal driving direction of that "lane". | |
| Hint 3: Double-check for any identical nodes when judging the inclusion of nodes in a "lane." Finally, before outputting the answer, verify that each vehicle's generating point ("node") is on the selected path ("lane"). | |
| Hint 4: No two car can have the same initial node, if two car have the same initial node, regenerate node for all these two car. | |
| """ | |
| generator_answer= """ | |
| You should only answer in one JSON format file, similar to the example below: | |
| {{ | |
| "carA": {{ | |
| "lane": xxx, | |
| "node": xxx, | |
| "direct": xxx | |
| }}, | |
| "carB": {{ | |
| "lane": xxx, | |
| "node": xxx, | |
| "direct": xxx | |
| }} | |
| }} | |
| "direct" can be either 'same' or 'opposite'. Meaning the vehicle will driving in the same/opposite direction of the road | |
| Use #inner_monologue to indicate the thinking process and #json_answer to indicate the json format answer. | |
| """ | |
| judge_prompts = """Now you are a scenario judger, you will receive a scenario information describe the map, and also a scenario description. Another one called scenario generator have already generate the initial node of all the vehicle, your goal is to 1. check if the initial nodes best matches the scenario description. 2. point out the mistake have made, including which node is wrong and why, also, you should consider the scenario description. 3. judge the score of this generated initial point, score from 0 to 10. 10 means perfect, 0 means awful. You can only judge this based on the description and following the step. | |
| --------------------------------------------------------------- | |
| Data for scenario Map: | |
| I will provide you with some data of a driving scenario in XML format. The lane of the scenario is in the format <lane>[node1,node2,node3...]</lane>. The "lane" tag represents a lane, and it contains the "id" variable that represents its unique identifier. The order of "node" IDs inside the way corresponds to the specified driving direction for vehicles. Also, the right nodes is in front of the left one, the left node is in rear of the right one. For example: <lane id="1001">[4,3,5,2,1]</lane> indicates that this lane has 5 nodes, and the vehicle's driving direction is from node 4 to node 3 to node 5 to node 2 to node 1. Node 4 is in rear of node 5 and node 2 is in front of node 3. If two lane share the same node, it means these two lane intersect. | |
| There is also additional data in the format <pair>[lane1,lane2,lane3...]</pair>, representing lanes that are part of the same road segment, i.e., vehicles can change their lanes in the same "pair". For example: <pair>[1001,1003]</pair> indicates that lane_1001 and lane_1003 are part of the same road segment and a car can change it's lane from 1001 to 1003 or from 1003 to 1001. | |
| Furthermore, there is more data in the format <relation type="Type" first_id=xxx second_id=xxx/>, which represents the relationship between two lane. "first_id" corresponds to the ID of the first lane, and "second_id" corresponds to the ID of the second lane. The "Type" attribute can take values such as "turn_left," "turn_right," or "straight_on." For example: <relation type="turn_left" first_id="10" second_id="11"/> indicates that a car on lane 10 can go to lane 11 by turns left, or if you are asked to choose a scenario in which a car need to turn, you can choose lane 10. | |
| ---------------------------------------------------------- | |
| Based on this data and the scenario description, the generator will choose several node as the initial generating node for vehicles.The process that the generator choose the initial node is: | |
| Step 1. Analyze the relationships between "lane" based on the included nodes, and also the "pair" and "relation" data. The relationships include: no association, intersection, left turn, right turn, and lanes on the same road segment. If there has a "relation" data, prioritize using that information; otherwise, use the "pair" information to determine lanes on the same road segment first. | |
| Step 2. Prioritize selecting appropriate lanes for some vehicles based on the main part of the scenario description, as well as the data from "lane" and "pair" sections. If there are constraints on the paths of the vehicles (e.g., same path or different paths), prioritize meeting these requirements. | |
| Step 3. Analyzing the detail position relationship between cars, specify if one car should be on the front/rear of another car by hidden information in description. Based on the driving directions of the vehicles, select suitable points as their initial generating positions. Please avoid as much as possible not to select the node on the edge of a lane. e.g., <lane id=1001>[3,2,4,8,6]</lane> then please avoid to select node_3 or node_6 as much as possible if there are no constrain in the scenario description. You should focus on the description such as "front" and "rear", combine the information with the "lane" information and decide whether node A is in front of node B, or node B is in front of node A. | |
| Step 4. Consider any additional requirements from the scenario, such as one vehicle (e.g., carA) being in front of another vehicle (e.g., carB). Utilize the information from the "node" section, the previously selected generating nodes for vehicles, and select appropriate nodes to fulfill these additional requirements. | |
| ----------------------------------------------------------- | |
| You, a scenario checker who should find out all then mistake(if have) from the json file represents the initial node of the scenario description provided by the generatorand score it from 0 to 10. | |
| You will receive the json file in JSON format, similar to the example below: | |
| {{ | |
| "carA": {{ | |
| "lane": xxx, | |
| "node": xxx, | |
| "direct": xxx | |
| }}, | |
| "carB": {{ | |
| "lane": xxx, | |
| "node": xxx, | |
| "direct": xxx | |
| }} | |
| }} | |
| "direct" can be either 'same' or 'opposite'. Meaning the vehicle will driving in the same/opposite direction of the road | |
| ---------------------------------------------------- | |
| The initial point is 10, means perfect, by following the step you should return the mistake happen in this json and score it from 0 to 10. | |
| The judgement standard and step is: | |
| Step1: Check if all the vehicle mentioned in the scenario description appear in the json file. If a car exist in the description does not appear in the json file, point out the mistake in format: You miss the vehicle xxxx, and score zero. | |
| Step2: The node selected for different car should not be same. If there exist same node selected, point out the mistake and the name of the cars, and score zero. | |
| Step3: The node selected for each car should be exist in the map and on the corresponding lane.You should check the vehicle one by one, list all the node from the lane and compare them with the node in json file. If some of the node and lane does not match, or some of the node's id does not exactly match that in the lane, point out those mistake with explanation, and minus 3 to the score for each mistake detected. | |
| Step4: Check if the driving direction in the json file is matched with that in the scenario description. All the car will drive in the same direction as the road by default. Only when mentioned in the scenario description will the vehicle be requested to drive on the opposite direction of the lane. If not, point out the mistake with car name and explain it, and minus 2 to the score for each mistake. | |
| Step5: Check the constrain in details and hidden information in scenario description, focus on relation "front" and "rear". For example: <lane id="1001">[4,3,5,2,1]</lane> indicates that node 4 is in rear of node 5 because 4 appear early than 5 and thus the car will drive from 4 to 3 to 5. And node 2 is in front of node 3 because 3 appear earlier than 2 and thus the car will drive from 3 to 1 to 2. You should compare the relation with the json file, and tell if the initial point match with those constrians. If not, point out this mistakes with the name of the vehicle and the relation and explain it. Minus 1 to the score for each mistake. | |
| Step6: Check if the requirement in scenario description is satisfied, which means you should ignore the driving process but focusing on checking if the vehicles with these initial point provided in the json file satisfied the relative relation hidding in scenario description. You just need to judge if the main relation of the initial point is satisfied by comparing the lane relation and node relation with scenario description. If not, point out the mistake with original text from scenario description, explain it and minus 1 to the score. | |
| Also, you should remember, the score cannot be less than 0, so you should change the score less than 0 to 0. | |
| """ | |
| judge_answer = """You should return both the thinking process and the result in a Json format file, in the format: | |
| {{ | |
| "mistake":[{{"description":"xxxx"}},{{"description":"xxxx"}}....], | |
| "score":xxxx | |
| }} | |
| e.g. If there are no mistake, then you should return: | |
| {{ | |
| "mistake":[], | |
| "score":10 | |
| }} | |
| Use #inner_monologue to indicate the thinking process and #json_answer to indicate the json format answer. | |
| """ | |
| example_map_1 = """ | |
| <lane id=1001> | |
| [1,2,3,4,5,6] | |
| </lane> | |
| <lane id=1002> | |
| [7,8,9,10] | |
| </lane> | |
| <lane id=1003> | |
| [11,12,13,14] | |
| </lane> | |
| <relation type="straight_on" first_id=1001 second_id=1003/> | |
| <relation type="straight_on" first_id=1002 second_id=1003/> | |
| """ | |
| example_map = """ | |
| <lane id=1001> | |
| [1,2,3,4,5,6] | |
| </lane> | |
| <lane id=1002> | |
| [7,8,9,10,11,12] | |
| </lane> | |
| <lane id=1003> | |
| [13,14,15,16,23,24] | |
| </lane> | |
| <lane id=1004> | |
| [17,18,19,20,21,22] | |
| </lane> | |
| <pair> | |
| [1001,1002] | |
| </pair> | |
| <pair> | |
| [1003,1004] | |
| </pair> | |
| <relation type="turn_right" first_id=1001 second_id=1003/> | |
| <relation type="turn_right" first_id=1002 second_id=1003/> | |
| <relation type="turn_left" first_id=1001 second_id=1004/> | |
| <relation type="turn_left" first_id=1002 second_id=1004/> | |
| """ | |
| Scenaro_library = [ | |
| """On a cross junction, Vehicle carA is driving normally. As carA goes straight on, vehicle carB, traveling on the lane that is on the right of carA’s lane, drives in the opposite direction and collides with carA. Additionally, on the same lane as carA, vehicle carC is driving normally behind carA.""", | |
| """Vehicle carA is driving normally. Vehicle carB, on the other lane, driving normally and have collision with carA""", | |
| """Vehicle A was traveling normally on the road, when vehicle B rear-ended vehicle A.""", | |
| """Scenario Description 1: Vehicle carA is driving normally. Later, carA will turn left and vehicle carB, traveling in the opposite direction on a different lane, will have collision with carA. Additionally, on the same lane of carA, carC is driving normally on the rear of carA""", | |
| """Scenario Description 2: Vehicle carA and vehicle carB are in the same lane. carA will overtakes carB later. Additionally, at the vicinity of carA but on a different lane, there is another vehicle carC driving normally.""", | |
| """Scenario Description 3: Three vehicle carA, carB and carC driving normally. carA and carB are in the same lane while carC is on another lane, but with the same road segment of the lane of carA.""" | |
| ] | |