Spaces:
Paused
Paused
Update app/main.py
Browse files- app/main.py +4 -2
app/main.py
CHANGED
|
@@ -1369,8 +1369,10 @@ async def chat_completions(request: OpenAIRequest, api_key: str = Depends(get_ap
|
|
| 1369 |
return JSONResponse(status_code=400, content=error_response)
|
| 1370 |
|
| 1371 |
# --- Handle specific OpenAI client model ---
|
| 1372 |
-
if request.model
|
| 1373 |
print(f"INFO: Using OpenAI library path for model: {request.model}")
|
|
|
|
|
|
|
| 1374 |
|
| 1375 |
# --- Determine Credentials for OpenAI Client (Correct Priority) ---
|
| 1376 |
credentials_to_use = None
|
|
@@ -1459,7 +1461,7 @@ async def chat_completions(request: OpenAIRequest, api_key: str = Depends(get_ap
|
|
| 1459 |
f"https://{LOCATION}-aiplatform.googleapis.com/v1beta1/"
|
| 1460 |
f"projects/{PROJECT_ID}/locations/{LOCATION}/endpoints/openapi"
|
| 1461 |
)
|
| 1462 |
-
UNDERLYING_MODEL_ID
|
| 1463 |
|
| 1464 |
# Initialize Async OpenAI Client
|
| 1465 |
openai_client = openai.AsyncOpenAI(
|
|
|
|
| 1369 |
return JSONResponse(status_code=400, content=error_response)
|
| 1370 |
|
| 1371 |
# --- Handle specific OpenAI client model ---
|
| 1372 |
+
if request.model.endswith("-openai"): # Generalized check for suffix
|
| 1373 |
print(f"INFO: Using OpenAI library path for model: {request.model}")
|
| 1374 |
+
base_model_name = request.model.replace("-openai", "") # Extract base model name
|
| 1375 |
+
UNDERLYING_MODEL_ID = f"google/{base_model_name}" # Add google/ prefix
|
| 1376 |
|
| 1377 |
# --- Determine Credentials for OpenAI Client (Correct Priority) ---
|
| 1378 |
credentials_to_use = None
|
|
|
|
| 1461 |
f"https://{LOCATION}-aiplatform.googleapis.com/v1beta1/"
|
| 1462 |
f"projects/{PROJECT_ID}/locations/{LOCATION}/endpoints/openapi"
|
| 1463 |
)
|
| 1464 |
+
# UNDERLYING_MODEL_ID is now set above based on the request
|
| 1465 |
|
| 1466 |
# Initialize Async OpenAI Client
|
| 1467 |
openai_client = openai.AsyncOpenAI(
|