(sql_data)
| 84 | # Create the directory if it does not exist |
| 85 | if not os.path.exists(search_directory): |
| 86 | os.makedirs(search_directory) |
| 87 | |
| 88 | # Skip processing if results already exist and overwrite is not allowed |
| 89 | if os.path.exists(agent_format.complete_sql_save_path): |
| 90 | return |
| 91 | |
| 92 | # Ensure the search directory exists (in case it was removed) |
| 93 | if not os.path.exists(search_directory): |
| 94 | os.makedirs(search_directory) |
| 95 | |
| 96 | # Get table information |
| 97 | table_info = get_table_info(args.db_path, sql_data, agent_format.api, clear_des=True) |
| 98 | |
| 99 | # Format answer and update the pre-chat session |
| 100 | format_csv, chat_session_format = agent_format.format_answer(task, chat_session_format) |
| 101 | |
| 102 | # Skip task if the context is too long |
| 103 | if chat_session_format.get_message_len() > 200000: |
| 104 | print(f"{sql_data} Too long context, skip") |
| 105 | return |
| 106 | |
| 107 | if args.model_vote: |
| 108 | num_votes = args.num_votes |
| 109 | sql_paths = {} |
| 110 | threads = [] |
| 111 | |
| 112 | for i in range(num_votes): |
| 113 | csv_save_pathi = str(i) + agent_format.csv_save_name |
| 114 | log_pathi = str(i) + agent_format.log_save_name |
| 115 | sql_save_pathi = str(i) + agent_format.sql_save_name |
| 116 | sql_paths[sql_save_pathi] = csv_save_pathi |
| 117 | |
| 118 | thread = threading.Thread( |
| 119 | target=execute, |
| 120 | args=( |
| 121 | task, table_info, args, |
| 122 | csv_save_pathi, log_pathi, sql_save_pathi, |
| 123 | search_directory, format_csv, sql_data |
| 124 | ) |
| 125 | ) |
| 126 | threads.append(thread) |
| 127 | thread.start() |
| 128 | |
| 129 | # wait |
| 130 | for thread in threads: |
| 131 | thread.join() |
| 132 | |
| 133 | if "result.sql" not in os.listdir(search_directory): |
| 134 | if any(file.endswith('.sql') for file in os.listdir(search_directory) if os.path.isfile(os.path.join(search_directory, file))): |
| 135 | # After all processes have completed, perform the vote result |
| 136 | agent_format.vote_result(search_directory, task, chat_session_format, sql_paths, table_info) |
| 137 | else: |
| 138 | print(f"{sql_data}: Empty") |
| 139 | else: |
| 140 | # Directly execute the task |
| 141 | execute( |
| 142 | task, table_info, args, |
| 143 | agent_format.csv_save_name, agent_format.log_save_name, agent_format.sql_save_name, |
nothing calls this directly
no test coverage detected