Skip to content

Conversation

@imwithye
Copy link
Member

Allow change openai base url to a custom endpoint.

Copilot AI review requested due to automatic review settings December 10, 2025 11:36
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

This PR adds support for configuring a custom OpenAI base URL, enabling users to connect to OpenAI-compatible endpoints (such as Azure OpenAI, local proxies, or other API-compatible services) instead of being limited to the default OpenAI API endpoint.

Key changes:

  • Added OPENAI_BASE_URL environment variable configuration with a sensible default
  • Updated the OpenAI client initialization to use the configured base URL
  • Extended Helm chart deployment configuration to support the new setting

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/libs/cfg/cfg.go Added OpenAIBaseURL field to config struct and openAIBaseURL() helper function that reads from env var with default fallback
internal/services/toolkit/client/client.go Updated OpenAI client initialization to use the configured base URL via option.WithBaseURL()
helm-chart/values.yaml Added openai_base_url value with default OpenAI endpoint
helm-chart/templates/paperdebugger.yaml Added OPENAI_BASE_URL environment variable to ConfigMap for Kubernetes deployment

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +33 to +39
func openAIBaseURL() string {
val := os.Getenv("OPENAI_BASE_URL")
if val != "" {
return val
}
return "https://api.openai.com/v1"
}
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The new OpenAIBaseURL field and openAIBaseURL() helper function lack test coverage. The existing test file cfg_test.go validates other configuration fields (MongoURI, JwtSigningKey, OpenAIAPIKey) but doesn't include assertions for the new OpenAIBaseURL field.

Consider adding test coverage similar to the existing assertions:

assert.NotNil(t, cfg.OpenAIBaseURL)
assert.NotEmpty(t, cfg.OpenAIBaseURL)

Additionally, consider testing both the default value and custom value scenarios for the openAIBaseURL() function to ensure it correctly falls back to the default when the environment variable is not set.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +39
func openAIBaseURL() string {
val := os.Getenv("OPENAI_BASE_URL")
if val != "" {
return val
}
return "https://api.openai.com/v1"
}
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The openAIBaseURL() function doesn't trim whitespace from the environment variable value. If a user accidentally includes leading/trailing whitespace in the OPENAI_BASE_URL environment variable, it could cause API connection issues.

Consider applying strings.TrimSpace() to the value before returning it, consistent with how other URL values might be handled:

func openAIBaseURL() string {
	val := os.Getenv("OPENAI_BASE_URL")
	if val != "" {
		return strings.TrimSpace(val)
	}
	return "https://api.openai.com/v1"
}

Note: You'll need to import "strings" if not already imported.

Copilot uses AI. Check for mistakes.
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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@imwithye imwithye requested a review from Copilot December 10, 2025 12:04
@imwithye imwithye merged commit 2b3086c into main Dec 10, 2025
5 checks passed
@imwithye imwithye deleted the feat-custom-backend branch December 10, 2025 12:05
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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