chatservice

package
v0.0.68 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenAIChatStreamChunk added in v0.0.64

type OpenAIChatStreamChunk struct {
	ID      string               `json:"id" example:"chatcmpl-123"`
	Object  string               `json:"object" example:"chat.completion.chunk"`
	Created int64                `json:"created" example:"1694268190"`
	Model   string               `json:"model" example:"mistral:instruct"`
	Choices []OpenAIStreamChoice `json:"choices" openapi_include_type:"chatservice.OpenAIStreamChoice"`
}

OpenAIChatStreamChunk represents a single chunk of data in an SSE stream for an OpenAI-compatible chat completion.

type OpenAIStreamChoice added in v0.0.64

type OpenAIStreamChoice struct {
	Index        int               `json:"index" example:"0"`
	Delta        OpenAIStreamDelta `json:"delta" openapi_include_type:"chatservice.OpenAIStreamDelta"`
	FinishReason *string           `json:"finish_reason,omitempty" example:"stop"`
}

OpenAIStreamChoice represents a choice within a stream chunk. It contains the delta, which is the actual content being streamed.

type OpenAIStreamDelta added in v0.0.64

type OpenAIStreamDelta struct {
	// The role of the author of this message.
	Role string `json:"role,omitempty" example:"assistant"`
	// The contents of the chunk.
	Content string `json:"content,omitempty" example:" world"`
}

OpenAIStreamDelta contains the incremental content update (the "delta") for a streaming chat response.

type Service

type Service interface {
	OpenAIChatCompletions(ctx context.Context, taskChainID string, req taskengine.OpenAIChatRequest) (*taskengine.OpenAIChatResponse, []taskengine.CapturedStateUnit, error)
	OpenAIChatCompletionsStream(ctx context.Context, taskChainID string, req taskengine.OpenAIChatRequest, speed time.Duration) (<-chan OpenAIChatStreamChunk, error)
}

func New

func WithActivityTracker

func WithActivityTracker(service Service, tracker libtracker.ActivityTracker) Service

WithActivityTracker creates a new decorated service that tracks activity

Jump to

Keyboard shortcuts

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