Skip to content

Agent Zero AI framework

ignore typecheck in models.py

frdel9c75aea346cb
diff --git a/models.py b/models.py
index 924415c7f..12c36afb4 100644
--- a/models.py
+++ b/models.py
@@ -17,6 +17,7 @@ from typing import (
from litellm import completion, acompletion, embedding
import litellm
import openai
+from litellm.types.utils import ModelResponse
from python.helpers import dotenv
from python.helpers import settings, dirty_json
@@ -620,9 +621,9 @@ class BrowserCompatibleChatWrapper(ChatOpenRouter):
# Gemini: strip triple backticks and conform schema
try:
- msg = resp.choices[0].message
+ msg = resp.choices[0].message # type: ignore
if self.provider == "gemini" and isinstance(getattr(msg, "content", None), str):
- cleaned = browser_use_monkeypatch.gemini_clean_and_conform(msg.content)
+ cleaned = browser_use_monkeypatch.gemini_clean_and_conform(msg.content) # type: ignore
if cleaned:
msg.content = cleaned
except Exception:
diff --git a/webui/js/api.js b/webui/js/api.js
index eeec492b5..2baa1eb9a 100644
--- a/webui/js/api.js
+++ b/webui/js/api.js
@@ -55,6 +55,7 @@ export async function fetchApi(url, request) {
}else if(response.redirected && response.url.endsWith("/login")){
// redirect to login
window.location.href = response.url;
+ return;
}
// return the response
@@ -80,8 +81,14 @@ async function getCsrfToken() {
if (csrfToken) return csrfToken;
const response = await fetch("/csrf_token", {
credentials: "same-origin",
- }).then((r) => r.json());
- csrfToken = response.token;
- document.cookie = `csrf_token_${response.runtime_id}=${csrfToken}; SameSite=Strict; Path=/`;
+ });
+ if (response.redirected && response.url.endsWith("/login")) {
+ // redirect to login
+ window.location.href = response.url;
+ return;
+ }
+ const json = await response.json();
+ csrfToken = json.token;
+ document.cookie = `csrf_token_${json.runtime_id}=${csrfToken}; SameSite=Strict; Path=/`;
return csrfToken;
}