File tree Expand file tree Collapse file tree
utils/build/docker/python/flask Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2231,13 +2231,22 @@ def external_request_redirect():
22312231@app .route ("/ai_guard/evaluate" , methods = ["POST" ])
22322232def ai_guard_evaluate ():
22332233 """AI Guard evaluation endpoint."""
2234- from ddtrace .internal .settings .asm import ai_guard_config
2234+ # AI Guard was moved from `ddtrace.appsec.ai_guard` to the top-level `ddtrace.aiguard`
2235+ # package (dd-trace-py#18754, #19110). Import the new location first and fall back to
2236+ # the old one to stay compatible with every tracer version under test.
2237+ try :
2238+ from ddtrace .internal .settings .aiguard import aiguard_config
2239+ except ImportError :
2240+ from ddtrace .internal .settings .asm import ai_guard_config as aiguard_config
22352241
2236- if not ai_guard_config ._ai_guard_enabled :
2242+ if not aiguard_config ._ai_guard_enabled :
22372243 return jsonify ({"action" : "ALLOW" , "reason" : "AI Guard not enabled" }), 200
22382244
22392245 try :
2240- from ddtrace .appsec .ai_guard import new_ai_guard_client , Options , AIGuardAbortError
2246+ try :
2247+ from ddtrace .aiguard import new_ai_guard_client , Options , AIGuardAbortError
2248+ except ImportError :
2249+ from ddtrace .appsec .ai_guard import new_ai_guard_client , Options , AIGuardAbortError
22412250 from ddtrace .appsec .track_user_sdk import track_user_id
22422251
22432252 should_block = flask_request .headers .get ("X-AI-Guard-Block" , "false" ).lower () == "true"
You can’t perform that action at this time.
0 commit comments