@@ -275,6 +275,13 @@ def __init__(
275
275
self .secret_manager = secret_manager
276
276
self .is_fim = is_fim
277
277
self .context = PipelineContext ()
278
+
279
+ # we create the sesitive context here so that it is not shared between individual requests
280
+ # TODO: could we get away with just generating the session ID for an instance?
281
+ self .context .sensitive = PipelineSensitiveData (
282
+ manager = self .secret_manager ,
283
+ session_id = str (uuid .uuid4 ()),
284
+ )
278
285
self .context .metadata ["is_fim" ] = is_fim
279
286
280
287
async def process_request (
@@ -288,17 +295,14 @@ async def process_request(
288
295
is_copilot : bool = False ,
289
296
) -> PipelineResult :
290
297
"""Process a request through all pipeline steps"""
291
- self .context .sensitive = PipelineSensitiveData (
292
- manager = self .secret_manager ,
293
- session_id = str (uuid .uuid4 ()),
294
- api_key = api_key ,
295
- model = model ,
296
- provider = provider ,
297
- api_base = api_base ,
298
- )
299
298
self .context .metadata ["extra_headers" ] = extra_headers
300
299
current_request = request
301
300
301
+ self .context .sensitive .api_key = api_key
302
+ self .context .sensitive .model = model
303
+ self .context .sensitive .provider = provider
304
+ self .context .sensitive .api_base = api_base
305
+
302
306
# For Copilot provider=openai. Use a flag to not clash with other places that may use that.
303
307
provider_db = "copilot" if is_copilot else provider
304
308
0 commit comments