mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 01:40:15 +01:00
🔧 fix: URL params, package mismatch, typing, shared link redirect, and o1 (azure) (#4899)
* fix: double decoding of URL params * fix: prevent streaming options for O1 model (azure) * fix: update @langchain/openai to version 0.3.14 in package-lock.json * chore(AuthContext): typing * chore(useTimeout): typing * fix: shared link redirecting to login when code block includes "Run Code" button * fix: typing
This commit is contained in:
parent
85d92c2353
commit
2875380bf1
8 changed files with 41 additions and 22 deletions
|
|
@ -21,7 +21,12 @@ const RunCode: React.FC<CodeBarProps> = React.memo(({ lang, codeRef, blockIndex
|
|||
|
||||
const { messageId, conversationId, partIndex } = useMessageContext();
|
||||
const normalizedLang = useMemo(() => normalizeLanguage(lang), [lang]);
|
||||
const { data } = useVerifyAgentToolAuth({ toolId: Tools.execute_code });
|
||||
const { data } = useVerifyAgentToolAuth(
|
||||
{ toolId: Tools.execute_code },
|
||||
{
|
||||
retry: 1,
|
||||
},
|
||||
);
|
||||
const authType = useMemo(() => data?.message ?? false, [data?.message]);
|
||||
const isAuthenticated = useMemo(() => data?.authenticated ?? false, [data?.authenticated]);
|
||||
const { methods, onSubmit, isDialogOpen, setIsDialogOpen, handleRevokeApiKey } =
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const AuthContextProvider = ({
|
|||
//@ts-ignore - ok for token to be undefined initially
|
||||
setTokenHeader(token);
|
||||
setIsAuthenticated(isAuthenticated);
|
||||
if (redirect) {
|
||||
if (redirect != null && redirect) {
|
||||
navigate(redirect, { replace: true });
|
||||
}
|
||||
},
|
||||
|
|
@ -83,7 +83,7 @@ const AuthContextProvider = ({
|
|||
});
|
||||
|
||||
const logout = useCallback(() => logoutUser.mutate(undefined), [logoutUser]);
|
||||
const userQuery = useGetUserQuery({ enabled: !!token });
|
||||
const userQuery = useGetUserQuery({ enabled: !!(token ?? '') });
|
||||
const refreshToken = useRefreshTokenMutation();
|
||||
|
||||
const login = (data: TLoginUser) => {
|
||||
|
|
@ -102,18 +102,18 @@ const AuthContextProvider = ({
|
|||
};
|
||||
|
||||
const silentRefresh = useCallback(() => {
|
||||
if (authConfig?.test) {
|
||||
if (authConfig?.test === true) {
|
||||
console.log('Test mode. Skipping silent refresh.');
|
||||
return;
|
||||
}
|
||||
refreshToken.mutate(undefined, {
|
||||
onSuccess: (data: TLoginResponse) => {
|
||||
const { user, token } = data;
|
||||
onSuccess: (data: TLoginResponse | undefined) => {
|
||||
const { user, token = '' } = data ?? {};
|
||||
if (token) {
|
||||
setUserContext({ token, isAuthenticated: true, user });
|
||||
} else {
|
||||
console.log('Token is not present. User is not authenticated.');
|
||||
if (authConfig?.test) {
|
||||
if (authConfig?.test === true) {
|
||||
return;
|
||||
}
|
||||
navigate('/login');
|
||||
|
|
@ -121,7 +121,7 @@ const AuthContextProvider = ({
|
|||
},
|
||||
onError: (error) => {
|
||||
console.log('refreshToken mutation error:', error);
|
||||
if (authConfig?.test) {
|
||||
if (authConfig?.test === true) {
|
||||
return;
|
||||
}
|
||||
navigate('/login');
|
||||
|
|
@ -136,10 +136,10 @@ const AuthContextProvider = ({
|
|||
doSetError((userQuery.error as Error).message);
|
||||
navigate('/login', { replace: true });
|
||||
}
|
||||
if (error && isAuthenticated) {
|
||||
if (error != null && error && isAuthenticated) {
|
||||
doSetError(undefined);
|
||||
}
|
||||
if (!token || !isAuthenticated) {
|
||||
if (token == null || !token || !isAuthenticated) {
|
||||
silentRefresh();
|
||||
}
|
||||
}, [
|
||||
|
|
@ -149,7 +149,9 @@ const AuthContextProvider = ({
|
|||
userQuery.isError,
|
||||
userQuery.error,
|
||||
error,
|
||||
setUser,
|
||||
navigate,
|
||||
silentRefresh,
|
||||
setUserContext,
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,11 @@ export default function useQueryParams({
|
|||
const maxAttempts = 50; // 5 seconds maximum (50 * 100ms)
|
||||
|
||||
useEffect(() => {
|
||||
const promptParam = searchParams.get('prompt');
|
||||
if (!promptParam) {
|
||||
const decodedPrompt = searchParams.get('prompt') ?? '';
|
||||
if (!decodedPrompt) {
|
||||
return;
|
||||
}
|
||||
|
||||
const decodedPrompt = decodeURIComponent(promptParam);
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
// If already processed or max attempts reached, clear interval and stop
|
||||
if (processedRef.current || attemptsRef.current >= maxAttempts) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function useTimeout({ callback, delay = 400 }: TUseTimeoutParams) {
|
|||
}
|
||||
|
||||
// Set new timeout
|
||||
if (value) {
|
||||
if (value != null && value) {
|
||||
console.log(value);
|
||||
timeout.current = setTimeout(() => {
|
||||
callback(value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue