@@ -121,9 +121,9 @@ def _build_status_frame(label: str, detail: Optional[str] = None, url: Optional[
121121@csrf_exempt
122122def chat_response (request : HttpRequest ) -> JsonResponse :
123123 """
124- Normal Mode: Help user understand the CURRENT website using Playwright navigation .
125- Agent stays within the current domain and navigates to find information .
126- Now uses Unified Context Manager for full conversation history.
124+ Thinking Mode: Process user questions using LLM with available MCP tools .
125+ Note: Browser automation has been removed. For web research, use Research mode .
126+ Uses Unified Context Manager for full conversation history.
127127 """
128128 try :
129129 question = request .GET .get ('question' , '' )
@@ -134,13 +134,7 @@ def chat_response(request: HttpRequest) -> JsonResponse:
134134 if not question :
135135 return JsonResponse ({'error' : 'No question provided' }, status = 400 )
136136
137- # Extract domain from current URL for restriction
138- restricted_domain = None
139- if current_url :
140- parsed = urlparse (current_url )
141- restricted_domain = parsed .netloc
142-
143- logger .info (f"Chat request: question='{ question [:50 ]} ...', domain={ restricted_domain } " )
137+ logger .info (f"Chat request: question='{ question [:50 ]} ...'" )
144138
145139 # Get session ID
146140 session_id = _get_session_id (request )
@@ -173,34 +167,23 @@ def chat_response(request: HttpRequest) -> JsonResponse:
173167 import time
174168 start_time = time .time ()
175169
176- # Use agent with Playwright for domain navigation
170+ # Use agent with MCP tools (SEC-EDGAR, filesystem)
177171 response = ds .create_agent_response (
178172 user_input = question ,
179173 message_list = messages ,
180174 model = model ,
181- use_playwright = True ,
182- restricted_domain = restricted_domain ,
183- current_url = current_url ,
184- auto_fetch_page = True
175+ current_url = current_url
185176 )
186177
187178 responses [model ] = response
188- # Persist Playwright scraped context, if any
189- for entry in ds .get_last_playwright_context () or []:
190- integration .add_playwright_content (
191- session_id = session_id ,
192- content = entry .get ("content" , "" ),
193- url = entry .get ("url" ) or current_url ,
194- action = entry .get ("action" )
195- )
196179
197180 # Add response to context
198181 response_time_ms = int ((time .time () - start_time ) * 1000 )
199182 context_mgr .add_assistant_message (
200183 session_id = session_id ,
201184 content = response ,
202185 model = model ,
203- tools_used = ["playwright" ] if restricted_domain else [ ],
186+ tools_used = [],
204187 response_time_ms = response_time_ms
205188 )
206189
@@ -354,14 +337,14 @@ def adv_response(request: HttpRequest) -> JsonResponse:
354337@csrf_exempt
355338def agent_chat_response (request : HttpRequest ) -> JsonResponse :
356339 """
357- Process chat response via Agent with optional tools (Playwright, etc.)
358- Now uses Unified Context Manager for full conversation history.
340+ Process chat response via Agent with MCP tools (SEC-EDGAR, filesystem).
341+ Note: Browser automation has been removed. For web research, use Research mode.
342+ Uses Unified Context Manager for full conversation history.
359343 """
360344 try :
361345 question = request .GET .get ('question' , '' )
362346 selected_models = request .GET .get ('models' , 'gpt-4o-mini' )
363347 current_url = request .GET .get ('current_url' , '' )
364- use_playwright = request .GET .get ('use_playwright' , 'false' ).lower () == 'true'
365348
366349 if not question :
367350 return JsonResponse ({'error' : 'No question provided' }, status = 400 )
@@ -397,35 +380,23 @@ def agent_chat_response(request: HttpRequest) -> JsonResponse:
397380 import time
398381 start_time = time .time ()
399382
400- # Create agent response
383+ # Create agent response with MCP tools
401384 response = ds .create_agent_response (
402385 user_input = question ,
403386 message_list = messages ,
404387 model = model ,
405- use_playwright = use_playwright ,
406- restricted_domain = None , # No restriction in agent mode
407- current_url = current_url ,
408- auto_fetch_page = True
388+ current_url = current_url
409389 )
410390
411391 responses [model ] = response
412- # Persist Playwright scraped context, if any
413- for entry in ds .get_last_playwright_context () or []:
414- integration .add_playwright_content (
415- session_id = session_id ,
416- content = entry .get ("content" , "" ),
417- url = entry .get ("url" ) or current_url ,
418- action = entry .get ("action" )
419- )
420392
421393 # Add response to context
422394 response_time_ms = int ((time .time () - start_time ) * 1000 )
423- tools_used = ["playwright" ] if use_playwright else []
424395 context_mgr .add_assistant_message (
425396 session_id = session_id ,
426397 content = response ,
427398 model = model ,
428- tools_used = tools_used ,
399+ tools_used = [] ,
429400 response_time_ms = response_time_ms
430401 )
431402
@@ -466,8 +437,8 @@ def agent_chat_response(request: HttpRequest) -> JsonResponse:
466437@csrf_exempt
467438def chat_response_stream (request : HttpRequest ) -> StreamingHttpResponse :
468439 """
469- Normal Mode Streaming: Help user understand the CURRENT website using Playwright navigation .
470- Agent stays within the current domain and navigates to find information .
440+ Thinking Mode Streaming: Process user questions using LLM with available MCP tools .
441+ Note: Browser automation has been removed. For web research, use Research mode .
471442 """
472443 try :
473444 question = request .GET .get ('question' , '' )
@@ -477,12 +448,6 @@ def chat_response_stream(request: HttpRequest) -> StreamingHttpResponse:
477448 if not question :
478449 return JsonResponse ({'error' : 'No question provided' }, status = 400 )
479450
480- # Extract domain
481- restricted_domain = None
482- if current_url :
483- parsed = urlparse (current_url )
484- restricted_domain = parsed .netloc
485-
486451 # Get session ID
487452 session_id = _get_session_id (request )
488453
@@ -515,9 +480,6 @@ def event_stream():
515480 yield b'event: connected\n data: {"status": "connected"}\n \n '
516481 yield _build_status_frame ("Preparing context" )
517482
518- if restricted_domain :
519- yield _build_status_frame ("Navigating site" , restricted_domain )
520-
521483 import time
522484 start_time = time .time ()
523485 aggregated_chunks : List [str ] = []
@@ -526,10 +488,7 @@ def event_stream():
526488 user_input = question ,
527489 message_list = messages ,
528490 model = model ,
529- use_playwright = True ,
530- restricted_domain = restricted_domain ,
531491 current_url = current_url ,
532- auto_fetch_page = True ,
533492 user_timezone = user_timezone ,
534493 user_time = user_time
535494 )
@@ -572,22 +531,13 @@ def event_stream():
572531 if not final_response and aggregated_chunks :
573532 final_response = "" .join (aggregated_chunks )
574533
575- # Persist Playwright scraped context, if any
576- for entry in ds .get_last_playwright_context () or []:
577- integration .add_playwright_content (
578- session_id = session_id ,
579- content = entry .get ("content" , "" ),
580- url = entry .get ("url" ) or current_url ,
581- action = entry .get ("action" )
582- )
583-
584534 # Add to context
585535 response_time_ms = int ((time .time () - start_time ) * 1000 )
586536 context_mgr .add_assistant_message (
587537 session_id = session_id ,
588538 content = final_response ,
589539 model = model ,
590- tools_used = ["playwright" ] if restricted_domain else [ ],
540+ tools_used = [],
591541 response_time_ms = response_time_ms
592542 )
593543
0 commit comments