-
Notifications
You must be signed in to change notification settings - Fork 67
feat: add support for custom openai base url #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |
| ) | ||
|
|
||
| type Cfg struct { | ||
| OpenAIBaseURL string | ||
| OpenAIAPIKey string | ||
| JwtSigningKey string | ||
|
|
||
|
|
@@ -19,6 +20,7 @@ var cfg *Cfg | |
| func GetCfg() *Cfg { | ||
| _ = godotenv.Load() | ||
| cfg = &Cfg{ | ||
| OpenAIBaseURL: openAIBaseURL(), | ||
| OpenAIAPIKey: os.Getenv("OPENAI_API_KEY"), | ||
| JwtSigningKey: os.Getenv("JWT_SIGNING_KEY"), | ||
| MongoURI: mongoURI(), | ||
|
|
@@ -28,6 +30,14 @@ func GetCfg() *Cfg { | |
| return cfg | ||
| } | ||
|
|
||
| func openAIBaseURL() string { | ||
| val := os.Getenv("OPENAI_BASE_URL") | ||
| if val != "" { | ||
| return val | ||
| } | ||
| return "https://api.openai.com/v1" | ||
| } | ||
|
Comment on lines
+33
to
+39
|
||
|
|
||
| func xtraMCPURI() string { | ||
| val := os.Getenv("XTRAMCP_URI") | ||
| if val != "" { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
OpenAIBaseURLfield andopenAIBaseURL()helper function lack test coverage. The existing test filecfg_test.govalidates 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:
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.