Skip to content

Commit 9873a71

Browse files
committed
run darglint
1 parent 520e641 commit 9873a71

File tree

3 files changed

+5
-65
lines changed

3 files changed

+5
-65
lines changed

src/agentlab/agents/bm25_agent/bm25_retriever.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -70,64 +70,3 @@ def create_text_chunks(self, axtree, chunk_size=200, overlap=50):
7070
return text_splitter.split_text(axtree)
7171
else:
7272
return get_chunks_from_tokenizer(axtree, self.chunk_size, self.overlap)
73-
74-
@staticmethod
75-
def extract_bid(line):
76-
"""
77-
Extracts the bid from a line in the format '[bid] textarea ...'.
78-
79-
Parameters:
80-
line (str): The input line containing the bid in square brackets.
81-
82-
Returns:
83-
str: The extracted bid, or None if no bid is found.
84-
"""
85-
match = re.search(r"\[([a-zA-Z0-9]+)\]", line)
86-
if match:
87-
return match.group(1)
88-
return None
89-
90-
@classmethod
91-
def get_elements_around(cls, tree, element_id, n):
92-
"""
93-
Get n elements around the given element_id from the AXTree while preserving its indentation structure.
94-
95-
:param tree: String representing the AXTree with indentations.
96-
:param element_id: The element ID to center around (can include alphanumeric IDs like 'a203').
97-
:param n: The number of elements to include before and after.
98-
:return: String of the AXTree elements around the given element ID, preserving indentation.
99-
"""
100-
# Split the tree into lines
101-
lines = tree.splitlines()
102-
103-
# Extract the line indices and content containing element IDs
104-
id_lines = [(i, line) for i, line in enumerate(lines) if "[" in line and "]" in line]
105-
106-
# Parse the IDs from the lines
107-
parsed_ids = []
108-
for idx, line in id_lines:
109-
try:
110-
element_id_in_line = line.split("[")[1].split("]")[0]
111-
parsed_ids.append((idx, element_id_in_line, line))
112-
except IndexError:
113-
continue
114-
115-
# Find the index of the element with the given ID
116-
target_idx = next(
117-
(i for i, (_, eid, _) in enumerate(parsed_ids) if eid == element_id), None
118-
)
119-
120-
if target_idx is None:
121-
raise ValueError(f"Element ID {element_id} not found in the tree.")
122-
123-
# Calculate the range of elements to include
124-
start_idx = max(0, target_idx - n)
125-
end_idx = min(len(parsed_ids), target_idx + n + 1)
126-
127-
# Collect the lines to return
128-
result_lines = []
129-
for idx in range(start_idx, end_idx):
130-
line_idx = parsed_ids[idx][0]
131-
result_lines.append(lines[line_idx])
132-
133-
return "\n".join(result_lines)

src/agentlab/agents/focus_agent/focus_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FocusAgentArgs(GenericAgentArgs):
3636
retriever_prompt_flags: LlmRetrieverPromptFlags = None
3737
max_retry: int = 4
3838
keep_structure: bool = False
39-
strategy: Literal["bid", "role", "bid+role"] = "bid"
39+
strategy: Literal["bid", "bid+role"] = "bid"
4040
benchmark: str = None
4141
retriever_type: Literal["line", "defender", "restrictive", "neutral"] = "line"
4242

src/agentlab/agents/focus_agent/llm_retriever_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def remove_lines(tree: str, line_numbers: list[int]) -> str:
4747

4848
@staticmethod
4949
def remove_lines_keep_structure(
50-
tree: str, line_numbers: list[int], strategy: Literal["bid", "role", "bid+role"]
50+
tree: str, line_numbers: list[int], strategy: Literal["bid", "bid+role"]
5151
) -> str:
5252
"""
5353
Remove all other lines that are not in line_numbers.
@@ -56,6 +56,9 @@ def remove_lines_keep_structure(
5656
Args:
5757
tree (str): The tree containing content to process
5858
line_numbers (list[int]): Line numbers to keep (1-indexed)
59+
strategy (Literal["bid", "bid+role"]): Strategy to keep structure
60+
- "bid": keep only the bid of the element and replace the rest of the line
61+
- "bid+role": keep the bid and role of the element and replace the rest of the line
5962
6063
Returns:
6164
str: Content with only specified lines kept, other parts replaced by tags
@@ -74,8 +77,6 @@ def remove_lines_keep_structure(
7477
tag = (
7578
line.split()[0] + " ... removed ..."
7679
) # keep bid and replace the rest of the line with removed
77-
case "role":
78-
raise NotImplementedError("Strategy keep role only not implemented.")
7980
case "bid+role":
8081
if ("[" not in line) and ("]" not in line):
8182
tag = line.split()[

0 commit comments

Comments
 (0)