Skip to content

Class: SpecialTokensText

Defined in: utils/LlamaText.ts:433

Constructors

new SpecialTokensText()

ts
new SpecialTokensText(value: string): SpecialTokensText

Defined in: utils/LlamaText.ts:436

Parameters

ParameterType
valuestring

Returns

SpecialTokensText

Properties

value

ts
readonly value: string;

Defined in: utils/LlamaText.ts:434

Methods

toString()

ts
toString(): string

Defined in: utils/LlamaText.ts:440

Returns

string


tokenize()

ts
tokenize(tokenizer: Tokenizer, trimLeadingSpace: boolean): Token[]

Defined in: utils/LlamaText.ts:444

Parameters

ParameterTypeDefault value
tokenizerTokenizerundefined
trimLeadingSpacebooleanfalse

Returns

Token[]


tokenizeSpecialTokensOnly()

ts
tokenizeSpecialTokensOnly(tokenizer: Tokenizer): (string | Token)[]

Defined in: utils/LlamaText.ts:448

Parameters

ParameterType
tokenizerTokenizer

Returns

(string | Token)[]


toJSON()

ts
toJSON(): LlamaTextSpecialTokensTextJSON

Defined in: utils/LlamaText.ts:472

Returns

LlamaTextSpecialTokensTextJSON


fromJSON()

ts
static fromJSON(json: LlamaTextSpecialTokensTextJSON): SpecialTokensText

Defined in: utils/LlamaText.ts:496

Parameters

ParameterType
jsonLlamaTextSpecialTokensTextJSON

Returns

SpecialTokensText


isSpecialTokensTextJSON()

ts
static isSpecialTokensTextJSON(value: LlamaTextJSONValue): value is LlamaTextSpecialTokensTextJSON

Defined in: utils/LlamaText.ts:503

Parameters

ParameterType
valueLlamaTextJSONValue

Returns

value is LlamaTextSpecialTokensTextJSON


wrapIf()

ts
static wrapIf(shouldWrap: boolean, value: string): string | SpecialTokensText

Defined in: utils/LlamaText.ts:510

Wraps the value with a SpecialTokensText only if shouldWrap is true

Parameters

ParameterType
shouldWrapboolean
valuestring

Returns

string | SpecialTokensText