Skip to content

Class: LlamaText

Constructors

new LlamaText()

ts
new LlamaText(...values: readonly LlamaTextInputValue[]): LlamaText

Can also be called without new

Parameters

ParameterType
...valuesreadonly LlamaTextInputValue[]

Returns

LlamaText

Defined in

utils/LlamaText.ts:19

Properties

values

ts
readonly values: readonly LlamaTextValue[];

Defined in

utils/LlamaText.ts:14

Methods

concat()

ts
concat(value: LlamaTextInputValue): LlamaText

Parameters

ParameterType
valueLlamaTextInputValue

Returns

LlamaText

Defined in

utils/LlamaText.ts:24


mapValues()

ts
mapValues(mapper: (this: readonly LlamaTextValue[], value: LlamaTextValue, index: number, values: readonly LlamaTextValue[]) => LlamaTextInputValue): LlamaText

Parameters

ParameterType
mapper(this: readonly LlamaTextValue[], value: LlamaTextValue, index: number, values: readonly LlamaTextValue[]) => LlamaTextInputValue

Returns

LlamaText

Defined in

utils/LlamaText.ts:28


joinValues()

ts
joinValues(separator: LlamaTextValue | LlamaText): LlamaText

Joins the values with the given separator.

Note that the values are squashed when they are loaded into the LlamaText, so the separator is not added between adjacent strings.

To add the separator on values before squashing them, use LlamaText.joinValues instead.

Parameters

ParameterType
separatorLlamaTextValue | LlamaText

Returns

LlamaText

Defined in

utils/LlamaText.ts:48


toString()

ts
toString(): string

Returns

string

Defined in

utils/LlamaText.ts:65


toJSON()

ts
toJSON(): LlamaTextJSON

Returns

LlamaTextJSON

Defined in

utils/LlamaText.ts:78


tokenize()

ts
tokenize(tokenizer: Tokenizer, options?: "trimLeadingSpace"): Token[]

Parameters

ParameterType
tokenizerTokenizer
options?"trimLeadingSpace"

Returns

Token[]

Defined in

utils/LlamaText.ts:94


compare()

ts
compare(other: LlamaText): boolean

Parameters

ParameterType
otherLlamaText

Returns

boolean

Defined in

utils/LlamaText.ts:118


trimStart()

ts
trimStart(): LlamaText

Returns

LlamaText

Defined in

utils/LlamaText.ts:122


trimEnd()

ts
trimEnd(): LlamaText

Returns

LlamaText

Defined in

utils/LlamaText.ts:160


includes()

ts
includes(value: LlamaText): boolean

Parameters

ParameterType
valueLlamaText

Returns

boolean

Defined in

utils/LlamaText.ts:198


fromJSON()

ts
static fromJSON(json: LlamaTextJSON): LlamaText

Parameters

ParameterType
jsonLlamaTextJSON

Returns

LlamaText

Defined in

utils/LlamaText.ts:265


compare()

ts
static compare(a: LlamaText, b: LlamaText): boolean

Parameters

ParameterType
aLlamaText
bLlamaText

Returns

boolean

Defined in

utils/LlamaText.ts:287


fromTokens()

ts
static fromTokens(tokenizer: Tokenizer, tokens: Token[]): LlamaText

Attempt to convert tokens to a LlamaText while preserving special tokens.

Non-standard special tokens that don't have a text representation are ignored.

Parameters

ParameterType
tokenizerTokenizer
tokensToken[]

Returns

LlamaText

Defined in

utils/LlamaText.ts:309


joinValues()

ts
static joinValues(separator: string | LlamaText, values: readonly LlamaTextInputValue[]): LlamaText

Join values with the given separator before squashing adjacent strings inside the values

Parameters

ParameterType
separatorstring | LlamaText
valuesreadonly LlamaTextInputValue[]

Returns

LlamaText

Defined in

utils/LlamaText.ts:362


isLlamaText()

ts
static isLlamaText(value: unknown): value is LlamaText

Parameters

ParameterType
valueunknown

Returns

value is LlamaText

Defined in

utils/LlamaText.ts:379