@@ -44,29 +44,6 @@ def __init__(self, **kwargs: dict):
4444 self .kwargs = kwargs
4545 self .set_mode ()
4646
47- # Store original environment variables
48- self .original_db_conn = os .environ .get ("Text2Sql__Tsql__ConnectionString" )
49- self .original_db_name = os .environ .get ("Text2Sql__Tsql__Database" )
50-
51- def _update_environment (self , injected_parameters : dict = None ):
52- """Update environment variables with injected parameters."""
53- if injected_parameters :
54- if "database_connection_string" in injected_parameters :
55- os .environ ["Text2Sql__Tsql__ConnectionString" ] = injected_parameters [
56- "database_connection_string"
57- ]
58- if "database_name" in injected_parameters :
59- os .environ ["Text2Sql__Tsql__Database" ] = injected_parameters [
60- "database_name"
61- ]
62-
63- def _restore_environment (self ):
64- """Restore original environment variables."""
65- if self .original_db_conn :
66- os .environ ["Text2Sql__Tsql__ConnectionString" ] = self .original_db_conn
67- if self .original_db_name :
68- os .environ ["Text2Sql__Tsql__Database" ] = self .original_db_name
69-
7047 def set_mode (self ):
7148 """Set the mode of the plugin based on the environment variables."""
7249 self .pre_run_query_cache = (
@@ -195,19 +172,12 @@ def process_user_message(
195172 """
196173 logging .info ("Processing question: %s" , user_message )
197174
198- # Update environment with injected parameters
199- self ._update_environment (injected_parameters )
200-
201- try :
202- agent_input = {
203- "user_message" : user_message ,
204- "injected_parameters" : injected_parameters ,
205- }
175+ agent_input = {
176+ "user_message" : user_message ,
177+ "injected_parameters" : injected_parameters ,
178+ }
206179
207- if database_results :
208- agent_input ["database_results" ] = database_results
180+ if database_results :
181+ agent_input ["database_results" ] = database_results
209182
210- return self .agentic_flow .run_stream (task = json .dumps (agent_input ))
211- finally :
212- # Restore original environment
213- self ._restore_environment ()
183+ return self .agentic_flow .run_stream (task = json .dumps (agent_input ))
0 commit comments