-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.py
More file actions
33 lines (25 loc) · 997 Bytes
/
Copy pathcontext.py
File metadata and controls
33 lines (25 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from dataclasses import dataclass
@dataclass
class RequestContext:
"""Accumulates state across the forward_request pipeline stages."""
# Set at creation from the incoming request
method: str
path: str
query: str
headers: dict
body: bytes
content_type: str
# Routing / upstream target — initialised with global defaults, then
# overwritten by _sanitize_and_route if the payload carries a model field.
per_request_upstream_url: str = ""
per_request_upstream_api_key: str | None = None
# Set during _sanitize_and_route
resolved_model: str | None = None
is_direct: bool = False
# Set after routing: body that will actually be sent to the upstream
send_content: bytes | None = None
# Set during _maybe_convert_protocol
need_protocol_conv: bool = False
pre_conv_content: bytes | None = None # send_content before Anthropic→OpenAI conversion
# Set during _build_target_url
target_url: str | None = None