Class: LlamaText
Defined in: utils/LlamaText.ts:16
See
Using LlamaText
tutorial
Constructors
new LlamaText()
new LlamaText(...values: readonly LlamaTextInputValue[]): LlamaText
Defined in: utils/LlamaText.ts:22
Can also be called without new
Parameters
Parameter | Type |
---|---|
...values | readonly LlamaTextInputValue [] |
Returns
Properties
values
readonly values: readonly LlamaTextValue[];
Defined in: utils/LlamaText.ts:17
Methods
concat()
concat(value: LlamaTextInputValue): LlamaText
Defined in: utils/LlamaText.ts:27
Parameters
Parameter | Type |
---|---|
value | LlamaTextInputValue |
Returns
mapValues()
mapValues(mapper: (this: readonly LlamaTextValue[], value: LlamaTextValue, index: number, values: readonly LlamaTextValue[]) => LlamaTextInputValue): LlamaText
Defined in: utils/LlamaText.ts:31
Parameters
Parameter | Type |
---|---|
mapper | (this : readonly LlamaTextValue [], value : LlamaTextValue , index : number , values : readonly LlamaTextValue []) => LlamaTextInputValue |
Returns
joinValues()
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
Parameter | Type |
---|---|
separator | | LlamaTextValue | LlamaText |
Returns
toString()
toString(): string
Defined in: utils/LlamaText.ts:68
Returns
string
toJSON()
toJSON(): LlamaTextJSON
Defined in: utils/LlamaText.ts:81
Returns
tokenize()
tokenize(tokenizer: Tokenizer, options?: "trimLeadingSpace"): Token[]
Defined in: utils/LlamaText.ts:97
Parameters
Parameter | Type |
---|---|
tokenizer | Tokenizer |
options ? | "trimLeadingSpace" |
Returns
Token
[]
compare()
compare(other: LlamaText): boolean
Defined in: utils/LlamaText.ts:121
Parameters
Parameter | Type |
---|---|
other | LlamaText |
Returns
boolean
trimStart()
trimStart(): LlamaText
Defined in: utils/LlamaText.ts:125
Returns
trimEnd()
trimEnd(): LlamaText
Defined in: utils/LlamaText.ts:163
Returns
includes()
includes(value: LlamaText): boolean
Defined in: utils/LlamaText.ts:201
Parameters
Parameter | Type |
---|---|
value | LlamaText |
Returns
boolean
fromJSON()
static fromJSON(json: LlamaTextJSON): LlamaText
Defined in: utils/LlamaText.ts:268
Parameters
Parameter | Type |
---|---|
json | LlamaTextJSON |
Returns
compare()
static compare(a: LlamaText, b: LlamaText): boolean
Defined in: utils/LlamaText.ts:290
Parameters
Parameter | Type |
---|---|
a | LlamaText |
b | LlamaText |
Returns
boolean
fromTokens()
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
Parameter | Type |
---|---|
tokenizer | Tokenizer |
tokens | Token [] |
Returns
joinValues()
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
Parameter | Type |
---|---|
separator | string | LlamaText |
values | readonly LlamaTextInputValue [] |
Returns
isLlamaText()
static isLlamaText(value: unknown): value is LlamaText
Defined in: utils/LlamaText.ts:382
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
value is LlamaText