manually stop at stop tokens for all providers
This commit is contained in:
parent
58a7ee8369
commit
8a4d57f015
2 changed files with 3 additions and 2 deletions
|
|
@ -28,6 +28,7 @@ import AutocompleteLruCache from "./cache.js";
|
|||
import {
|
||||
noFirstCharNewline,
|
||||
onlyWhitespaceAfterEndOfLine,
|
||||
stopAtStopTokens,
|
||||
} from "./charStream.js";
|
||||
import {
|
||||
constructAutocompletePrompt,
|
||||
|
|
@ -662,6 +663,7 @@ export class CompletionProvider {
|
|||
lang.endOfLine,
|
||||
fullStop,
|
||||
);
|
||||
charGenerator = stopAtStopTokens(charGenerator, stop);
|
||||
charGenerator = this.bracketMatchingService.stopOnUnmatchedClosingBracket(
|
||||
charGenerator,
|
||||
prefix,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { stopAtStopTokens } from "../../autocomplete/charStream.js";
|
||||
import { CompletionOptions, ModelProvider } from "../../index.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
import { streamSse } from "../stream.js";
|
||||
|
|
@ -50,7 +49,7 @@ class HuggingFaceInferenceAPI extends BaseLLM {
|
|||
}
|
||||
}
|
||||
|
||||
for await (const text of stopAtStopTokens(stream(), options.stop ?? [])) {
|
||||
for await (const text of stream()) {
|
||||
yield text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue