Skip to content

Commit

Permalink
updated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick-Davis-MSFT committed Oct 8, 2024
1 parent 7329c3c commit 9811095
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

/.env
*.env*
.env
# dependencies
/node_modules
/.pnp
Expand Down
12 changes: 9 additions & 3 deletions utils/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) && {
Expand Down

0 comments on commit 9811095

Please sign in to comment.