* fix: duplicate role inside messages cause some model to refuse to answer Signed-off-by: James <namnh0122@gmail.com> * update * Bump cortex to 0.4.12 * some model require not empty message update --------- Signed-off-by: James <namnh0122@gmail.com> Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com>
32 lines
488 B
TypeScript
32 lines
488 B
TypeScript
export class Stack<T> {
|
|
private array: T[] = []
|
|
|
|
pop(): T | undefined {
|
|
if (this.isEmpty()) throw new Error()
|
|
|
|
return this.array.pop()
|
|
}
|
|
|
|
push(data: T): void {
|
|
this.array.push(data)
|
|
}
|
|
|
|
peek(): T {
|
|
if (this.isEmpty()) throw new Error()
|
|
|
|
return this.array[this.array.length - 1]
|
|
}
|
|
|
|
isEmpty(): boolean {
|
|
return this.array.length === 0
|
|
}
|
|
|
|
size(): number {
|
|
return this.array.length
|
|
}
|
|
|
|
reverseOutput(): T[] {
|
|
return [...this.array]
|
|
}
|
|
}
|