mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-07 01:56:53 +00:00
feat: add DeepChat deeplink support (#4668)
This commit is contained in:
+19
@@ -66,6 +66,15 @@ export function detectChatLinkType(url: string): ChatLinkType {
|
||||
return 'custom-protocol'
|
||||
}
|
||||
|
||||
export function chatLinkRequiresApiKey(url: string): boolean {
|
||||
return (
|
||||
url.includes('{key}') ||
|
||||
url.includes('{cherryConfig}') ||
|
||||
url.includes('{aionuiConfig}') ||
|
||||
url.includes('{deepchatConfig}')
|
||||
)
|
||||
}
|
||||
|
||||
export function parseChatConfig(raw: RawChatConfig): ChatPreset[] {
|
||||
let parsed: unknown = raw
|
||||
|
||||
@@ -146,6 +155,16 @@ export function resolveChatUrl({
|
||||
return replaceToken(url, '{aionuiConfig}', encoded)
|
||||
}
|
||||
|
||||
if (url.includes('{deepchatConfig}')) {
|
||||
const payload = {
|
||||
id: 'new-api',
|
||||
baseUrl: safeServerAddress,
|
||||
apiKey: safeApiKey,
|
||||
}
|
||||
const encoded = encodeURIComponent(toBase64(JSON.stringify(payload)))
|
||||
return replaceToken(url, '{deepchatConfig}', encoded)
|
||||
}
|
||||
|
||||
if (safeServerAddress) {
|
||||
const encodedAddress = encodeURIComponent(safeServerAddress)
|
||||
url = replaceToken(url, '{address}', encodedAddress)
|
||||
|
||||
Reference in New Issue
Block a user