mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-30 04:11:33 -08:00
feat: decode token
This commit is contained in:
parent
a3fb8813c7
commit
ee2ccc3e9b
3 changed files with 12 additions and 4 deletions
|
|
@ -479,7 +479,8 @@
|
|||
"ModelNotExist": "找不到模型",
|
||||
"ModelNotExistDescription": "尝试使用你给的这个路径加载模型,但在这个位置其实没有所需要的模型",
|
||||
"OpenThisPath": "打开该位置",
|
||||
"GenerationTimeout": "模型生成超时,已中止。"
|
||||
"GenerationTimeout": "模型生成超时,已中止。",
|
||||
"ModalDisposed": "模型已卸载,生成中止,需要重新加载模型。"
|
||||
},
|
||||
"Help": {
|
||||
"Alternatives": "其它源",
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export class LanguageModel implements ILanguageModelService {
|
|||
return;
|
||||
}
|
||||
let observable;
|
||||
const texts = { timeout: i18n.t('LanguageModel.GenerationTimeout') };
|
||||
const texts = { timeout: i18n.t('LanguageModel.GenerationTimeout'), disposed: i18n.t('LanguageModel.ModalDisposed') };
|
||||
switch (runner) {
|
||||
case LanguageModelRunner.llamaCpp: {
|
||||
observable = worker.runLLama({ completionOptions, loadConfig: { ...config, modelPath }, conversationID }, texts);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export function runLLama(
|
|||
conversationID: IRunLLAmaOptions['id'];
|
||||
loadConfig: IRunLLAmaOptions['loadConfig'];
|
||||
},
|
||||
texts: { timeout: string },
|
||||
texts: { disposed: string; timeout: string },
|
||||
): Observable<ILanguageModelWorkerResponse> {
|
||||
const { conversationID, completionOptions, loadConfig } = options;
|
||||
|
||||
|
|
@ -105,8 +105,15 @@ export function runLLama(
|
|||
...completionOptions,
|
||||
signal: abortController.signal,
|
||||
onToken: (tokens) => {
|
||||
if (modalInstance === undefined) {
|
||||
abortController.abort();
|
||||
runnerAbortControllers.delete(conversationID);
|
||||
subscriber.next({ type: 'result', token: texts.timeout, id: conversationID });
|
||||
subscriber.complete();
|
||||
return;
|
||||
}
|
||||
updateTimeout();
|
||||
subscriber.next({ type: 'result', token, id: conversationID });
|
||||
subscriber.next({ type: 'result', token: modalInstance.detokenize(tokens), id: conversationID });
|
||||
},
|
||||
});
|
||||
// completed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue