streaming

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ConversationIDProp = "conversation_id"
View Source
const LLMRequesterUserIDProp = "llm_requester_user_id"

LLMRequesterUserIDProp is a compatibility bridge for the meeting summarization flow, which still produces custom_llmbot posts without a conversation entity. Ownership for conversation-backed posts should be resolved via ConversationIDProp and the conversation row's UserID; this prop should only be consulted as a fallback when no conversation_id is present. Remove once meeting flows migrate.

View Source
const NoRegen = "no_regen"
View Source
const PostStreamingControlCancel = "cancel"
View Source
const PostStreamingControlContinue = "continue"

PostStreamingControlContinue signals a tool-approval resume stream onto a post that already has content. The webapp clears the visible message but keeps the resolved tool cards.

View Source
const PostStreamingControlEnd = "end"
View Source
const PostStreamingControlStart = "start"
View Source
const RespondingToProp = "responding_to"
View Source
const UnsafeLinksPostProp = "unsafe_links"
View Source
const WebSearchContextProp = "web_search_context"

WebSearchContextProp is still read by conversations/web_search_context.go when extracting web search state from legacy thread posts.

Variables

View Source
var ErrAlreadyStreamingToPost = fmt.Errorf("already streaming to post")

Functions

func ModifyPostForBot

func ModifyPostForBot(botid string, requesterUserID string, post *model.Post, respondingToPostID string)

ModifyPostForBot modifies a post to add bot-specific properties

Types

type Client

type Client interface {
	PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
	UpdatePost(post *model.Post) error
	CreatePost(post *model.Post) error
	DM(senderID, receiverID string, post *model.Post) error
	GetUser(userID string) (*model.User, error)
	GetChannel(channelID string) (*model.Channel, error)
	GetConfig() *model.Config
	KVSet(key string, value interface{}) error
	LogError(msg string, keyValuePairs ...interface{})
	LogDebug(msg string, keyValuePairs ...interface{})
}

Client defines the minimal client interface needed for streaming operations.

type MMPostStreamService

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

func NewMMPostStreamService

func NewMMPostStreamService(mmClient Client, i18n *i18n.Bundle) *MMPostStreamService

func (*MMPostStreamService) FinishStreaming

func (p *MMPostStreamService) FinishStreaming(postID string)

FinishStreaming should be called when a post streaming operation is finished on success or failure. It is safe to call multiple times, must be called at least once.

func (*MMPostStreamService) GetStreamingContext

func (p *MMPostStreamService) GetStreamingContext(inCtx context.Context, postID string) (context.Context, error)

func (*MMPostStreamService) SetTurnStore

func (p *MMPostStreamService) SetTurnStore(ts TurnStore)

SetTurnStore sets the store used for persisting assistant turns. When nil (the default), turn persistence is silently skipped.

func (*MMPostStreamService) StopStreaming

func (p *MMPostStreamService) StopStreaming(postID string)

func (*MMPostStreamService) StreamContinuationToPost

func (p *MMPostStreamService) StreamContinuationToPost(ctx context.Context, stream *llm.TextStreamResult, post *model.Post, userLocale string, requesterUserID string)

func (*MMPostStreamService) StreamToNewDM

func (p *MMPostStreamService) StreamToNewDM(ctx context.Context, botID string, stream *llm.TextStreamResult, userID string, post *model.Post, respondingToPostID string) error

func (*MMPostStreamService) StreamToNewPost

func (p *MMPostStreamService) StreamToNewPost(ctx context.Context, botID string, requesterUserID string, stream *llm.TextStreamResult, post *model.Post, respondingToPostID string) error

func (*MMPostStreamService) StreamToPost

func (p *MMPostStreamService) StreamToPost(ctx context.Context, stream *llm.TextStreamResult, post *model.Post, userLocale string, requesterUserID string)

StreamToPost streams a fresh response onto a post (first stream or regen, where the caller has already scrubbed prior turns). For tool-approval resume use StreamContinuationToPost.

type Service

type Service interface {
	StreamToNewPost(ctx context.Context, botID string, requesterUserID string, stream *llm.TextStreamResult, post *model.Post, respondingToPostID string) error
	StreamToNewDM(ctx context.Context, botID string, stream *llm.TextStreamResult, userID string, post *model.Post, respondingToPostID string) error
	StreamToPost(ctx context.Context, stream *llm.TextStreamResult, post *model.Post, userLocale string, requesterUserID string)

	// StreamContinuationToPost streams a follow-up round onto a post that
	// already has an assistant turn (tool-approval resume). Finalize demotes
	// the prior anchor so both rounds render. Do not use for regeneration.
	StreamContinuationToPost(ctx context.Context, stream *llm.TextStreamResult, post *model.Post, userLocale string, requesterUserID string)

	StopStreaming(postID string)
	GetStreamingContext(inCtx context.Context, postID string) (context.Context, error)
	FinishStreaming(postID string)
}

type TurnStore

type TurnStore interface {
	CreateTurnAutoSequence(turn *store.Turn) error
	GetTurnByPostID(postID string) (*store.Turn, error)
	UpdateTurnPostID(id string, postID *string) error
}

TurnStore is the subset of store operations needed by the streaming layer. Finalize either creates a fresh anchor (first stream / regen, with the caller having scrubbed any prior turns) or demotes the existing anchor and creates a new one (continuation).

Jump to

Keyboard shortcuts

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