conversation

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StageWaiting   = "waiting"
	StageThinking  = "thinking"
	StageExecuting = "executing"
	StageEliciting = "elicitation"
	StageCanceled  = "canceled"
	StageDone      = "done"
	StageError     = "error"

	StatusSucceeded      = "succeeded"
	StatusRunning        = "running"
	StatusWaitingForUser = "waiting_for_user"
	StatusFailed         = "failed"
	StatusCanceled       = "canceled"
)

Variables

View Source
var ConversationFS embed.FS
View Source
var ConversationPathURI = "/v1/api/agently/conversation/{id}"

Functions

func DefineConversationComponent

func DefineConversationComponent(ctx context.Context, srv *datly.Service) error

Types

type AttachmentView

type AttachmentView struct {
	InlineBody      *[]uint8 `sqlx:"inline_body"`
	Compression     string   `sqlx:"compression"`
	Uri             *string  `sqlx:"uri"`
	MimeType        string   `sqlx:"mime_type"`
	ParentMessageId *string  `sqlx:"parent_message_id"`
}

type ConversationInput

type ConversationInput struct {
	Id                string                `parameter:",kind=path,in=id" predicate:"equal,group=0,t,id"`
	Since             string                `` /* 225-byte string literal not displayed */
	IncludeTranscript bool                  `parameter:",kind=query,in=includeTranscript" predicate:"expr,group=1,?" value:"true"`
	IncludeModelCal   bool                  `parameter:",kind=query,in=includeModelCall" predicate:"expr,group=2,?" value:"false"`
	IncludeToolCall   bool                  `parameter:",kind=query,in=includeToolCall" predicate:"expr,group=3,?" value:"false"`
	AgentId           string                `parameter:",kind=query,in=agentId" predicate:"expr,group=0,t.agent_id = ?"`
	ParentId          string                `parameter:",kind=query,in=parentId" predicate:"expr,group=0,t.conversation_parent_id = ?"`
	ParentTurnId      string                `parameter:",kind=query,in=parentTurnId" predicate:"expr,group=0,t.conversation_parent_turn_id = ?"`
	ExcludeChildren   bool                  `parameter:",kind=query,in=excludeChildren" predicate:"expr,group=0,t.conversation_parent_id IS NULL"`
	ExcludeScheduled  bool                  `parameter:",kind=query,in=excludeScheduled" predicate:"expr,group=0,t.schedule_id IS NULL"`
	ScheduleId        string                `parameter:",kind=query,in=scheduleId" predicate:"expr,group=0,t.schedule_id = ?"`
	ScheduleRunId     string                `parameter:",kind=query,in=scheduleRunId" predicate:"expr,group=0,t.schedule_run_id = ?"`
	Query             string                `` /* 223-byte string literal not displayed */
	StatusFilter      string                `parameter:",kind=query,in=status" predicate:"expr,group=0,t.status = ?"`
	HasScheduleId     bool                  `parameter:",kind=query,in=hasScheduleId" predicate:"expr,group=0,t.schedule_id IS NOT NULL"`
	Has               *ConversationInputHas `setMarker:"true" format:"-" sqlx:"-" diff:"-" json:"-"`
}

func (*ConversationInput) EmbedFS

func (i *ConversationInput) EmbedFS() *embed.FS

type ConversationInputHas

type ConversationInputHas struct {
	Id                bool
	Since             bool
	IncludeTranscript bool
	IncludeModelCal   bool
	IncludeToolCall   bool
	AgentId           bool
	ParentId          bool
	ParentTurnId      bool
	ExcludeChildren   bool
	ExcludeScheduled  bool
	ScheduleId        bool
	ScheduleRunId     bool
	Query             bool
	StatusFilter      bool
	HasScheduleId     bool
}

type ConversationOutput

type ConversationOutput struct {
	response.Status `parameter:",kind=output,in=status" json:",omitempty"`
	Data            []*ConversationView `` /* 128-byte string literal not displayed */
	Metrics         response.Metrics    `parameter:",kind=output,in=metrics"`
}

type ConversationView

type ConversationView struct {
	LastTurnId               *string           `sqlx:"last_turn_id"`
	Stage                    string            `sqlx:"stage"`
	Id                       string            `sqlx:"id"`
	Summary                  *string           `sqlx:"summary"`
	LastActivity             *time.Time        `sqlx:"last_activity"`
	UsageInputTokens         *int              `sqlx:"usage_input_tokens"`
	UsageOutputTokens        *int              `sqlx:"usage_output_tokens"`
	UsageEmbeddingTokens     *int              `sqlx:"usage_embedding_tokens"`
	CreatedAt                time.Time         `sqlx:"created_at"`
	UpdatedAt                *time.Time        `sqlx:"updated_at"`
	CreatedByUserId          *string           `sqlx:"created_by_user_id"`
	AgentId                  *string           `sqlx:"agent_id"`
	DefaultModelProvider     *string           `sqlx:"default_model_provider"`
	DefaultModel             *string           `sqlx:"default_model"`
	DefaultModelParams       *string           `sqlx:"default_model_params"`
	Title                    *string           `sqlx:"title"`
	ConversationParentId     *string           `sqlx:"conversation_parent_id"`
	ConversationParentTurnId *string           `sqlx:"conversation_parent_turn_id"`
	Metadata                 *string           `sqlx:"metadata"`
	Visibility               string            `sqlx:"visibility"`
	Shareable                int               `sqlx:"shareable"`
	Status                   *string           `sqlx:"status"`
	Scheduled                *int              `sqlx:"scheduled"`
	ScheduleId               *string           `sqlx:"schedule_id"`
	ScheduleRunId            *string           `sqlx:"schedule_run_id"`
	ScheduleKind             *string           `sqlx:"schedule_kind"`
	ScheduleTimezone         *string           `sqlx:"schedule_timezone"`
	ScheduleCronExpr         *string           `sqlx:"schedule_cron_expr"`
	ExternalTaskRef          *string           `sqlx:"external_task_ref"`
	Transcript               []*TranscriptView `view:",table=turn" on:"Id:id=ConversationId:conversation_id" sql:"uri=conversation/transcript.sql"`
	Usage                    *UsageView        `view:",table=model_call" on:"Id:id=ConversationId:m.conversation_id" sql:"uri=conversation/usage.sql"`
}

func (*ConversationView) OnRelation

func (c *ConversationView) OnRelation(ctx context.Context)

OnRelation sorts turns and computes the effective conversation stage.

type Elicitation

type Elicitation map[string]interface{}

Elicitation holds hydrated elicitation payload data attached to a message.

func (*Elicitation) Scan

func (e *Elicitation) Scan(src interface{}) error

func (Elicitation) Value

func (e Elicitation) Value() (driver.Value, error)

type LinkedConversationView

type LinkedConversationView struct {
	Id        string     `sqlx:"id"`
	Status    *string    `sqlx:"status"`
	CreatedAt time.Time  `sqlx:"created_at"`
	UpdatedAt *time.Time `sqlx:"updated_at"`
}

type MessageToolCallView added in v0.1.8

type MessageToolCallView struct {
	MessageSequence        *int                        `sqlx:"message_sequence" source:"sequence"`
	MessageId              string                      `sqlx:"message_id"`
	TurnId                 *string                     `sqlx:"turn_id"`
	OpId                   string                      `sqlx:"op_id"`
	Attempt                int                         `sqlx:"attempt"`
	ToolName               string                      `sqlx:"tool_name"`
	ToolKind               string                      `sqlx:"tool_kind"`
	Status                 string                      `sqlx:"status"`
	RequestHash            *string                     `sqlx:"request_hash"`
	ErrorCode              *string                     `sqlx:"error_code"`
	ErrorMessage           *string                     `sqlx:"error_message"`
	Retriable              *int                        `sqlx:"retriable"`
	StartedAt              *time.Time                  `sqlx:"started_at"`
	CompletedAt            *time.Time                  `sqlx:"completed_at"`
	LatencyMs              *int                        `sqlx:"latency_ms"`
	Cost                   *float64                    `sqlx:"cost"`
	TraceId                *string                     `sqlx:"trace_id"`
	SpanId                 *string                     `sqlx:"span_id"`
	RequestPayloadId       *string                     `sqlx:"request_payload_id"`
	ResponsePayloadId      *string                     `sqlx:"response_payload_id"`
	RunId                  *string                     `sqlx:"run_id"`
	Iteration              *int                        `sqlx:"iteration"`
	MessageRequestPayload  *ModelCallStreamPayloadView `view:",table=call_payload" on:"RequestPayloadId:request_payload_id=Id:id" sql:"uri=conversation/request_payload.sql"`
	MessageResponsePayload *ModelCallStreamPayloadView `view:",table=call_payload" on:"ResponsePayloadId:response_payload_id=Id:id" sql:"uri=conversation/response_payload.sql"`
}

