Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit ddc0723

Browse files
committed
Fix up headers into dictionary
1 parent 57dbfb1 commit ddc0723

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/codegate/providers/copilot/pipeline.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,23 @@ async def process_body(self, headers: list[str], body: bytes) -> bytes:
5959
try:
6060
normalized_body = self.normalizer.normalize(body)
6161

62+
headers_dict = {}
63+
for header in headers:
64+
try:
65+
name, value = header.split(":", 1)
66+
headers_dict[name.strip().lower()] = value.strip()
67+
except ValueError:
68+
continue
69+
6270
pipeline = self.create_pipeline()
6371
result = await pipeline.process_request(
6472
request=normalized_body,
6573
provider=self.provider_name,
6674
prompt_id=self._request_id(headers),
6775
model=normalized_body.get("model", "gpt-4o-mini"),
68-
api_key = headers.get('authorization','').replace('Bearer ', ''),
69-
api_base = "https://" + headers.get('host', ''),
70-
extra_headers=CopilotPipeline._get_copilot_headers(headers)
76+
api_key = headers_dict.get('authorization','').replace('Bearer ', ''),
77+
api_base = "https://" + headers_dict.get('host', ''),
78+
extra_headers=CopilotPipeline._get_copilot_headers(headers_dict)
7179
)
7280

7381
if result.request:

0 commit comments

Comments
 (0)