thread.svelte.ts

Declarations
#

2 declarations

view source

Thread
#

thread.svelte.ts view source

A thread is a linear sequence of turns that maintains a chronological record of interactions between the user and the AI.

inheritance

extends:
  • Cell<typeof ThreadJson>

model_name

type string

model

type Model

readonly

turns

type IndexedCollection<Turn>

readonly

enabled

type boolean

content

type string

readonly

length

type number

readonly

token_count

type number

readonly

content_preview

type string

readonly

constructor

type new (options: ThreadOptions): Thread

options

add_turn

Add a turn to this thread.

type (turn: Turn): void

turn
type Turn
returns void

add_user_turn

Create and add a user turn with the given content.

type (content: string, request?: { created: string & $brand<"Datetime">; provider_name: "ollama" | "claude" | "chatgpt" | "gemini"; model: string; prompt: string; completion_messages?: { ...; }[] | undefined; } | undefined): Turn

content
type string
request?
type { created: string & $brand<"Datetime">; provider_name: "ollama" | "claude" | "chatgpt" | "gemini"; model: string; prompt: string; completion_messages?: { [x: string]: unknown; role: string; content: string; }[] | undefined; } | undefined
optional
returns Turn

add_assistant_turn

Create and add an assistant turn with the given content.

type (content: string, json?: Partial<{ id: string & $brand<"Uuid">; created: string & $brand<"Datetime">; updated: string & $brand<"Datetime">; part_ids: (string & $brand<...>)[]; ... 4 more ...; error_message?: string | undefined; }> | undefined): Turn

content
type string
json?
type Partial<{ id: string & $brand<"Uuid">; created: string & $brand<"Datetime">; updated: string & $brand<"Datetime">; part_ids: (string & $brand<"Uuid">)[]; ... 4 more ...; error_message?: string | undefined; }> | undefined
optional
returns Turn

add_system_turn

Create and add a system turn with the given content.

type (content: string): Turn

content
type string
returns Turn

add_turn_from_part

Create and add a turn from a part.

type (part: PartUnion, role: string): Turn

part
role
type string
returns Turn

remove_all_turns

Remove all turns from this thread.

type (): void

returns void

send_message

Send a message to the AI and create corresponding turns. Returns null if provider is unavailable (defensive check - UI should prevent this).

type (content: string): Promise<Turn | null>

content
type string
returns Promise<Turn | null>

switch_model

type (model_id: string & $brand<"Uuid">): void

model_id
type string & $brand<"Uuid">
returns void

ThreadOptions
#

Depends on
#

Imported by
#