diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..46be9bedb8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node +{ + "name": "Node.js & TypeScript", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm", + "features": { + "ghcr.io/devcontainers/features/azure-cli:1": {}, + "ghcr.io/devcontainers-contrib/features/npm-package:1": {}, + "ghcr.io/rchaganti/vsc-devcontainer-features/azurebicep:1": {} + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitignore b/.gitignore index d8ebacd6a6..8d61224621 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - +/.env +*.env* +.env # dependencies /node_modules /.pnp diff --git a/utils/server/index.ts b/utils/server/index.ts index bf299528b8..b687ab4c59 100644 --- a/utils/server/index.ts +++ b/utils/server/index.ts @@ -44,8 +44,14 @@ export const OpenAIStream = async ( //let token = getCache("cachedToken"); //console.log("auth token:",token); //let token = process.env.AUTH_TOKEN ? JSON.parse(process.env.AUTH_TOKEN) : ''; - let token = await getAuthToken(); - console.log("auth token:",token); + let token = null; + try{ + token = await getAuthToken(); + console.log("auth token:",token); + } + catch(e){ + console.log("Error getting token: ", e); + } const header = { 'Content-Type': 'application/json', @@ -55,7 +61,7 @@ export const OpenAIStream = async ( ...(OPENAI_API_TYPE === 'azure' && process.env.AZURE_USE_MANAGED_IDENTITY=="false" && { 'api-key': `${key ? key : process.env.OPENAI_API_KEY}` }), - ...(OPENAI_API_TYPE === 'azure' && process.env.AZURE_USE_MANAGED_IDENTITY=="true" && { + ...(OPENAI_API_TYPE === 'azure' && process.env.AZURE_USE_MANAGED_IDENTITY=="true" && token?.token && { Authorization: `Bearer ${token.token}` }), ...((OPENAI_API_TYPE === 'openai' && OPENAI_ORGANIZATION) && {