type MessageView

type MessageView struct {
	Elicitation          Elicitation              `sqlx:"ELICITATION"`
	Id                   string                   `sqlx:"id"`
	ConversationId       string                   `sqlx:"conversation_id"`
	TurnId               *string                  `sqlx:"turn_id"`
	Archived             *int                     `sqlx:"archived"`
	Sequence             *int                     `sqlx:"sequence"`
	CreatedAt            time.Time                `sqlx:"created_at"`
	UpdatedAt            *time.Time               `sqlx:"updated_at"`
	CreatedByUserId      *string                  `sqlx:"created_by_user_id"`
	Status               *string                  `sqlx:"status"`
	Mode                 *string                  `sqlx:"mode"`
	Role                 string                   `sqlx:"role"`
	Type                 string                   `sqlx:"type"`
	Content              *string                  `sqlx:"content"`
	RawContent           *string                  `sqlx:"raw_content"`
	Summary              *string                  `sqlx:"summary"`
	ContextSummary       *string                  `sqlx:"context_summary"`
	Tags                 *string                  `sqlx:"tags"`
	Interim              int                      `sqlx:"interim"`
	ElicitationId        *string                  `sqlx:"elicitation_id"`
	ParentMessageId      *string                  `sqlx:"parent_message_id"`
	SupersededBy         *string                  `sqlx:"superseded_by"`
	LinkedConversationId *string                  `sqlx:"linked_conversation_id"`
	AttachmentPayloadId  *string                  `sqlx:"attachment_payload_id"`
	ElicitationPayloadId *string                  `sqlx:"elicitation_payload_id"`
	ToolName             *string                  `sqlx:"tool_name"`
	EmbeddingIndex       *string                  `sqlx:"embedding_index"`
	Narration            *string                  `sqlx:"preamble"`
	Iteration            *int                     `sqlx:"iteration"`
	Phase                *string                  `sqlx:"phase"`
	MessageToolCall      *MessageToolCallView     `view:",table=tool_call" on:"Id:m.id=MessageId:message_id" sql:"uri=conversation/tool_call.sql"`
	ToolMessage          []*ToolMessageView       `view:",table=message" on:"Id:id=ParentMessageId:m.parent_message_id" sql:"uri=conversation/tool_message.sql"`
	UserElicitationData  *UserElicitationDataView `view:",table=message" on:"Id:id=MessageId:m.id" sql:"uri=conversation/user_elicitation_data.sql"`
	LinkedConversation   *LinkedConversationView  `` /* 128-byte string literal not displayed */
	Attachment           []*AttachmentView        `view:",table=message" on:"Id:id=ParentMessageId:m.parent_message_id" sql:"uri=conversation/attachment.sql"`
	ModelCall            *ModelCallView           `view:",table=model_call" on:"Id:id=MessageId:message_id" sql:"uri=conversation/model_call.sql"`
}

type ModelCallStreamPayloadView

type ModelCallStreamPayloadView struct {
	Id          string  `sqlx:"id"`
	InlineBody  *string `sqlx:"inline_body"`
	Compression string  `sqlx:"compression"`
}

type ModelCallView

type ModelCallView struct {
	CompletedAt                        *time.Time                  `sqlx:"completed_at"`
	CompletionAcceptedPredictionTokens *int                        `sqlx:"completion_accepted_prediction_tokens"`
	CompletionAudioTokens              *int                        `sqlx:"completion_audio_tokens"`
	CompletionReasoningTokens          *int                        `sqlx:"completion_reasoning_tokens"`
	CompletionRejectedPredictionTokens *int                        `sqlx:"completion_rejected_prediction_tokens"`
	CompletionTokens                   *int                        `sqlx:"completion_tokens"`
	Cost                               *float64                    `sqlx:"cost"`
	ErrorCode                          *string                     `sqlx:"error_code"`
	ErrorMessage                       *string                     `sqlx:"error_message"`
	FinishReason                       *string                     `sqlx:"finish_reason"`
	Iteration                          *int                        `sqlx:"iteration"`
	LatencyMs                          *int                        `sqlx:"latency_ms"`
	MessageId                          string                      `sqlx:"message_id"`
	Model                              string                      `sqlx:"model"`
	ModelKind                          string                      `sqlx:"model_kind"`
	PromptAudioTokens                  *int                        `sqlx:"prompt_audio_tokens"`
	PromptCachedTokens                 *int                        `sqlx:"prompt_cached_tokens"`
	PromptTokens                       *int                        `sqlx:"prompt_tokens"`
	Provider                           string                      `sqlx:"provider"`
	ProviderRequestPayloadId           *string                     `sqlx:"provider_request_payload_id"`
	ProviderResponsePayloadId          *string                     `sqlx:"provider_response_payload_id"`
	RequestPayloadId                   *string                     `sqlx:"request_payload_id"`
	ResponsePayloadId                  *string                     `sqlx:"response_payload_id"`
	RunId                              *string                     `sqlx:"run_id"`
	SpanId                             *string                     `sqlx:"span_id"`
	StartedAt                          *time.Time                  `sqlx:"started_at"`
	Status                             string                      `sqlx:"status"`
	StreamPayloadId                    *string                     `sqlx:"stream_payload_id"`
	TotalTokens                        *int                        `sqlx:"total_tokens"`
	TraceId                            *string                     `sqlx:"trace_id"`
	TurnId                             *string                     `sqlx:"turn_id"`
	ModelCallRequestPayload            *ModelCallStreamPayloadView `` /* 127-byte string literal not displayed */
	ModelCallProviderRequestPayload    *ModelCallStreamPayloadView `` /* 153-byte string literal not displayed */
	ModelCallResponsePayload           *ModelCallStreamPayloadView `` /* 130-byte string literal not displayed */
	ModelCallProviderResponsePayload   *ModelCallStreamPayloadView `` /* 156-byte string literal not displayed */
	ToolCallLinks                      []*ToolCallLinksView        `view:",table=tool_call" on:"TraceId:trace_id=TraceId:trace_id" sql:"uri=conversation/tool_call_links.sql"`
	ModelCallStreamPayload             *ModelCallStreamPayloadView `view:",table=call_payload" on:"StreamPayloadId:stream_payload_id=Id:id" sql:"uri=conversation/model_call_stream_payload.sql"`
}

type ModelView

type ModelView struct {
	ConversationId                     string   `sqlx:"conversation_id"`
	Model                              string   `sqlx:"model"`
	PromptTokens                       *int     `sqlx:"prompt_tokens"`
	PromptCachedTokens                 *int     `sqlx:"prompt_cached_tokens"`
	PromptAudioTokens                  *int     `sqlx:"prompt_audio_tokens"`
	CompletionTokens                   *int     `sqlx:"completion_tokens"`
	CompletionReasoningTokens          *int     `sqlx:"completion_reasoning_tokens"`
	CompletionAudioTokens              *int     `sqlx:"completion_audio_tokens"`
	CompletionAcceptedPredictionTokens *int     `sqlx:"completion_accepted_prediction_tokens"`
	CompletionRejectedPredictionTokens *int     `sqlx:"completion_rejected_prediction_tokens"`
	TotalTokens                        *int     `sqlx:"total_tokens"`
	Cost                               *float64 `sqlx:"cost"`
}

type ToolCallLinksView

type ToolCallLinksView struct {
	MessageId string  `sqlx:"message_id"`
	OpId      string  `sqlx:"op_id"`
	TraceId   *string `sqlx:"trace_id"`
}

type ToolCallView

type ToolCallView struct {
	MessageSequence   *int                        `sqlx:"message_sequence" source:"sequence"`
	MessageId         string                      `sqlx:"message_id"`
	TurnId            *string                     `sqlx:"turn_id"`
	OpId              string                      `sqlx:"op_id"`
	Attempt           int                         `sqlx:"attempt"`
	ToolName          string                      `sqlx:"tool_name"`
	ToolKind          string                      `sqlx:"tool_kind"`
	Status            string                      `sqlx:"status"`
	RequestHash       *string                     `sqlx:"request_hash"`
	ErrorCode         *string                     `sqlx:"error_code"`
	ErrorMessage      *string                     `sqlx:"error_message"`
	Retriable         *int                        `sqlx:"retriable"`
	StartedAt         *time.Time                  `sqlx:"started_at"`
	CompletedAt       *time.Time                  `sqlx:"completed_at"`
	LatencyMs         *int                        `sqlx:"latency_ms"`
	Cost              *float64                    `sqlx:"cost"`
	TraceId           *string                     `sqlx:"trace_id"`
	SpanId            *string                     `sqlx:"span_id"`
	RequestPayloadId  *string                     `sqlx:"request_payload_id"`
	ResponsePayloadId *string                     `sqlx:"response_payload_id"`
	RunId             *string                     `sqlx:"run_id"`
	Iteration         *int                        `sqlx:"iteration"`
	RequestPayload    *ModelCallStreamPayloadView `view:",table=call_payload" on:"RequestPayloadId:request_payload_id=Id:id" sql:"uri=conversation/request_payload.sql"`
	ResponsePayload   *ModelCallStreamPayloadView `view:",table=call_payload" on:"ResponsePayloadId:response_payload_id=Id:id" sql:"uri=conversation/response_payload.sql"`
}

