-
Notifications
You must be signed in to change notification settings - Fork 21
Fix: Follow override image gen service URL #352
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
a8fea6a
d4ed807
5501ca1
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 |
|---|---|---|
|
|
@@ -884,24 +884,37 @@ public function requestImageCreation( | |
| * @return array | ||
| */ | ||
| public function getImageRequestOptions(?string $userId): array { | ||
| $timeout = $this->openAiSettingsService->getRequestTimeout(); | ||
| $requestOptions = [ | ||
| 'timeout' => $timeout, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Timeout should always have some value. When ImageRetrieval isn't authenticated timeout will not be defined.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the last commit. |
||
| 'timeout' => $this->openAiSettingsService->getRequestTimeout(), | ||
| 'headers' => [ | ||
| 'User-Agent' => Application::USER_AGENT, | ||
| ], | ||
| ]; | ||
|
|
||
| if ($this->openAiSettingsService->getIsImageRetrievalAuthenticated()) { | ||
| $useBasicAuth = $this->openAiSettingsService->getUseBasicAuth(); | ||
| if ($useBasicAuth) { | ||
| if ($this->openAiSettingsService->imageOverrideEnabled()) { | ||
| $useBasicAuth = $this->openAiSettingsService->getAdminImageUseBasicAuth(); | ||
|
|
||
| $apiKey = $this->openAiSettingsService->getAdminImageApiKey(); | ||
| $basicUser = $this->openAiSettingsService->getAdminImageBasicUser(); | ||
| $basicPassword = $this->openAiSettingsService->getAdminImageBasicPassword(); | ||
|
|
||
| $requestOptions['timeout'] = $this->openAiSettingsService->getImageRequestTimeout(); | ||
| } else { | ||
| // image service settings are not overridden | ||
| $useBasicAuth = $this->openAiSettingsService->getUseBasicAuth(); | ||
|
|
||
| // this has no equivalent when the service URL is overridden | ||
| // so the user-defined credentials will be ignored | ||
| $apiKey = $this->openAiSettingsService->getUserApiKey($userId, true); | ||
| $basicUser = $this->openAiSettingsService->getUserBasicUser($userId, true); | ||
| $basicPassword = $this->openAiSettingsService->getUserBasicPassword($userId, true); | ||
| } | ||
| if ($useBasicAuth) { | ||
| if ($basicUser !== '' && $basicPassword !== '') { | ||
| $requestOptions['headers']['Authorization'] = 'Basic ' . base64_encode($basicUser . ':' . $basicPassword); | ||
| } | ||
| } else { | ||
| $apiKey = $this->openAiSettingsService->getUserApiKey($userId, true); | ||
| $requestOptions['headers']['Authorization'] = 'Bearer ' . $apiKey; | ||
| } | ||
| } | ||
|
|
@@ -1007,15 +1020,11 @@ public function updateExpImgProcessingTime(int $runtime): void { | |
| * @return array decoded request result or error | ||
| * @throws Exception | ||
| */ | ||
| public function request(?string $userId, string $endPoint, array $params = [], string $method = 'GET', ?string $contentType = null, bool $logErrors = true, ?string $serviceType = null): array { | ||
| public function request( | ||
| ?string $userId, string $endPoint, array $params = [], string $method = 'GET', | ||
| ?string $contentType = null, bool $logErrors = true, ?string $serviceType = null, | ||
| ): array { | ||
| try { | ||
| $serviceUrl = ''; | ||
| $apiKey = ''; | ||
| $basicUser = ''; | ||
| $basicPassword = ''; | ||
| $useBasicAuth = false; | ||
| $timeout = 0; | ||
|
|
||
| if ($serviceType === Application::SERVICE_TYPE_IMAGE && $this->openAiSettingsService->imageOverrideEnabled()) { | ||
| $serviceUrl = $this->openAiSettingsService->getImageServiceUrl(); | ||
| $apiKey = $this->openAiSettingsService->getAdminImageApiKey(); | ||
|
|
||
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.
👍 We should also do this in integration_replicate, I think