mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
feat(auth) normalise the way in which we check whether a user has free/paid access to nous portal so we can expose behaviour and error messages accordingly.
This commit is contained in:
parent
0bf9b867cf
commit
406901b27d
32 changed files with 2470 additions and 181 deletions
18
run_agent.py
18
run_agent.py
|
|
@ -2847,7 +2847,12 @@ class AIAgent:
|
|||
|
||||
return True
|
||||
|
||||
def _try_refresh_nous_client_credentials(self, *, force: bool = True) -> bool:
|
||||
def _try_refresh_nous_client_credentials(
|
||||
self,
|
||||
*,
|
||||
force: bool = True,
|
||||
inference_auth_mode: str | None = None,
|
||||
) -> bool:
|
||||
if self.api_mode != "chat_completions" or self.provider != "nous":
|
||||
return False
|
||||
|
||||
|
|
@ -2858,14 +2863,15 @@ class AIAgent:
|
|||
resolve_nous_runtime_credentials,
|
||||
)
|
||||
|
||||
selected_auth_mode = inference_auth_mode or (
|
||||
NOUS_INFERENCE_AUTH_MODE_LEGACY
|
||||
if force
|
||||
else NOUS_INFERENCE_AUTH_MODE_AUTO
|
||||
)
|
||||
creds = resolve_nous_runtime_credentials(
|
||||
min_key_ttl_seconds=max(60, int(os.getenv("HERMES_NOUS_MIN_KEY_TTL_SECONDS", "1800"))),
|
||||
timeout_seconds=float(os.getenv("HERMES_NOUS_TIMEOUT_SECONDS", "15")),
|
||||
inference_auth_mode=(
|
||||
NOUS_INFERENCE_AUTH_MODE_LEGACY
|
||||
if force
|
||||
else NOUS_INFERENCE_AUTH_MODE_AUTO
|
||||
),
|
||||
inference_auth_mode=selected_auth_mode,
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.debug("Nous credential refresh failed: %s", exc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue