aichat

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AIChat

func AIChat(props Props) templ.Component

AIChat renders a conversational AI chat widget. Collapsed: sparkle icon + placeholder + keyboard shortcut. Expanded: scrollable message area + reply input.

func ActionBar

func ActionBar(props ActionBarProps) templ.Component

ActionBar renders a primary button + discard button row.

func AssignRow

func AssignRow(props AssignRowProps) templ.Component

AssignRow renders an "Assign:" label with avatar chips.

func AssistantMessage

func AssistantMessage(props ...AssistantMessageProps) templ.Component

AssistantMessage renders a light bubble with sparkle avatar, left-aligned (AI response). Takes children for content (text, cards, quick replies, etc.).

func AssistantMessageWithContent

func AssistantMessageWithContent(content templ.Component) templ.Component

AssistantMessageWithContent renders an assistant message wrapping a templ component. Use this from Go code (e.g. SSE handlers) where { children... } isn't available.

func AssistantText

func AssistantText(text string) templ.Component

AssistantText renders a text bubble inside an AssistantMessage.

func MessagesID

func MessagesID(chatID string) string

MessagesID returns the ID of the messages container for SSE targeting.

func QuickReplies

func QuickReplies(props QuickRepliesProps) templ.Component

QuickReplies renders a row of bordered buttons below an AI message.

func ReadSignals

func ReadSignals(chatID string, r *http.Request, dest *AIChatSignals) error

ReadSignals reads the AI chat's namespaced signals from the request.

func ResponseCard

func ResponseCard(props ResponseCardProps) templ.Component

ResponseCard renders a bordered card inside an assistant message. Takes children for action rows (AssignRow, ActionBar).

func Typing

func Typing(props TypingProps) templ.Component

Typing renders a sparkle avatar with animated dots (AI is thinking).

func UserMessage

func UserMessage(props UserMessageProps) templ.Component

UserMessage renders a dark pill bubble, right-aligned (user's message).

Types

type AIChatSignals

type AIChatSignals struct {
	Open  bool   `json:"open"`  // collapsed vs expanded
	Input string `json:"input"` // current input text
}

AIChatSignals holds the reactive state for the AI chat.

type ActionBarProps

type ActionBarProps struct {
	PrimaryLabel string // e.g. "Add to inbox ✦"
	PrimaryURL   string // POST endpoint for primary action
	DiscardURL   string // POST endpoint for discard
}

ActionBarProps configures the action bar at the bottom of a response card.

type AssignRowProps

type AssignRowProps struct {
	Members []Member
}

AssignRowProps configures the assign row.

type AssistantMessageProps

type AssistantMessageProps struct {
	ID    string
	Class string
}

AssistantMessageProps configures an assistant message.

type CardTag

type CardTag struct {
	Label   string
	Variant string // "" (default/outline) | "warning" | "success" | "info" | "error"
}

CardTag represents a category badge on a response card.

type ChatSender

type ChatSender struct {
	// contains filtered or unexported fields
}

ChatSender provides SSE operations scoped to a specific AI chat instance.

func Chat

Chat returns a ChatSender scoped to the given chat ID. All operations target the chat's messages container.

chat := aichat.Chat(sse, "my-chat")
chat.UserMessage("Hello")
chat.ShowTyping()
chat.HideTyping()
chat.AssistantText("Hi there!")

func (*ChatSender) Append

func (c *ChatSender) Append(component templ.Component) error

Append appends any templ component to the messages area.

func (*ChatSender) AssistantMessage

func (c *ChatSender) AssistantMessage(content templ.Component) error

AssistantMessage appends an assistant message wrapping a templ component.

func (*ChatSender) AssistantText

func (c *ChatSender) AssistantText(text string) error

AssistantText appends a simple text response from the assistant.

func (*ChatSender) HideTyping

func (c *ChatSender) HideTyping() error

HideTyping removes the typing indicator.

func (*ChatSender) ShowTyping

func (c *ChatSender) ShowTyping() error

ShowTyping appends a typing indicator.

func (*ChatSender) UserMessage

func (c *ChatSender) UserMessage(text string) error

UserMessage appends a user message bubble.

type Member

type Member struct {
	Initials string // e.g. "ME", "SA"
	Name     string // display name
	Color    string // Tailwind bg color class (e.g. "bg-success", "bg-secondary")
	Active   bool   // currently selected
}

Member represents a team/family member for assignment.

type Props

type Props struct {
	ID               string
	Class            string
	Attributes       templ.Attributes
	Placeholder      string          // collapsed placeholder (default "Tell your butler something...")
	ReplyPlaceholder string          // reply input placeholder (default "Type a reply...")
	SubmitURL        string          // POST endpoint for user messages
	Shortcut         string          // keyboard shortcut hint (default "⌘K")
	InputSlot        templ.Component // optional: replaces default input row (e.g. embedded CommandBar)
}

Props configures the AI chat component.

type QuickRepliesProps

type QuickRepliesProps struct {
	ID        string
	SubmitURL string // POST endpoint — value is sent via signals
	ChatID    string // parent AIChat ID to set input signal before posting
	Options   []QuickReply
}

QuickRepliesProps configures quick-reply buttons.

type QuickReply

type QuickReply struct {
	Label string
	Value string // sent as message text when clicked
}

QuickReply represents a single quick-reply option.

type ResponseCardProps

type ResponseCardProps struct {
	ID          string
	Class       string
	Title       string // bold heading (e.g. "Buy football boots for Max")
	Description string // AI explanation text
	Tags        []CardTag
}

ResponseCardProps configures a rich AI response card.

type TypingProps

type TypingProps struct {
	ID string
}

TypingProps configures the typing indicator.

type UserMessageProps

type UserMessageProps struct {
	ID    string
	Class string
	Text  string
}

UserMessageProps configures a user message bubble.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL