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:
MyPrototypeWhat 2025-09-03 15:50:47 +08:00
parent 4e91db43c9
commit 976d246cac
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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
}