hashan-7 commited on
Commit
7a2aa0e
·
verified ·
1 Parent(s): 51bf1cd

Debug code

Browse files
Files changed (1) hide show
  1. scope_router.py +19 -0
scope_router.py CHANGED
@@ -312,7 +312,21 @@ def is_restricted_request(request: CodeXRequest) -> bool:
312
 
313
 
314
  def decide_scope(request: CodeXRequest) -> ScopeDecision:
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  if is_restricted_request(request):
 
316
  return ScopeDecision(
317
  route=ScopeRoute.RESTRICTED,
318
  message="Code X cannot help with harmful, abusive, or clearly unsafe coding requests.",
@@ -320,6 +334,7 @@ def decide_scope(request: CodeXRequest) -> ScopeDecision:
320
  )
321
 
322
  if is_image_request(request):
 
323
  return ScopeDecision(
324
  route=ScopeRoute.IMAGE,
325
  message="Code X is focused on coding tasks. Image generation, image editing, and picture analysis should be handled by the image workflow instead.",
@@ -327,6 +342,7 @@ def decide_scope(request: CodeXRequest) -> ScopeDecision:
327
  )
328
 
329
  if is_greeting_request(request):
 
330
  return ScopeDecision(
331
  route=ScopeRoute.GREETING,
332
  message="Hello. Code X is ready for coding tasks. Send code, an error, or a software request and I will help.",
@@ -334,6 +350,7 @@ def decide_scope(request: CodeXRequest) -> ScopeDecision:
334
  )
335
 
336
  if is_non_code_request(request):
 
337
  return ScopeDecision(
338
  route=ScopeRoute.NON_CODE,
339
  message="Code X is focused on software and coding tasks. This request looks outside Code X scope, so it should go to the normal chat assistant.",
@@ -341,12 +358,14 @@ def decide_scope(request: CodeXRequest) -> ScopeDecision:
341
  )
342
 
343
  if is_code_related_request(request):
 
344
  return ScopeDecision(
345
  route=ScopeRoute.CODE,
346
  message="Code-related request detected.",
347
  should_continue_to_codex=True,
348
  )
349
 
 
350
  return ScopeDecision(
351
  route=ScopeRoute.UNKNOWN,
352
  message="This request is not clearly a coding task. Send code, an error, or a software development request for Code X.",
 
312
 
313
 
314
  def decide_scope(request: CodeXRequest) -> ScopeDecision:
315
+ print("=" * 80, flush=True)
316
+ print("DEBUG scope_router.decide_scope()", flush=True)
317
+ print(f"DEBUG raw session_id: {request.session_id!r}", flush=True)
318
+ print(f"DEBUG raw message: {request.message!r}", flush=True)
319
+ print(f"DEBUG raw previous_context: {request.previous_context!r}", flush=True)
320
+ print(f"DEBUG normalized message: {normalize_text(request.message)!r}", flush=True)
321
+ print(f"DEBUG is_follow_up_code_request: {is_follow_up_code_request(request)}", flush=True)
322
+ print(f"DEBUG is_code_related_request: {is_code_related_request(request)}", flush=True)
323
+ print(f"DEBUG is_greeting_request: {is_greeting_request(request)}", flush=True)
324
+ print(f"DEBUG is_image_request: {is_image_request(request)}", flush=True)
325
+ print(f"DEBUG is_non_code_request: {is_non_code_request(request)}", flush=True)
326
+ print(f"DEBUG is_restricted_request: {is_restricted_request(request)}", flush=True)
327
+
328
  if is_restricted_request(request):
329
+ print("DEBUG final scope route: RESTRICTED", flush=True)
330
  return ScopeDecision(
331
  route=ScopeRoute.RESTRICTED,
332
  message="Code X cannot help with harmful, abusive, or clearly unsafe coding requests.",
 
334
  )
335
 
336
  if is_image_request(request):
337
+ print("DEBUG final scope route: IMAGE", flush=True)
338
  return ScopeDecision(
339
  route=ScopeRoute.IMAGE,
340
  message="Code X is focused on coding tasks. Image generation, image editing, and picture analysis should be handled by the image workflow instead.",
 
342
  )
343
 
344
  if is_greeting_request(request):
345
+ print("DEBUG final scope route: GREETING", flush=True)
346
  return ScopeDecision(
347
  route=ScopeRoute.GREETING,
348
  message="Hello. Code X is ready for coding tasks. Send code, an error, or a software request and I will help.",
 
350
  )
351
 
352
  if is_non_code_request(request):
353
+ print("DEBUG final scope route: NON_CODE", flush=True)
354
  return ScopeDecision(
355
  route=ScopeRoute.NON_CODE,
356
  message="Code X is focused on software and coding tasks. This request looks outside Code X scope, so it should go to the normal chat assistant.",
 
358
  )
359
 
360
  if is_code_related_request(request):
361
+ print("DEBUG final scope route: CODE", flush=True)
362
  return ScopeDecision(
363
  route=ScopeRoute.CODE,
364
  message="Code-related request detected.",
365
  should_continue_to_codex=True,
366
  )
367
 
368
+ print("DEBUG final scope route: UNKNOWN", flush=True)
369
  return ScopeDecision(
370
  route=ScopeRoute.UNKNOWN,
371
  message="This request is not clearly a coding task. Send code, an error, or a software development request for Code X.",