Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskOptions ¶
AskOptions is the Ask handler behind ModuleAsk. It builds the form and send button for input. When the user sends with Enter or the button, it submits an AskOutput to answer, but only if at least one option is picked or own text is selected, and the own text is within 256 KiB. Use it to add the same question to a module of your own with neui.Module.Ask.
func ModuleAsk ¶
func ModuleAsk() common.ModuleFactory
ModuleAsk is the built-in module that lets the agent ask the user to pick from a list, rendered in the chat by Chat. Register it with neui.WithModules or neui.OptionModules:
neui.Enable(ctx, neui.OptionModules(nekit.ModuleAsk()))
Types ¶
type AskInput ¶
type AskInput struct {
// Question is shown above the options.
Question string `json:"question" required:"true" description:"the question, one sentence"`
// Options are listed in this order.
Options []AskOption `json:"options" required:"true" description:"the answers to pick from, in order"`
// Multiple shows checkboxes instead of radio buttons, so several answers can be picked.
Multiple bool `json:"multiple,omitempty" description:"allow several answers instead of one"`
// Own adds a free-text row for an answer of the user's own, up to 256 KiB.
Own bool `json:"own,omitempty" description:"add a row for the user to type their own answer"`
}
AskInput is what the agent sends to the ask tool: a question and the answers to offer.
type AskOption ¶
type AskOption struct {
// Name is the answer as shown and as returned in AskOutput.Picked.
Name string `json:"name" required:"true" description:"the answer, a few words"`
// Desc is an optional line under the name explaining the choice.
Desc string `json:"description" description:"one line on what picking it means; omit when the name says it"`
}
AskOption is one answer the user can pick in an AskOptions question.
type AskOutput ¶
type AskOutput struct {
// Picked holds the names of the chosen options, in option order.
Picked []string `json:"picked,omitempty" description:"names of the options marked"`
// Typed is the user's own answer, trimmed; empty unless the own row is
// selected and has text.
Typed string `json:"typed,omitempty" description:"the user's own typed answer; may come with picked when multiple"`
}
AskOutput is the user's answer as the agent receives it. At least one of Picked and Typed is set.
type Chat ¶
type Chat struct {
// MaxAttachmentSize is the largest file, in bytes, a user may attach. Zero means 12 MiB.
MaxAttachmentSize int
// MaxAttachments is how many files one draft may hold. Zero means 10.
MaxAttachments int
// AttachmentTimeout bounds one file upload. Zero means 10 minutes.
AttachmentTimeout time.Duration
// AsideRight puts the chat list sidebar on the right instead of the left.
AsideRight bool
// Framed draws a rounded border around the widget.
Framed bool
// ThemeDark recolours the dark face, shown under a dark system scheme or
// inside data-theme="dark". The zero value keeps the built-in palette.
ThemeDark css.Theme
// ThemeLight recolours the light face, shown under a light system scheme or
// inside data-theme="light". The zero value keeps the built-in palette.
ThemeLight css.Theme
// Layout sets the chat's side and sizes; the zero value keeps the defaults.
Layout css.Layout
// GreetingTitle is the heading a new chat shows before its first message:
// a string or a GoX element. nil shows "How can I help?"; "" leaves it out.
GreetingTitle any
// GreetingBody is what shows under GreetingTitle: a string or a GoX element,
// such as the host's own template. nil shows "Ask a question or describe
// what you need."; "" leaves it out.
GreetingBody any
// Disable lists features hidden from the user; nil shows everything.
// ChatSimple is the preset for non-technical users and grows with technical features added later.
Disable []params.Feature
}
Chat is the ready-made chat widget: the chat list sidebar, the thread, the composer and its popovers. Render it on a page as ~nekit.Chat{}; the zero value is a complete chat. It fills its container, so give that container a height.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package css holds the nechat stylesheet and its theme overrides.
|
Package css holds the nechat stylesheet and its theme overrides. |
|
Package params carries nekit chat settings through the widget's components.
|
Package params carries nekit chat settings through the widget's components. |