Spaces:
Paused
Paused
Selcan Yukcu
commited on
Commit
·
e948c11
1
Parent(s):
af03acd
refactor: rename and update multi-module bug localization tool and request model
Browse files
main.py
CHANGED
|
@@ -6,7 +6,7 @@ from loguru import logger
|
|
| 6 |
from dataclasses import dataclass
|
| 7 |
|
| 8 |
from utils.config import API_CONFIG
|
| 9 |
-
from utils.model import
|
| 10 |
|
| 11 |
@dataclass
|
| 12 |
class DSContext:
|
|
@@ -27,36 +27,30 @@ async def ds_lifespan(server: FastMCP) -> AsyncIterator[DSContext]:
|
|
| 27 |
mcp = FastMCP(name="defect-solver-server", lifespan=ds_lifespan)
|
| 28 |
|
| 29 |
|
|
|
|
| 30 |
@mcp.tool(
|
| 31 |
-
name="
|
| 32 |
description=(
|
| 33 |
"""
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
Args:
|
| 37 |
-
request (
|
| 38 |
-
ctx (Context):
|
| 39 |
-
|
| 40 |
Returns:
|
| 41 |
-
dict:
|
| 42 |
"""
|
| 43 |
),
|
| 44 |
)
|
| 45 |
-
async def
|
| 46 |
-
"""
|
| 47 |
-
Given a BugLocalizationRequest, this tool analyzes the entire microservice architecture of the project, identifies the most likely microservices and code files that may contain the bug, and returns a list of candidate microservices and files for further investigation.
|
| 48 |
-
|
| 49 |
-
Args:
|
| 50 |
-
request (BugLocalizationRequest): The bug localization request data.
|
| 51 |
-
ctx (Context): The MCP context containing lifespan context.
|
| 52 |
-
|
| 53 |
-
Returns:
|
| 54 |
-
dict: Predicted source code locations or error details.
|
| 55 |
-
"""
|
| 56 |
ds_ctx: DSContext = ctx.request_context.lifespan_context
|
| 57 |
client = ds_ctx.client
|
| 58 |
|
| 59 |
-
api_url = API_CONFIG["api_base_url"] + API_CONFIG["
|
| 60 |
hf_token = API_CONFIG.get("hf_access_token", None)
|
| 61 |
|
| 62 |
headers = {
|
|
@@ -65,7 +59,7 @@ async def full_bug_localization(request: BugLocalizationRequest, ctx: Context) -
|
|
| 65 |
}
|
| 66 |
|
| 67 |
try:
|
| 68 |
-
logger.info(f"Sending bug localization request to {api_url} with data: {request.model_dump()}")
|
| 69 |
response = await client.post(
|
| 70 |
api_url,
|
| 71 |
json={
|
|
@@ -81,13 +75,13 @@ async def full_bug_localization(request: BugLocalizationRequest, ctx: Context) -
|
|
| 81 |
logger.info(f"Received response: {response.text}")
|
| 82 |
return response.json()
|
| 83 |
except httpx.HTTPStatusError as e:
|
| 84 |
-
logger.error(f"HTTP error {e.response.status_code} from bug localization endpoint: {e.response.text}")
|
| 85 |
return {"error": f"HTTP error: {e.response.status_code}", "details": e.response.text}
|
| 86 |
except httpx.RequestError as e:
|
| 87 |
-
logger.error(f"Request error while calling bug localization endpoint: {e}")
|
| 88 |
return {"error": "Request error", "details": str(e)}
|
| 89 |
except Exception as e:
|
| 90 |
-
logger.exception("Unexpected error during bug localization request")
|
| 91 |
return {"error": "Unexpected error", "details": str(e)}
|
| 92 |
|
| 93 |
|
|
|
|
| 6 |
from dataclasses import dataclass
|
| 7 |
|
| 8 |
from utils.config import API_CONFIG
|
| 9 |
+
from utils.model import MultiModuleRequest, SingleModuleRequest, SearchSpaceRoutingRequest
|
| 10 |
|
| 11 |
@dataclass
|
| 12 |
class DSContext:
|
|
|
|
| 27 |
mcp = FastMCP(name="defect-solver-server", lifespan=ds_lifespan)
|
| 28 |
|
| 29 |
|
| 30 |
+
|
| 31 |
@mcp.tool(
|
| 32 |
+
name="multi_module_bug_localization",
|
| 33 |
description=(
|
| 34 |
"""
|
| 35 |
+
Performs bug localization across the entire Java project by first identifying likely microservices
|
| 36 |
+
(search spaces) and then locating the bug-related files within them.
|
| 37 |
+
|
| 38 |
+
Use this tool when you do not know which microservice is responsible for the bug.
|
| 39 |
+
|
| 40 |
Args:
|
| 41 |
+
request (MultiModuleRequest): Issue key and descriptive details from the bug report.
|
| 42 |
+
ctx (Context): MCP context object.
|
| 43 |
+
|
| 44 |
Returns:
|
| 45 |
+
dict: Includes selected microservices and localized file paths.
|
| 46 |
"""
|
| 47 |
),
|
| 48 |
)
|
| 49 |
+
async def multi_module_bug_localization(request: MultiModuleRequest, ctx: Context) -> dict:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
ds_ctx: DSContext = ctx.request_context.lifespan_context
|
| 51 |
client = ds_ctx.client
|
| 52 |
|
| 53 |
+
api_url = API_CONFIG["api_base_url"] + API_CONFIG["api_multimodule_endpoint"]
|
| 54 |
hf_token = API_CONFIG.get("hf_access_token", None)
|
| 55 |
|
| 56 |
headers = {
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
try:
|
| 62 |
+
logger.info(f"Sending multi-module bug localization request to {api_url} with data: {request.model_dump()}")
|
| 63 |
response = await client.post(
|
| 64 |
api_url,
|
| 65 |
json={
|
|
|
|
| 75 |
logger.info(f"Received response: {response.text}")
|
| 76 |
return response.json()
|
| 77 |
except httpx.HTTPStatusError as e:
|
| 78 |
+
logger.error(f"HTTP error {e.response.status_code} from multimodule bug localization endpoint: {e.response.text}")
|
| 79 |
return {"error": f"HTTP error: {e.response.status_code}", "details": e.response.text}
|
| 80 |
except httpx.RequestError as e:
|
| 81 |
+
logger.error(f"Request error while calling multimodule bug localization endpoint: {e}")
|
| 82 |
return {"error": "Request error", "details": str(e)}
|
| 83 |
except Exception as e:
|
| 84 |
+
logger.exception("Unexpected error during multimodule bug localization request")
|
| 85 |
return {"error": "Unexpected error", "details": str(e)}
|
| 86 |
|
| 87 |
|