Spaces:
Running
Running
Commit
·
63eb410
1
Parent(s):
47a4968
fixed auto retry for fake streaming
Browse files- app/api_helpers.py +6 -1
- app/vertex_ai_init.py +1 -1
app/api_helpers.py
CHANGED
@@ -133,8 +133,13 @@ async def fake_stream_generator(client_instance, model_name: str, prompt: Union[
|
|
133 |
err_msg = f"Error in fake_stream_generator: {str(e)}"
|
134 |
print(err_msg)
|
135 |
err_resp = create_openai_error_response(500, err_msg, "server_error")
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
yield "data: [DONE]\n\n"
|
|
|
138 |
return fake_stream_inner()
|
139 |
|
140 |
async def execute_gemini_call(
|
|
|
133 |
err_msg = f"Error in fake_stream_generator: {str(e)}"
|
134 |
print(err_msg)
|
135 |
err_resp = create_openai_error_response(500, err_msg, "server_error")
|
136 |
+
# It's good practice to log the JSON payload here too for consistency,
|
137 |
+
# though the main concern was the true streaming path.
|
138 |
+
json_payload_for_fake_stream_error = json.dumps(err_resp)
|
139 |
+
print(f"DEBUG: Yielding error JSON payload during fake streaming: {json_payload_for_fake_stream_error}")
|
140 |
+
yield f"data: {json_payload_for_fake_stream_error}\n\n"
|
141 |
yield "data: [DONE]\n\n"
|
142 |
+
raise # Re-raise the exception to allow auto-mode retries
|
143 |
return fake_stream_inner()
|
144 |
|
145 |
async def execute_gemini_call(
|
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:
|