Identify dynamic parts present in the cURL command
(self, state: AgentState)
| 144 | return state |
| 145 | |
| 146 | def dynamic_part_identifying_agent(self, state: AgentState) -> AgentState: |
| 147 | """ |
| 148 | Identify dynamic parts present in the cURL command |
| 149 | """ |
| 150 | in_process_node_id = state[self.TO_BE_PROCESSED_NODES_KEY].pop() |
| 151 | request = self.dag_manager.graph.nodes[in_process_node_id]["content"]["key"] |
| 152 | curl = request.to_minified_curl_command() |
| 153 | if curl.endswith(".js'"): |
| 154 | self.dag_manager.update_node(in_process_node_id, dynamic_parts=[]) |
| 155 | state[self.IN_PROCESS_NODE_DYNAMIC_PARTS_KEY] = [] |
| 156 | state[self.IN_PROCESS_NODE_KEY] = in_process_node_id |
| 157 | return state |
| 158 | |
| 159 | |
| 160 | input_variables = state[self.INPUT_VARIABLES_KEY] |
| 161 | |
| 162 | function_def = { |
| 163 | "name": "identify_dynamic_parts", |
| 164 | "description": ( |
| 165 | "Given the above cURL command, identify which parts are dynamic and validated by the server " |
| 166 | "for correctness (e.g., IDs, tokens, session variables). Exclude any parameters that represent " |
| 167 | "arbitrary user input or general data that can be hardcoded (e.g., amounts, notes, messages)." |
| 168 | ), |
| 169 | "parameters": { |
| 170 | "type": "object", |
| 171 | "properties": { |
| 172 | "dynamic_parts": { |
| 173 | "type": "array", |
| 174 | "items": {"type": "string"}, |
| 175 | "description": ( |
| 176 | "List of dynamic parts identified in the cURL command. Do not include duplicates. " |
| 177 | "Only strictly include the dynamic values (not the keys or any not extra part in front and after the value) of parts that are unique to a user or session " |
| 178 | "and, if incorrect, will cause the request to fail." |
| 179 | "Do not include the keys, only the values." |
| 180 | ), |
| 181 | } |
| 182 | }, |
| 183 | "required": ["dynamic_parts"], |
| 184 | }, |
| 185 | } |
| 186 | |
| 187 | prompt = f""" |
| 188 | URL: {curl} |
| 189 | |
| 190 | Task: |
| 191 | |
| 192 | Use your best judgment to identify which parts of the cURL command are dynamic, specific to a user or session, and are checked by the server for validity. These include tokens, IDs, session variables, or any other values that are unique to a user or session and, if incorrect, will cause the request to fail. |
| 193 | |
| 194 | Important: |
| 195 | - IGNORE THE COOKIE HEADER |
| 196 | - Ignore common headers like user-agent, sec-ch-ua, accept-encoding, referer, etc. |
| 197 | - Exclude parameters that represent arbitrary user input or general data that can be hardcoded, such as amounts, notes, messages, actions, etc. |
| 198 | - Only output the variable values and not the keys. |
| 199 | - Only include dynamic parts that are unique identifiers, tokens, or session variables. |
| 200 | |
| 201 | """ |
| 202 | |
| 203 | response = llm.get_instance().invoke( |