Skip to content

Class: LlamaText

Defined in: utils/LlamaText.ts:16

See

Using LlamaText tutorial

Constructors

new LlamaText()

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

Defined in: utils/LlamaText.ts:22

Can also be called without new

Parameters

ParameterType
...valuesreadonly LlamaTextInputValue[]

Returns

LlamaText

Properties

values

ts
readonly values: readonly LlamaTextValue[];

Defined in: utils/LlamaText.ts:17

Methods

concat()

ts
concat(value: LlamaTextInputValue): LlamaText

Defined in: utils/LlamaText.ts:27

Parameters

ParameterType
valueLlamaTextInputValue

Returns

LlamaText


mapValues()

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

Defined in: utils/LlamaText.ts:31

Parameters

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

Returns

LlamaText


joinValues()

ts
joinValues(separator: 
  | LlamaTextValue
  | LlamaText): LlamaText

Defined in: utils/LlamaText.ts:51

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
separator| LlamaTextValue | LlamaText

Returns

LlamaText


toString()

ts
toString(): string

Defined in: utils/LlamaText.ts:68

Returns

string


toJSON()

ts
toJSON(): LlamaTextJSON

Defined in: utils/LlamaText.ts:81

Returns

LlamaTextJSON


tokenize()

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

Defined in: utils/LlamaText.ts:97

Parameters

ParameterType
tokenizerTokenizer
options?"trimLeadingSpace"

Returns

Token[]


compare()

ts
compare(other: LlamaText): boolean

Defined in: utils/LlamaText.ts:121

Parameters

ParameterType
otherLlamaText

Returns

boolean


trimStart()

ts
trimStart(): LlamaText

Defined in: utils/LlamaText.ts:125

Returns

LlamaText


trimEnd()

ts
trimEnd(): LlamaText

Defined in: utils/LlamaText.ts:163

Returns

LlamaText


includes()

ts
includes(value: LlamaText): boolean

Defined in: utils/LlamaText.ts:201

Parameters

ParameterType
valueLlamaText

Returns

boolean


fromJSON()

ts
static fromJSON(json: LlamaTextJSON): LlamaText

Defined in: utils/LlamaText.ts:268

Parameters

ParameterType
jsonLlamaTextJSON

Returns

LlamaText


compare()

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

Defined in: utils/LlamaText.ts:290

Parameters

ParameterType
aLlamaText
bLlamaText

Returns

boolean


fromTokens()

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

Defined in: utils/LlamaText.ts:312

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


joinValues()

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

Defined in: utils/LlamaText.ts:365

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

Parameters

ParameterType
separatorstring | LlamaText
valuesreadonly LlamaTextInputValue[]

Returns

LlamaText


isLlamaText()

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

Defined in: utils/LlamaText.ts:382

Parameters

ParameterType
valueunknown

Returns

value is LlamaText