org.llm4s.assistant

Members list

Type members

Classlikes

class AssistantAgent(client: LLMClient, tools: ToolRegistry, sessionDir: String)

Interactive assistant agent that wraps an org.llm4s.agent.Agent in a user-friendly conversational loop with session management. The agent is built once, from client and tools; each query is one turn on the session's thread.

Interactive assistant agent that wraps an org.llm4s.agent.Agent in a user-friendly conversational loop with session management. The agent is built once, from client and tools; each query is one turn on the session's thread.

Attributes

Supertypes
class Object
trait Matchable
class Any
sealed trait Command

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Help
class Load
object New
object Quit
class Save
object Sessions
Show all
object Command

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Command.type
case class SessionInfo(id: SessionId, title: String, filePath: FilePath, created: LocalDateTime, messageCount: Int, fileSize: Long)

Information about a saved session file.

Information about a saved session file.

Contains metadata about a persisted session including file location and statistics about the conversation.

Value parameters

created

Timestamp when the session was created

filePath

Path to the session JSON file

fileSize

Size of the session file in bytes

id

Unique session identifier

messageCount

Number of messages in the conversation

title

Human-readable session title

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SessionInfo

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
class SessionManager(sessionDir: DirectoryPath, uniqueSuffix: () => String)

Manages session persistence for the interactive assistant.

Manages session persistence for the interactive assistant.

SessionManager handles saving and loading conversation sessions to disk, enabling users to resume previous conversations and maintain context across multiple interactions.

== Key Features ==

  • '''Session Save''': Persists the conversation's messages as JSON with markdown companion
  • '''Session Load''': Restores the messages, which the next turn imports into a new agent thread
  • '''Session Listing''': Shows recent sessions sorted by modification time
  • '''Filename Sanitization''': Safely handles special characters in titles

== Storage Format == Sessions are stored as two files:

  • {title}.json - Machine-readable session state for loading
  • {title}.md - Human-readable markdown for viewing/sharing

== Usage Example ==

val manager = new SessionManager(DirectoryPath("/path/to/sessions"))

// Save current session
val info = manager.saveSession(sessionState, Some("My Conversation"))

// List recent sessions
val sessions = manager.listRecentSessions(limit = 5)

// Load a previous session
val loaded = manager.loadSession("My Conversation")

Value parameters

sessionDir

Directory path where sessions are stored

uniqueSuffix

Generator for the suffix used to disambiguate filename collisions; injectable for testing

Attributes

See also

SessionState for the state being persisted

SessionInfo for session metadata returned after save

Supertypes
class Object
trait Matchable
class Any
case class SessionState(threadId: Option[ThreadId], last: Option[AgentResult], sessionId: SessionId, sessionDir: DirectoryPath, created: LocalDateTime, history: Vector[Message])

Represents the state of an interactive assistant session.

Represents the state of an interactive assistant session.

The conversation lives on a thread of the assistant's agent: threadId names it once a turn has run, and last is that turn's result. A loaded session has neither yet: its saved messages are in history, and the next turn imports them into a new thread.

Value parameters

created

Timestamp when the session was created

history

Messages loaded from a saved session, imported by the next turn

last

The result of the latest turn on threadId

sessionDir

Directory path for session file storage

sessionId

Unique identifier for this session

threadId

The agent thread holding the conversation, once a turn has run on it

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SessionState

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class SessionSummary(id: SessionId, title: String, filename: String, created: LocalDateTime)

Summary of a session for listing and display purposes.

Summary of a session for listing and display purposes.

Lightweight representation of a session containing only essential information for session selection UI.

Value parameters

created

Timestamp when the session was created

filename

Base filename of the session file

id

Unique session identifier

title

Human-readable session title

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type