dify

package
v0.0.0-...-aa2b1f7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIFY_WORKFLOWS_RUN = "/v1/workflows/run"
	DIFY_ADD_USER      = "/console/api/workspaces/apo/members/add"
	DIFY_REMOVE_USER   = "/console/api/workspaces/apo/members/"
	DIFY_PASSWD_UPDATE = "/console/api/apo/account/password"
	DIFY_RESET_PASSWD  = "/console/api/apo/account/reset-password"
)
View Source
const MAX_CACHE_SIZE = 100

Variables

View Source
var DefaultDifyFastHttpClient = &http.Client{
	Transport: &http.Transport{
		MaxIdleConns:        10,
		MaxIdleConnsPerHost: 10,
		DialContext: (&net.Dialer{
			Timeout:   1 * time.Second,
			KeepAlive: 30 * time.Second,
		}).DialContext,
	},
	Timeout: 3 * time.Minute,
}

Functions

func HandleRecords

func HandleRecords(ctx context.Context, logger *zap.Logger, records <-chan *model.WorkflowRecord, handlers ...Handle)

Types

type AlertAnalyzeResponse

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

func (*AlertAnalyzeResponse) WorkflowRunID

func (r *AlertAnalyzeResponse) WorkflowRunID() string

type AlertCheckConfig

type AlertCheckConfig struct {
	FlowId        string
	FlowName      string
	APIKey        string
	Authorization string
	AnalyzeAuth   string

	User string

	Sampling       string
	CacheMinutes   int
	MaxConcurrency int

	Prom prometheus.Repo
}

func DefaultAlertCheckConfig

func DefaultAlertCheckConfig() *AlertCheckConfig

type AlertCheckResponse

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

func (*AlertCheckResponse) CreatedAt

func (r *AlertCheckResponse) CreatedAt() int64

UnixMicro Timestamp

func (*AlertCheckResponse) WorkflowRunID

func (r *AlertCheckResponse) WorkflowRunID() string

type ChunkCompletionResponse

type ChunkCompletionResponse struct{}

type CompletionResponse

type CompletionResponse struct {
	WorkflowRunID string                 `json:"workflow_run_id"`
	TaskID        string                 `json:"task_id"`
	Data          CompletionResponseData `json:"data"`
}

type CompletionResponseData

type CompletionResponseData struct {
	ID         string          `json:"id"`
	WorkflowID string          `json:"workload_id"`
	Status     string          `json:"status"`
	Outputs    json.RawMessage `json:"outputs"`

	CreatedAt int64 `json:"created_at"`
}

type DifyClient

type DifyClient struct {
	*http.Client

	BaseURL string
}

func (*DifyClient) WorkflowsRun

func (c *DifyClient) WorkflowsRun(req *WorkflowRequest, authorization string) (WorkflowResponse, error)

type DifyRepo

type DifyRepo interface {
	AddUser(username string, password string, role string) (*DifyResponse, error)
	UpdatePassword(username string, oldPassword string, newPassword string) (*DifyResponse, error)
	RemoveUser(username string) (*DifyResponse, error)
	ResetPassword(username string, newPassword string) (*DifyResponse, error)

	PrepareAsyncAlertCheckWorkflow(cfg *AlertCheckConfig, logger *zap.Logger) (records <-chan *model.WorkflowRecord, err error)
	SubmitAlertEvents(events []alert.AlertEvent)
	GetCacheMinutes() int
	GetAlertCheckFlowID() string
	GetAlertAnalyzeFlowID() string

	WorkflowsRun(req *WorkflowRequest, authorization string) (*CompletionResponse, error)
}

func New

func New() (DifyRepo, error)

type DifyResponse

type DifyResponse struct {
	Result  string `json:"result"`
	Message string `json:"message"`
}

type DifyUser

type DifyUser struct {
	Password    string `json:"password"`
	NewPassword string `json:"new_password"`
	Role        string `json:"role"`
	Username    string `json:"username"`
}

type Handle

type Handle func(ctx core.Context, record *model.WorkflowRecord) error

type WorkflowRequest

type WorkflowRequest struct {
	Inputs       json.RawMessage `json:"inputs"`
	ResponseMode string          `json:"response_mode"`
	User         string          `json:"user"`
}

type WorkflowResponse

type WorkflowResponse interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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