Description
Hello,
I'm trying to use the responseCallback from the module
await LLMModule.load({
modelSource: getFilePath(modelURI),
tokenizerSource: getFilePath(tokenizerURI),
tokenizerConfigSource: getFilePath(tokenizerConfigURI),
responseCallback: (token: string) => {
console.log('token ***', token);
console.log('*******')
if (!didCancel && internalIsGenerating ) {
onTokenReceived(token);
}
},
});
This is what i have and the log im getting is as such
{...}
LOG *******
LOG token *** <think>
Okay, the user
LOG *******
LOG token *** <think>
Okay, the user is
LOG *******
LOG token *** <think>
Okay, the user is asking
LOG *******
LOG token *** <think>
Okay, the user is asking,
LOG *******
LOG token *** <think>
Okay, the user is asking, "
LOG *******
LOG token *** <think>
Okay, the user is asking, "Ok
LOG *******
LOG token *** <think>
Okay, the user is asking, "Ok how
LOG *******
LOG token *** <think>
Okay, the user is asking, "Ok how old
LOG *******
LOG token *** <think>
Okay, the user is asking, "Ok how old are
LOG *******
i thought the responseCallback was actually giving token per token answers but not accumulating it like the normal useLLM function was doing.
My goal is to try to parse the token on the fly so that i can change the UI, i'm depending on token so i can make direct equality like token === "" since i will know in advance the tag.
Also this is more a question but couldn't that JS callback be on the generate itself?
When i use the API of oai compatible cloud model i get the streaming of token on calling the completion endpoint and it is the same for the llamacpp libraries. The token callback is on the "completion" call which correspond to this library generate.
I'm saying this because the token parsing is often link to the display we are doing on the app and its often a function that depend on various state that can change and it seems that even when i use a useCallback im not getting the token sent to that function
Steps to reproduce
- Load model with module
- console.log the token
Snack or a link to a repository
No response
React Native Executorch version
0.4.2
React Native version
0.79
Platforms
iOS
JavaScript runtime
Hermes
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
Simulator
AI model
No response
Performance logs
No response
Acknowledgements
Yes
Description
Hello,
I'm trying to use the responseCallback from the module
This is what i have and the log im getting is as such
i thought the responseCallback was actually giving token per token answers but not accumulating it like the normal useLLM function was doing.
My goal is to try to parse the token on the fly so that i can change the UI, i'm depending on token so i can make direct equality like token === "" since i will know in advance the tag.
Also this is more a question but couldn't that JS callback be on the generate itself?
When i use the API of oai compatible cloud model i get the streaming of token on calling the completion endpoint and it is the same for the llamacpp libraries. The token callback is on the "completion" call which correspond to this library generate.
I'm saying this because the token parsing is often link to the display we are doing on the app and its often a function that depend on various state that can change and it seems that even when i use a useCallback im not getting the token sent to that function
Steps to reproduce
Snack or a link to a repository
No response
React Native Executorch version
0.4.2
React Native version
0.79
Platforms
iOS
JavaScript runtime
Hermes
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
Simulator
AI model
No response
Performance logs
No response
Acknowledgements
Yes