mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-30 15:59:09 +08:00
fix: refine experimental_transform handling and improve chunking logic
- Updated PluginEnabledAiClient to streamline the handling of experimental_transform parameters. - Adjusted ModernAiProvider's smoothStream configuration for better chunking of text, enhancing processing efficiency. - Re-enabled block updates in messageThunk for improved state management.
This commit is contained in:
parent
02bcf03da9
commit
3d2caaf96a
@ -213,10 +213,13 @@ export class PluginEnabledAiClient<T extends ProviderId = ProviderId> {
|
||||
params!,
|
||||
async (finalModelId, transformedParams, streamTransforms) => {
|
||||
const model = await this.getModelWithMiddlewares(finalModelId)
|
||||
const experimental_transform =
|
||||
params?.experimental_transform ?? (streamTransforms.length > 0 ? streamTransforms : undefined)
|
||||
|
||||
return await streamText({
|
||||
model,
|
||||
...transformedParams,
|
||||
experimental_transform: streamTransforms.length > 0 ? streamTransforms : undefined
|
||||
experimental_transform
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
@ -178,8 +178,9 @@ export default class ModernAiProvider {
|
||||
const streamResult = await clientWithMiddlewares.streamText(modelId, {
|
||||
...params,
|
||||
experimental_transform: smoothStream({
|
||||
delayInMs: 100,
|
||||
chunking: 'word'
|
||||
delayInMs: 80,
|
||||
// 中文3个字符一个chunk,英文一个单词一个chunk
|
||||
chunking: /([\u4E00-\u9FFF]{3})|\S+\s+/
|
||||
})
|
||||
})
|
||||
const finalText = await adapter.processStream(streamResult)
|
||||
|
||||
@ -147,7 +147,7 @@ const getBlockThrottler = (id: string) => {
|
||||
}
|
||||
|
||||
const rafId = requestAnimationFrame(() => {
|
||||
store.dispatch(updateOneBlock({ id, changes: blockUpdate }))
|
||||
// store.dispatch(updateOneBlock({ id, changes: blockUpdate }))
|
||||
blockUpdateRafs.delete(id)
|
||||
})
|
||||
|
||||
@ -166,6 +166,7 @@ const getBlockThrottler = (id: string) => {
|
||||
*/
|
||||
const throttledBlockUpdate = (id: string, blockUpdate: any) => {
|
||||
const throttler = getBlockThrottler(id)
|
||||
store.dispatch(updateOneBlock({ id, changes: blockUpdate }))
|
||||
throttler(blockUpdate)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user