@@ -26,6 +26,7 @@ import useSWR from 'swr';
2626import  {  EyeIcon ,  EyeOffIcon ,  RotateCcwIcon  }  from  'lucide-react' ; 
2727
2828import  AIProvidersSettings  from  './AIProvidersSettings' ; 
29+ import  EditTokenModal  from  './EditTokenModal' ; 
2930import  ViewJobsTab  from  './ViewJobsTab' ; 
3031import  {  alignBox  }  from  '@nivo/core' ; 
3132import  { 
@@ -37,6 +38,10 @@ import {
3738export  default  function  TransformerLabSettings ( )  { 
3839  const  [ showPassword ,  setShowPassword ]  =  React . useState ( false ) ; 
3940  const  [ doNotTrack ,  setDoNotTrack ]  =  React . useState ( false ) ; 
41+   const  [ showHuggingfaceEditTokenModal ,  setShowHuggingfaceEditTokenModal ]  = 
42+     React . useState ( false ) ; 
43+   const  [ showWandbEditTokenModal ,  setShowWandbEditTokenModal ]  = 
44+     React . useState ( false ) ; 
4045  const  [ showExperimentalPlugins ,  setShowExperimentalPlugins ]  = 
4146    React . useState ( false ) ; 
4247
@@ -76,6 +81,14 @@ export default function TransformerLabSettings() {
7681  }  =  useAPI ( 'config' ,  [ 'get' ] ,  { 
7782    key : 'HuggingfaceUserAccessToken' , 
7883  } ) ; 
84+   const  { 
85+     data : wandbToken , 
86+     error : wandbTokenError , 
87+     isLoading : wandbTokenIsLoading , 
88+     mutate : wandbTokenMutate , 
89+   }  =  useAPI ( 'config' ,  [ 'get' ] ,  { 
90+     key : 'WANDB_API_KEY' , 
91+   } ) ; 
7992  const  [ showJobsOfType ,  setShowJobsOfType ]  =  React . useState ( 'NONE' ) ; 
8093  const  [ showProvidersPage ,  setShowProvidersPage ]  =  React . useState ( false ) ; 
8194
@@ -150,7 +163,60 @@ export default function TransformerLabSettings() {
150163              Huggingface Credentials:
151164            </ Typography > 
152165            { canLogInToHuggingFace ?. message  ===  'OK'  ? ( 
153-               < Alert  color = "success" > Login to Huggingface Successful</ Alert > 
166+               < div > 
167+                 < div  style = { {  position : 'relative' ,  width : '100%'  } } > 
168+                   < Alert  color = "success"  style = { {  width : '100%' ,  margin : 0  } } > 
169+                     Login to Huggingface Successful
170+                   </ Alert > 
171+                   < p 
172+                     style = { { 
173+                       position : 'absolute' , 
174+                       right : '16px' , 
175+                       top : '50%' , 
176+                       transform : 'translateY(-50%)' , 
177+                       margin : 0 , 
178+                       cursor : 'pointer' , 
179+                       fontSize : '14px' , 
180+                       borderBottom : '1px solid' , 
181+                     } } 
182+                     onClick = { ( )  =>  { 
183+                       setShowHuggingfaceEditTokenModal ( 
184+                         ! showHuggingfaceEditTokenModal , 
185+                       ) ; 
186+                     } } 
187+                   > 
188+                     Edit
189+                   </ p > 
190+                 </ div > 
191+                 < div > 
192+                   { showHuggingfaceEditTokenModal  &&  ( 
193+                     < EditTokenModal 
194+                       open = { showHuggingfaceEditTokenModal } 
195+                       onClose = { ( )  =>  setShowHuggingfaceEditTokenModal ( false ) } 
196+                       name = "Huggingface" 
197+                       token = { hftoken } 
198+                       onSave = { async  ( token )  =>  { 
199+                         await  chatAPI . authenticatedFetch ( 
200+                           chatAPI . Endpoints . Models . HuggingFaceLogout ( ) , 
201+                         ) ; 
202+                         await  chatAPI . authenticatedFetch ( 
203+                           getAPIFullPath ( 'config' ,  [ 'set' ] ,  { 
204+                             key : 'HuggingfaceUserAccessToken' , 
205+                             value : token , 
206+                           } ) , 
207+                         ) ; 
208+                         // Now manually log in to Huggingface 
209+                         await  chatAPI . authenticatedFetch ( 
210+                           chatAPI . Endpoints . Models . HuggingFaceLogin ( ) , 
211+                         ) ; 
212+                         hftokenmutate ( token ) ; 
213+                         canLogInToHuggingFaceMutate ( ) ; 
214+                         setShowHuggingfaceEditTokenModal ( false ) ; 
215+                       } } 
216+                     /> 
217+                   ) } 
218+                 </ div > 
219+               </ div > 
154220            )  : ( 
155221              < > 
156222                < Alert  color = "danger"  sx = { {  mb : 1  } } > 
@@ -217,9 +283,54 @@ export default function TransformerLabSettings() {
217283              </ > 
218284            ) } 
219285            { wandbLoginStatus ?. message  ===  'OK'  ? ( 
220-               < Alert  color = "success" > 
221-                 Login to Weights & Biases Successful
222-               </ Alert > 
286+               < div > 
287+                 < div  style = { {  position : 'relative' ,  width : '100%'  } } > 
288+                   < Alert  color = "success"  style = { {  width : '100%' ,  margin : 0  } } > 
289+                     Login to Weights & Biases Successful
290+                   </ Alert > 
291+                   < p 
292+                     style = { { 
293+                       position : 'absolute' , 
294+                       right : '16px' , 
295+                       top : '50%' , 
296+                       transform : 'translateY(-50%)' , 
297+                       margin : 0 , 
298+                       cursor : 'pointer' , 
299+                       fontSize : '14px' , 
300+                       borderBottom : '1px solid' , 
301+                     } } 
302+                     onClick = { ( )  =>  { 
303+                       setShowWandbEditTokenModal ( ! showWandbEditTokenModal ) ; 
304+                     } } 
305+                   > 
306+                     Edit
307+                   </ p > 
308+                 </ div > 
309+ 
310+                 < div > 
311+                   { showWandbEditTokenModal  &&  ( 
312+                     < EditTokenModal 
313+                       open = { showWandbEditTokenModal } 
314+                       onClose = { ( )  =>  setShowWandbEditTokenModal ( false ) } 
315+                       name = "Weights & Biases" 
316+                       token = { wandbToken  ||  '' } 
317+                       onSave = { async  ( token )  =>  { 
318+                         await  chatAPI . authenticatedFetch ( 
319+                           getAPIFullPath ( 'config' ,  [ 'set' ] ,  { 
320+                             key : 'WANDB_API_KEY' , 
321+                             value : token , 
322+                           } ) , 
323+                         ) ; 
324+                         await  chatAPI . authenticatedFetch ( 
325+                           chatAPI . Endpoints . Models . wandbLogin ( ) , 
326+                         ) ; 
327+                         wandbLoginMutate ( ) ; 
328+                         setShowWandbEditTokenModal ( false ) ; 
329+                       } } 
330+                     /> 
331+                   ) } 
332+                 </ div > 
333+               </ div > 
223334            )  : ( 
224335              < FormControl  sx = { {  maxWidth : '500px' ,  mt : 2  } } > 
225336                < FormLabel > Weights & Biases API Key</ FormLabel > 
0 commit comments