Spaces:
Running
Running
Commit
·
a69a36e
1
Parent(s):
2b87009
fixed new locatin server
Browse files- app/routes/chat_api.py +3 -3
- app/vertex_ai_init.py +1 -1
app/routes/chat_api.py
CHANGED
@@ -108,7 +108,7 @@ async def chat_completions(fastapi_request: Request, request: OpenAIRequest, api
|
|
108 |
rotated_credentials, rotated_project_id = credential_manager_instance.get_random_credentials()
|
109 |
if rotated_credentials and rotated_project_id:
|
110 |
try:
|
111 |
-
client_to_use = genai.Client(vertexai=True, credentials=rotated_credentials, project=rotated_project_id, location="
|
112 |
print(f"INFO: Using rotated credential for project: {rotated_project_id}")
|
113 |
except Exception as e:
|
114 |
print(f"ERROR: Rotated credential client init failed: {e}. Falling back.")
|
@@ -138,9 +138,9 @@ async def chat_completions(fastapi_request: Request, request: OpenAIRequest, api
|
|
138 |
return JSONResponse(status_code=500, content=create_openai_error_response(500, error_msg, "server_error"))
|
139 |
|
140 |
PROJECT_ID = rotated_project_id
|
141 |
-
LOCATION = "
|
142 |
VERTEX_AI_OPENAI_ENDPOINT_URL = (
|
143 |
-
f"https://
|
144 |
f"projects/{PROJECT_ID}/locations/{LOCATION}/endpoints/openapi"
|
145 |
)
|
146 |
# base_model_name is already extracted (e.g., "gemini-1.5-pro-exp-v1")
|
|
|
108 |
rotated_credentials, rotated_project_id = credential_manager_instance.get_random_credentials()
|
109 |
if rotated_credentials and rotated_project_id:
|
110 |
try:
|
111 |
+
client_to_use = genai.Client(vertexai=True, credentials=rotated_credentials, project=rotated_project_id, location="global")
|
112 |
print(f"INFO: Using rotated credential for project: {rotated_project_id}")
|
113 |
except Exception as e:
|
114 |
print(f"ERROR: Rotated credential client init failed: {e}. Falling back.")
|
|
|
138 |
return JSONResponse(status_code=500, content=create_openai_error_response(500, error_msg, "server_error"))
|
139 |
|
140 |
PROJECT_ID = rotated_project_id
|
141 |
+
LOCATION = "global" # Fixed as per user confirmation
|
142 |
VERTEX_AI_OPENAI_ENDPOINT_URL = (
|
143 |
+
f"https://aiplatform.googleapis.com/v1beta1/"
|
144 |
f"projects/{PROJECT_ID}/locations/{LOCATION}/endpoints/openapi"
|
145 |
)
|
146 |
# base_model_name is already extracted (e.g., "gemini-1.5-pro-exp-v1")
|
app/vertex_ai_init.py
CHANGED
@@ -85,7 +85,7 @@ async def init_vertex_ai(credential_manager_instance: CredentialManager) -> bool
|
|
85 |
temp_creds_val, temp_project_id_val = credential_manager_instance.get_random_credentials()
|
86 |
if temp_creds_val and temp_project_id_val:
|
87 |
try:
|
88 |
-
_ = genai.Client(vertexai=True, credentials=temp_creds_val, project=temp_project_id_val, location="
|
89 |
print(f"INFO: Successfully validated a credential from Credential Manager (Project: {temp_project_id_val}). Initialization check passed.")
|
90 |
return True
|
91 |
except Exception as e_val:
|
|
|
85 |
temp_creds_val, temp_project_id_val = credential_manager_instance.get_random_credentials()
|
86 |
if temp_creds_val and temp_project_id_val:
|
87 |
try:
|
88 |
+
_ = genai.Client(vertexai=True, credentials=temp_creds_val, project=temp_project_id_val, location="global")
|
89 |
print(f"INFO: Successfully validated a credential from Credential Manager (Project: {temp_project_id_val}). Initialization check passed.")
|
90 |
return True
|
91 |
except Exception as e_val:
|