Skip to content

Commit 6598200

Browse files
Apply suggestions from code review
Co-authored-by: Jordan Stephens <jordan@stephens.io>
1 parent dcf908e commit 6598200

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/api/routers/vertex.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ async def handle_proxy(request: Request, path: str):
151151
if "model" in content_json:
152152
content_json["model"]= get_chat_completion_model_name(model)
153153

154-
needs_conversion = False
154+
conversion_target = None
155155
if not model in known_chat_models:
156-
needs_conversion = True
157156
# openai messages to vertex contents
158157
if "anthropic" in model:
159158
content_json = to_vertex_anthropic(content_json)
159+
conversion_target = "anthropic"
160160

161161
# Build safe target URL
162162
target_url, headers = get_header(model, request, path)
@@ -171,10 +171,9 @@ async def handle_proxy(request: Request, path: str):
171171
)
172172

173173
content = response.content
174-
if needs_conversion:
174+
if conversion_target == "anthropic":
175175
# convert vertex response to openai format
176-
if "anthropic" in model:
177-
content = from_anthropic_to_openai_response(response.content, model_alias)
176+
content = from_anthropic_to_openai_response(response.content, model_alias)
178177

179178
except httpx.RequestError as e:
180179
logging.error(f"Proxy request failed: {e}")

0 commit comments

Comments
 (0)