Spaces:
Runtime error
Runtime error
trakshan-mishra commited on
Commit ·
ed862c3
1
Parent(s): 84d68b4
Update inline analysis to support structured lists for ChatGPT Actions compatibility
Browse files
diffcontext-service/backend/main.py
CHANGED
|
@@ -46,9 +46,13 @@ class CompileRequest(BaseModel):
|
|
| 46 |
symbol: str
|
| 47 |
max_tokens: int = 8000
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
class InlineRequest(BaseModel):
|
| 50 |
"""Lets beginners paste code directly without uploading a zip."""
|
| 51 |
-
files:
|
| 52 |
symbol: str # which function to analyze
|
| 53 |
|
| 54 |
class HealthResponse(BaseModel):
|
|
@@ -325,7 +329,11 @@ def analyze_inline(req: InlineRequest):
|
|
| 325 |
"""
|
| 326 |
tmp_dir = tempfile.mkdtemp(prefix="diffctx_inline_")
|
| 327 |
try:
|
| 328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
# Safety: strip any path traversal
|
| 330 |
safe_name = Path(filename).name
|
| 331 |
filepath = os.path.join(tmp_dir, safe_name)
|
|
|
|
| 46 |
symbol: str
|
| 47 |
max_tokens: int = 8000
|
| 48 |
|
| 49 |
+
class FileItem(BaseModel):
|
| 50 |
+
filename: str
|
| 51 |
+
content: str
|
| 52 |
+
|
| 53 |
class InlineRequest(BaseModel):
|
| 54 |
"""Lets beginners paste code directly without uploading a zip."""
|
| 55 |
+
files: List[FileItem] # list of file items to make it compatible with GPT Actions
|
| 56 |
symbol: str # which function to analyze
|
| 57 |
|
| 58 |
class HealthResponse(BaseModel):
|
|
|
|
| 329 |
"""
|
| 330 |
tmp_dir = tempfile.mkdtemp(prefix="diffctx_inline_")
|
| 331 |
try:
|
| 332 |
+
files_dict = {}
|
| 333 |
+
for f in req.files:
|
| 334 |
+
files_dict[f.filename] = f.content
|
| 335 |
+
|
| 336 |
+
for filename, code in files_dict.items():
|
| 337 |
# Safety: strip any path traversal
|
| 338 |
safe_name = Path(filename).name
|
| 339 |
filepath = os.path.join(tmp_dir, safe_name)
|
diffcontext/mcp_server.py
CHANGED
|
@@ -352,7 +352,15 @@ if HAS_MCP:
|
|
| 352 |
symbol = arguments["symbol"]
|
| 353 |
tmp_dir = tempfile.mkdtemp(prefix="diffctx_mcp_")
|
| 354 |
try:
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
safe_name = Path(filename).name
|
| 357 |
with open(os.path.join(tmp_dir, safe_name), "w") as f:
|
| 358 |
f.write(code)
|
|
|
|
| 352 |
symbol = arguments["symbol"]
|
| 353 |
tmp_dir = tempfile.mkdtemp(prefix="diffctx_mcp_")
|
| 354 |
try:
|
| 355 |
+
files_dict = {}
|
| 356 |
+
if isinstance(files, list):
|
| 357 |
+
for f in files:
|
| 358 |
+
if isinstance(f, dict):
|
| 359 |
+
files_dict[f.get("filename")] = f.get("content")
|
| 360 |
+
else:
|
| 361 |
+
files_dict = files
|
| 362 |
+
|
| 363 |
+
for filename, code in files_dict.items():
|
| 364 |
safe_name = Path(filename).name
|
| 365 |
with open(os.path.join(tmp_dir, safe_name), "w") as f:
|
| 366 |
f.write(code)
|