Skip to content

Conversation

@rahuldevikar761
Copy link
Collaborator

@rahuldevikar761 rahuldevikar761 commented Jan 23, 2026

image

- Add openai-config.ts for conditional OpenAI/Azure OpenAI configuration
- Use setDefaultOpenAIClient with AzureOpenAI for Azure endpoints
- Use chat_completions API for Azure OpenAI compatibility
- Update .env.template with Azure OpenAI environment variables
- Dynamic model/deployment name selection based on provider
@rahuldevikar761 rahuldevikar761 requested a review from a team as a code owner January 23, 2026 08:28
Copilot AI review requested due to automatic review settings January 23, 2026 08:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the NodeJS OpenAI sample agent to support using Azure OpenAI deployments (in addition to standard OpenAI) via environment-based configuration.

Changes:

  • Added an OpenAI/Azure OpenAI configuration module and wired it into agent creation (including model/deployment selection).
  • Adjusted environment loading and hosting behavior (production detection, health endpoint, bind host).
  • Expanded the .env.template to document Azure OpenAI settings.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
nodejs/openai/sample-agent/src/openai-config.ts New module to configure @openai/agents for Azure OpenAI vs standard OpenAI based on env vars.
nodejs/openai/sample-agent/src/client.ts Initializes OpenAI/Azure config and passes the selected model/deployment into the Agent.
nodejs/openai/sample-agent/src/agent.ts Loads .env earlier to ensure env vars are available during agent initialization.
nodejs/openai/sample-agent/src/index.ts Updates production/development detection, adds /api/health, and binds server to 0.0.0.0.
nodejs/openai/sample-agent/.env.template Adds Azure OpenAI configuration variables and model selection settings.

- Add 'openai' as direct dependency in package.json
- Check AZURE_OPENAI_DEPLOYMENT in isAzureOpenAI() function
- Throw clear error if AZURE_OPENAI_DEPLOYMENT is missing
- Remove appId from health endpoint to reduce information disclosure
- Remove direct openai dependency (use transitive from @openai/agents)
- Use require() and 'any' type to bypass version compatibility issues
@rahuldevikar761 rahuldevikar761 enabled auto-merge (squash) January 23, 2026 17:47
- Remove isProduction variable, use only isDevelopment
- Auth is required for everything except NODE_ENV=development
- Addresses pontemonti's review comment about ambiguous state
@rahuldevikar761 rahuldevikar761 merged commit 06a4752 into main Jan 23, 2026
8 checks passed
@rahuldevikar761 rahuldevikar761 deleted the users/radevika/fixNodeJSdotenvOrder branch January 23, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants