Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 02c3347

Browse files
committed
Remove get_tool_name_from_messages
This was superseded by using the client enum. Related: #830
1 parent ec96a31 commit 02c3347

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

src/codegate/pipeline/codegate_context_retriever/codegate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import structlog
55
from litellm import ChatCompletionRequest
66

7+
from codegate.clients.clients import ClientType
78
from codegate.pipeline.base import (
89
AlertSeverity,
910
PipelineContext,
@@ -13,7 +14,7 @@
1314
from codegate.pipeline.extract_snippets.extract_snippets import extract_snippets
1415
from codegate.storage.storage_engine import StorageEngine
1516
from codegate.utils.package_extractor import PackageExtractor
16-
from codegate.utils.utils import generate_vector_string, get_tool_name_from_messages
17+
from codegate.utils.utils import generate_vector_string
1718

1819
logger = structlog.get_logger("codegate")
1920

@@ -128,14 +129,13 @@ async def process( # noqa: C901
128129
new_request = request.copy()
129130

130131
# perform replacement in all the messages starting from this index
131-
base_tool = get_tool_name_from_messages(request)
132-
if base_tool != "open interpreter":
132+
if context.client != ClientType.OPEN_INTERPRETER:
133133
for i in range(last_user_idx, len(new_request["messages"])):
134134
message = new_request["messages"][i]
135135
message_str = str(message["content"]) # type: ignore
136136
context_msg = message_str
137137
# Add the context to the last user message
138-
if base_tool in ["cline", "kodu"]:
138+
if context.client in [ClientType.CLINE, ClientType.KODU]:
139139
match = re.search(r"<task>\s*(.*?)\s*</task>(.*)", message_str, re.DOTALL)
140140
if match:
141141
task_content = match.group(1) # Content within <task>...</task>

src/codegate/utils/utils.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,3 @@ def generate_vector_string(package) -> str:
3232
# add description
3333
vector_str += f" - Package offers this functionality: {package['description']}"
3434
return vector_str
35-
36-
37-
def get_tool_name_from_messages(data):
38-
"""
39-
Identifies the tool name based on the content of the messages.
40-
41-
Args:
42-
request (dict): The request object containing messages.
43-
tools (list): A list of tool names to search for.
44-
45-
Returns:
46-
str: The name of the tool found in the messages, or None if no match is found.
47-
"""
48-
tools = ["Cline", "Kodu", "Open Interpreter", "Aider"]
49-
for message in data.get("messages", []):
50-
message_content = str(message.get("content", ""))
51-
for tool in tools:
52-
if tool in message_content:
53-
return tool.lower()
54-
return None

0 commit comments

Comments
 (0)