Spaces:
No application file
No application file
File size: 21,044 Bytes
92ef79b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# Description of robots
DESCRIPTION_ROBOT = {
"excavator": {'width': 100, 'height': 100, 'functions': ["Excavation", "Unloading"]},
"dump_truck": {'width': 50, 'height': 100, 'functions': ["Loading", "Unloading"]},
}
# Navigation functions
NAVIGATION_FUNCTIONS = [
"avoid_areas_for_all_robots",
"avoid_areas_for_specific_robots",
"target_area_for_all_robots",
"target_area_for_specific_robots",
"allow_areas_for_all_robots",
"allow_areas_for_specific_robots",
"return_to_start_for_all_robots",
"return_to_start_for_specific_robots"
]
ROBOT_SPECIFIC_FUNCTIONS = [
"Excavation",
"ExcavatorUnloading",
"DumpUnloading",
"DumpLoading"
]
# Robot names
ROBOT_NAMES = {
"robot_dump_truck_01": {"id": "robot_dump_truck_01", "type": "dump_truck"},
"robot_dump_truck_02": {"id": "robot_dump_truck_02", "type": "dump_truck"},
# "robot_dump_truck_03": {"id": "robot_dump_truck_03", "type": "dump_truck"},
# "robot_dump_truck_04": {"id": "robot_dump_truck_04", "type": "dump_truck"},
# "robot_dump_truck_05": {"id": "robot_dump_truck_05", "type": "dump_truck"},
# "robot_dump_truck_06": {"id": "robot_dump_truck_06", "type": "dump_truck"},
"robot_excavator_01": {"id": "robot_excavator_01", "type": "excavator"},
# "robot_excavator_02": {"id": "robot_excavator_02", "type": "excavator"},
}
# Get robot functions
def get_robot_functions(robot_name):
robot_type = ROBOT_NAMES[robot_name]["type"]
specific_functions = DESCRIPTION_ROBOT[robot_type]["functions"]
return NAVIGATION_FUNCTIONS + specific_functions
# Get all functions description for planner mode
def get_all_functions_description():
description = "Here are the common navigation functions for all robots:\n\n"
description += ", ".join(NAVIGATION_FUNCTIONS) + "\n\n"
description += "Here are the robots in the system and their specific functions:\n\n"
for robot_name, robot_info in ROBOTS_CONFIG['robot_names'].items():
specific_functions = [func for func in ROBOTS_CONFIG["get_robot_functions"](robot_name) if func not in NAVIGATION_FUNCTIONS]
functions = ", ".join(specific_functions)
description += f"- {robot_name}: {robot_info['type']} ({functions})\n"
return description
# Robots configuration
ROBOTS_CONFIG = {
"description_robot": DESCRIPTION_ROBOT,
"robot_names": ROBOT_NAMES,
"get_robot_functions": get_robot_functions,
"get_all_functions_description": get_all_functions_description
}
# Model configuration
MODEL_CONFIG = {
"model_options": ["gpt-4o", "gpt-3.5-turbo", "gpt-4-turbo", "claude-3-haiku-20240307", "claude-3-5-sonnet-20240620", "claude-3-opus-20240229", "llama-3.3-70b-versatile", "llama-3.1-8b-instant", "llama3.3:70b-instruct-q4_K_M", "llama3.1:8b"],
"default_model": "gpt-4o",
"model_type": "openai",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
}
# Flag to determine whether confirmation is required
CONFIRMATION_REQUIRED = False # Set to False if confirmation is not required
# Initial messages configuration
if CONFIRMATION_REQUIRED:
INITIAL_MESSAGES_CONFIG = {
"system": (
"You are a confident and pattern-following assistant that assists the operator in managing multiple construction robots on a construction site. "
"In regular conversations, do not generate or send JSON commands. "
"When it becomes necessary to control the robot swarm, generate the appropriate JSON command but do not send it immediately. "
"You must ask the operator for confirmation before sending the JSON command. "
"When asking for confirmation, provide a detailed summary of the command's purpose and expected actions, but **do not include the actual JSON code**. "
"Use the following format for confirmation: "
"'I am ready to send a command to [target] on the construction site. The command will [brief description of action]. "
"Key details: [list important parameters or actions]. Do you agree to proceed with this command?' "
"It is crucial that you follow this instruction strictly to avoid including any JSON in the confirmation message, "
"while still providing a clear and detailed description of the command's intent and effects. "
"After receiving confirmation (e.g., 'yes', 'proceed', 'agreed'), immediately send the JSON command without further questions or explanations. "
"If the confirmation is negative or unclear, ask for clarification or await further instructions without sending the command."
),
"user_intro": {
"default": (
"I would like you to assist in managing multiple construction robots on a construction site. "
"In most cases, you should engage in regular conversation without generating or sending JSON commands. "
"However, when it becomes necessary to control the robot swarm, you should write JSON to do so, but only after confirming with me. "
"When confirming, **do not include the JSON code in your confirmation response under any circumstances**. "
"Instead, provide a detailed summary of the command's purpose and expected actions using the following format: "
"'I am ready to send a command to [target] on the construction site. The command will [brief description of action]. "
"Key details: [list important parameters or actions]. Do you agree to proceed with this command?' "
"It is essential to adhere to this format, providing a clear description of the command's intent and effects, "
"while avoiding the inclusion of any JSON in the confirmation message. "
"Once I confirm (e.g., by saying 'yes', 'proceed', or 'agreed'), immediately send the JSON command without asking any more questions. "
"If I don't confirm or my response is unclear, ask for clarification or wait for further instructions. "
"Pay attention to patterns that appear in the given context code. "
"Be thorough and thoughtful in your JSON. Do not include any import statements. Do not repeat my question. Do not provide any text explanation. "
"Note that x is back to front, y is left to right, and z is bottom to up.\n\n"
"Only use functions from the following library:\n\n\n{library}\n\n\n"
"Consider the following environmental objects in the scene:\n\n\n```{env_objects}```\n\n\n"
"The available robots on the construction site are:\n\n\n```{robot_names}```\n\n\n"
"Here are some examples of how to format the JSON based on previous queries:\n\n\n```{fewshot_examples}```\n\n\n"
),
"task_2_commannd_prompt": "You are working on decomposing tasks for the robots.",
"dart": "You are working on decomposing tasks for the robots.",
"task_decomposer": "You are working on decomposing tasks for the robots.",
"composer": "You are composing high-level tasks for the robots.",
"instruction_translator": "You are translating instructions for the robots.",
"planner": "You are planning tasks for the robots. Please use both navigation functions and robot-specific functions from the following list:\n\n{functions_description}\n\n"
},
"assistant": (
"Understood. I will generate the JSON and seek your confirmation by providing a detailed summary of the command's purpose and expected actions, without including the actual JSON code. "
"I will use the format: 'I am ready to send a command to [target] on the construction site. The command will [brief description of action]. Key details: [list important parameters or actions]. Do you agree to proceed with this command?' "
"This confirmation message will not include any JSON code but will give you a clear understanding of the command's intent and effects. "
"Once you confirm with a positive response like 'yes', 'proceed', or 'agreed', I will immediately send the JSON command without asking any further questions. "
"If your response is negative or unclear, I will seek clarification or await further instructions before proceeding."
)
}
else:
INITIAL_MESSAGES_CONFIG = {
"system": (
"You are a confident and pattern-following assistant that pays attention to the user's instructions and writes good JSON for controlling multiple construction robots in a construction site. "
"Please ensure that the JSON code is properly formatted with consistent indentation and alignment for better readability and ease of use when copying."
),
"user_intro": {
"default": (
"I would like you to help me write JSON to control multiple construction robots in a construction site. "
"Please complete the JSON code every time when I give you a new query. Pay attention to patterns that appear in the given context code. "
"Be thorough and thoughtful in your JSON. Do not include any import statement. Do not repeat my question. Do not provide any text explanation. "
"Note that x is back to front, y is left to right, and z is bottom to up.\n\n"
"Only use functions from the following library:\n\n\n{library}\n\n\n"
"Consider the following environmental objects in the scene:\n\n\n```{env_objects}```\n\n\n"
"The available robots in the construction site are:\n\n\n```{robot_names}```\n\n\n"
"Here are some examples of how to format the JSON based on previous queries:\n\n\n```{fewshot_examples}```\n\n\n"
),
"task_2_commannd_prompt": "You are working on decomposing tasks for the robots.",
"dart": "You are working on decomposing tasks for the robots.",
"task_decomposer": "You are working on decomposing tasks for the robots.",
"composer": "You are composing high-level tasks for the robots.",
"instruction_translator": "You are translating instructions for the robots.",
"planner": "You are planning tasks for the robots. Please use both navigation functions and robot-specific functions from the following list:\n\n{functions_description}\n\n"
},
"assistant": "Got it. I will complete the JSON you provide next."
}
# Mode configuration
MODE_CONFIG = {
"task_2_commannd_prompt": {
"display_name": "Task to Command",
"prompt_file": "./prompts/swarm/task_2_commannd_prompt.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "gpt-4o",
# "model_version": "claude-3-haiku-20240307",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_gpt_4o": {
"display_name": "gpt-4o",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "gpt-4o",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_gpt_4_turbo": {
"display_name": "gpt-4-turbo",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "gpt-4-turbo",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_gpt_3_5_turbo": {
"display_name": "gpt-3.5-turbo",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "gpt-3.5-turbo",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_claude_3_haiku": {
"display_name": "claude-3-haiku",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "claude-3-haiku-20240307",
"provider": "anthropic",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_claude_3_sonnet": {
"display_name": "claude-3-5-sonnet",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "claude-3-5-sonnet-20240620",
"provider": "anthropic",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_claude_3_opus": {
"display_name": "claude-3-opus",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "claude-3-opus-20240229",
"provider": "anthropic",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_llama_3_3_70b": {
"display_name": "llama-3.3-70b-versatile",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "llama-3.3-70b-versatile",
"provider": "groq",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_llama_3_1_8b": {
"display_name": "llama-3.1-8b-instant",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "llama-3.1-8b-instant",
"provider": "groq",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_ollama_llama3_1_8b": {
"display_name": "ollama-llama3.1:8b",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "llama3.1:8b",
"provider": "ollama",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"dart_ollama_llama3_3_70b": {
"display_name": "ollama-llama3.3:70b",
"prompt_file": "./prompts/swarm/dart.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "llama3.3:70b-instruct-q4_K_M",
"provider": "ollama",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": [
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"task_decomposer": {
"display_name": "Task Decomposer",
"prompt_file": "./prompts/swarm/task_decomposer_prompt.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "gpt-4o",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": ["tasks_topic"],
"json_keys": {"tasks": "tasks_topic"},
"functions_description": ""
},
"composer": {
"display_name": "Composer",
"prompt_file": "./prompts/swarm/composer_prompt.txt",
"type": "GRADIO_MESSAGE_MODES",
"model_version": "gpt-4o",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": [],
"output_topics": ["tasks_topic"],
"json_keys": {"tasks": "tasks_topic"},
"functions_description": ""
},
"instruction_translator": {
"display_name": "Instruction Translator (Developer Mode)",
"prompt_file": "./prompts/swarm/instruction_translator_prompt.txt",
"type": "ROS_MESSAGE_MODE",
"model_version": "gpt-4o",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": ["tasks_topic"],
"output_topics": [
"robovla_instruction_translator_out",
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ""
},
"planner": {
"display_name": "Planner (Developer Mode)",
"prompt_file": "./prompts/swarm/planner_prompt.txt",
"type": "ROS_MESSAGE_MODE",
"model_version": "gpt-4o",
"provider": "openai",
"max_tokens": 2048,
"temperature": 0,
"frequency_penalty": 0,
"input_topics": ["tasks_topic"],
"output_topics": [
"robovla_instruction_translator_out",
"instruction_topic",
"keywords_topic"
],
"json_keys": {
"instruction_function": "instruction_topic",
"clip_keywords": "keywords_topic"
},
"functions_description": ROBOTS_CONFIG["get_all_functions_description"]()
}
}
# Default modes to display in the UI
# GRADIO_MESSAGE_MODES = ["task_2_commannd_prompt", "task_decomposer", "instruction_translator", "composer", "planner"]
GRADIO_MESSAGE_MODES = ["dart_gpt_4o", "dart_gpt_3_5_turbo", "dart_gpt_4_turbo", "dart_claude_3_haiku", "dart_claude_3_sonnet", "dart_claude_3_opus", "dart_llama_3_3_70b","dart_llama_3_1_8b", "dart_ollama_llama3_3_70b", "dart_ollama_llama3_1_8b", "task_2_commannd_prompt"]
ROS_MESSAGE_MODE = "instruction_translator"
|