@@ -93,15 +93,19 @@ async def process_body(
93
93
"""Common processing logic for all strategies"""
94
94
try :
95
95
normalized_body = self .normalizer .normalize (body )
96
+ except Exception as e :
97
+ logger .error (f"Pipeline processing error: { e } " )
98
+ return body , None
96
99
97
- headers_dict = {}
98
- for header in headers :
99
- try :
100
- name , value = header .split (":" , 1 )
101
- headers_dict [name .strip ().lower ()] = value .strip ()
102
- except ValueError :
103
- continue
100
+ headers_dict = {}
101
+ for header in headers :
102
+ try :
103
+ name , value = header .split (":" , 1 )
104
+ headers_dict [name .strip ().lower ()] = value .strip ()
105
+ except ValueError :
106
+ continue
104
107
108
+ try :
105
109
result = await self .instance .process_request (
106
110
request = normalized_body ,
107
111
provider = self .provider_name ,
@@ -111,25 +115,33 @@ async def process_body(
111
115
extra_headers = CopilotPipeline ._get_copilot_headers (headers_dict ),
112
116
is_copilot = True ,
113
117
)
118
+ except Exception as e :
119
+ logger .error (f"Pipeline processing error: { e } " )
120
+ return body , None
114
121
115
- if result .context .shortcut_response :
122
+ if result .context .shortcut_response :
123
+ try :
116
124
# Return shortcut response to the user
117
125
body = CopilotPipeline ._create_shortcut_response (
118
126
result , normalized_body .get ("model" , "gpt-4o-mini" )
119
127
)
120
128
logger .info (f"Pipeline created shortcut response: { body } " )
129
+ except Exception as e :
130
+ logger .error (f"Pipeline processing error: { e } " )
131
+ return body , None
121
132
122
- elif result .request :
133
+ elif result .request :
134
+ try :
123
135
# the pipeline did modify the request, return to the user
124
136
# in the original LLM format
125
137
body = self .normalizer .denormalize (result .request )
126
138
# Uncomment the below to debug the request
127
139
# logger.debug(f"Pipeline processed request: {body}")
128
140
129
- return body , result .context
130
- except Exception as e :
131
- logger .error (f"Pipeline processing error: { e } " )
132
- return body , None
141
+ return body , result .context
142
+ except Exception as e :
143
+ logger .error (f"Pipeline processing error: { e } " )
144
+ return body , None
133
145
134
146
135
147
class CopilotFimNormalizer :
0 commit comments