type ToolMessageView

type ToolMessageView struct {
	Id                   string        `sqlx:"id"`
	ParentMessageId      *string       `sqlx:"parent_message_id"`
	CreatedAt            time.Time     `sqlx:"created_at"`
	Sequence             *int          `sqlx:"sequence"`
	Type                 string        `sqlx:"type"`
	Content              *string       `sqlx:"content"`
	ToolName             *string       `sqlx:"tool_name"`
	Iteration            *int          `sqlx:"iteration"`
	LinkedConversationId *string       `sqlx:"linked_conversation_id"`
	ToolCall             *ToolCallView `view:",table=tool_call" on:"Id:m.id=MessageId:message_id" sql:"uri=conversation/tool_call.sql"`
}

type TranscriptView

type TranscriptView struct {
	ElapsedInSec          int            `sqlx:"elapsedInSec"`
	Stage                 string         `sqlx:"stage"`
	Id                    string         `sqlx:"id"`
	ConversationId        string         `sqlx:"conversation_id"`
	CreatedAt             time.Time      `sqlx:"created_at"`
	QueueSeq              *int           `sqlx:"queue_seq"`
	Origin                *string        `sqlx:"origin"`
	GoalID                *string        `sqlx:"goal_id"`
	StatusReason          *string        `sqlx:"status_reason"`
	Status                string         `sqlx:"status"`
	ErrorMessage          *string        `sqlx:"error_message"`
	StartedByMessageId    *string        `sqlx:"started_by_message_id"`
	RetryOf               *string        `sqlx:"retry_of"`
	AgentIdUsed           *string        `sqlx:"agent_id_used"`
	AgentConfigUsedId     *string        `sqlx:"agent_config_used_id"`
	ModelOverrideProvider *string        `sqlx:"model_override_provider"`
	ModelOverride         *string        `sqlx:"model_override"`
	ModelParamsOverride   *string        `sqlx:"model_params_override"`
	RunId                 *string        `sqlx:"run_id"`
	Message               []*MessageView `view:",table=message" on:"Id:id=TurnId:turn_id" sql:"uri=conversation/message.sql"`
}

func (*TranscriptView) OnRelation

func (t *TranscriptView) OnRelation(ctx context.Context)

OnRelation normalizes transcript messages and computes the turn stage.

type UsageView

type UsageView struct {
	ConversationId                     string       `sqlx:"conversation_id"`
	Cost                               *float64     `sqlx:"cost"`
	PromptTokens                       *int         `sqlx:"prompt_tokens"`
	PromptCachedTokens                 *int         `sqlx:"prompt_cached_tokens"`
	PromptAudioTokens                  *int         `sqlx:"prompt_audio_tokens"`
	CompletionTokens                   *int         `sqlx:"completion_tokens"`
	CompletionReasoningTokens          *int         `sqlx:"completion_reasoning_tokens"`
	CompletionAudioTokens              *int         `sqlx:"completion_audio_tokens"`
	CompletionAcceptedPredictionTokens *int         `sqlx:"completion_accepted_prediction_tokens"`
	CompletionRejectedPredictionTokens *int         `sqlx:"completion_rejected_prediction_tokens"`
	TotalTokens                        *int         `sqlx:"total_tokens"`
	Model                              []*ModelView `` /* 128-byte string literal not displayed */
}

type UserElicitationDataView

type UserElicitationDataView struct {
	InlineBody  *string `sqlx:"inline_body"`
	Compression string  `sqlx:"compression"`
	MessageId   string  `sqlx:"message_id" source:"id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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