mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 21:01:32 +08:00
feat: enhance provider configuration and stream text parameters
- Added maxRetries option to buildStreamTextParams for improved error handling. - Implemented custom fetch logic for 'cherryin' provider to include signature generation in requests.
This commit is contained in:
parent
4e91db43c9
commit
976d246cac
@ -98,7 +98,8 @@ export async function buildStreamTextParams(
|
||||
headers: options.requestOptions?.headers,
|
||||
providerOptions,
|
||||
tools,
|
||||
stopWhen: stepCountIs(10)
|
||||
stopWhen: stepCountIs(10),
|
||||
maxRetries: 0
|
||||
}
|
||||
if (assistant.prompt) {
|
||||
params.system = assistant.prompt
|
||||
|
||||
@ -237,5 +237,23 @@ export async function prepareSpecialProviderConfig(
|
||||
const { token } = await window.api.copilot.getToken(defaultHeaders)
|
||||
config.options.apiKey = token
|
||||
}
|
||||
if (provider.id === 'cherryin') {
|
||||
config.options.fetch = async (url, options) => {
|
||||
// 在这里对最终参数进行签名
|
||||
const signature = await window.api.cherryin.generateSignature({
|
||||
method: 'POST',
|
||||
path: '/chat/completions',
|
||||
query: '',
|
||||
body: JSON.parse(options.body)
|
||||
})
|
||||
return fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers,
|
||||
...signature
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user