chore: prepare GoodBuddy 0.8.5

This commit is contained in:
lofyer
2026-08-07 10:45:01 +08:00
parent e20cb447af
commit 17e66a3369
54 changed files with 1306 additions and 1640 deletions
+19 -5
View File
@@ -1,19 +1,33 @@
export function createOpenAIApiBaseUrl(baseUrl: string): string {
const url = new URL(baseUrl)
url.pathname = url.pathname.replace(/\/+$/u, '')
url.search = ''
url.hash = ''
return url.toString().replace(/\/$/u, '')
const normalized = url.toString()
return url.pathname === '/'
? normalized.replace(/\/(?=[?#]|$)/u, '')
: normalized
}
/**
* Appends an API path while preserving any query the base URL carries, which
* gateways such as Azure OpenAI require. Child runtimes cannot forward a query
* through their own base URL, so they keep using createOpenAIApiBaseUrl.
*/
function createOpenAIRequestUrl(baseUrl: string, path: string): URL {
const url = new URL(baseUrl)
url.pathname = `${url.pathname.replace(/\/+$/u, '')}${path}`
url.hash = ''
return url
}
export function createOpenAIChatCompletionsUrl(baseUrl: string): URL {
return new URL(`${createOpenAIApiBaseUrl(baseUrl)}/chat/completions`)
return createOpenAIRequestUrl(baseUrl, '/chat/completions')
}
export function createOpenAIResponsesUrl(baseUrl: string): URL {
return new URL(`${createOpenAIApiBaseUrl(baseUrl)}/responses`)
return createOpenAIRequestUrl(baseUrl, '/responses')
}
export function createOpenAIImagesGenerationsUrl(baseUrl: string): URL {
return new URL(`${createOpenAIApiBaseUrl(baseUrl)}/images/generations`)
return createOpenAIRequestUrl(baseUrl, '/images/generations')
}