Documentation
¶
Overview ¶
Package providers defines the Provider interface and common types for embed providers.
Index ¶
- type DifyProvider
- func (p *DifyProvider) Description() string
- func (p *DifyProvider) ID() string
- func (p *DifyProvider) Name() string
- func (p *DifyProvider) RenderBody(settings map[string]string, rc RenderContext) template.HTML
- func (p *DifyProvider) RenderHead(_ map[string]string) template.HTML
- func (p *DifyProvider) SettingsSchema() []SettingField
- func (p *DifyProvider) Validate(settings map[string]string) error
- type Provider
- type RenderContext
- type SelectOption
- type SettingField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DifyProvider ¶
type DifyProvider struct{}
DifyProvider implements the Provider interface for Dify AI chat.
func (*DifyProvider) Description ¶
func (p *DifyProvider) Description() string
Description returns the provider description.
func (*DifyProvider) RenderBody ¶
func (p *DifyProvider) RenderBody(settings map[string]string, rc RenderContext) template.HTML
RenderBody returns the custom Dify chat widget.
func (*DifyProvider) RenderHead ¶
func (p *DifyProvider) RenderHead(_ map[string]string) template.HTML
RenderHead returns HTML for the <head> section.
func (*DifyProvider) SettingsSchema ¶
func (p *DifyProvider) SettingsSchema() []SettingField
SettingsSchema returns the configuration fields for Dify.
type Provider ¶
type Provider interface {
// ID returns the unique identifier for the provider (e.g., "dify", "youtube")
ID() string
// Name returns the display name for the provider
Name() string
// Description returns a brief description of the provider
Description() string
// SettingsSchema returns the configuration fields for the provider
SettingsSchema() []SettingField
// Validate validates the provider settings
// Returns nil if valid, or an error describing the issue
Validate(settings map[string]string) error
// RenderHead returns HTML to inject in the <head> section
RenderHead(settings map[string]string) template.HTML
// RenderBody returns HTML to inject before </body>.
// ctx carries the request origin and a token-issuance closure so providers
// that need a signed proxy token can mint it at render time instead of
// relying on a public mint endpoint.
RenderBody(settings map[string]string, ctx RenderContext) template.HTML
}
Provider defines the interface for embed providers. Each provider implements a specific third-party service integration.
type RenderContext ¶ added in v0.18.1
type RenderContext struct {
Origin string
IssueProxyToken func() (token string, expiresAt time.Time, err error)
}
RenderContext carries per-request state into provider render methods. Origin is the normalized scheme://host of the page the widget will run on. IssueProxyToken mints a signed proxy token bound to Origin (or returns an error if the module is not configured to issue one). Providers that do not need a token can ignore the closure.
type SelectOption ¶
SelectOption represents an option for select fields.
type SettingField ¶
type SettingField struct {
// ID is the unique identifier for the field (used in JSON storage)
ID string
// Name is the display name for the field
Name string
// Description provides additional context for the field
Description string
// Type is the field type: "text", "textarea", "url", "color", "select", "checkbox"
Type string
// Options are the available choices for "select" type fields
Options []SelectOption
// Required indicates if the field must have a value when enabled
Required bool
// Default is the default value for the field
Default string
// Placeholder is the placeholder text for input fields
Placeholder string
}
SettingField defines a configuration field for a provider.