forked from Laboratoria/DEV015-dataverse-chat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from gabyh7922/dev
creacion de test
- Loading branch information
Showing
11 changed files
with
46 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
export const getApiKey = () => { | ||
// obtener la API KEY desde Local Storage | ||
// Obtener la API KEY desde Local Storage | ||
try { | ||
const api_key = localStorage.getItem('apiKey'); | ||
if (!api_key) { | ||
throw new Error('Api Key not defined!'); | ||
} | ||
return localStorage.getItem('apiKey'); | ||
return api_key; | ||
} catch (error) { | ||
const api_key = prompt("Por favor ingresa una Open AI Key"); | ||
if (api_key.length <= 160) { | ||
|
||
// Validar que la clave tiene la longitud correcta | ||
if (!api_key || api_key.length <= 160) { | ||
alert("Api Key invalida, por favor ingresa una Open AI api key"); | ||
return getApiKey(); | ||
return null; // Detener la recursión si la clave no es válida | ||
} | ||
|
||
setApiKey(api_key); | ||
return null; | ||
return api_key; // Retornar la clave válida | ||
} | ||
}; | ||
|
||
export const setApiKey = (key) => { | ||
//guardar la API KEY en Local Storage | ||
// Guardar la API KEY en Local Storage | ||
try { | ||
localStorage.setItem('apiKey', key); | ||
sessionStorage.setItem('apiKey', key);//permite almacenar datos de forma persistente en el navegador. | ||
} catch (error) { | ||
alert('Error al guardar la API KEY:', error); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.