chatservice

package
v0.0.74 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"`
	ToolCalls []OpenAIStreamToolCall `json:"tool_calls,omitempty"`
}

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

type OpenAIStreamFunctionCall added in v0.0.69

type OpenAIStreamFunctionCall struct {
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

OpenAIStreamFunctionCall represents function details within a tool call stream chunk.

type OpenAIStreamToolCall added in v0.0.69

type OpenAIStreamToolCall struct {
	Index    int                       `json:"index"`
	ID       string                    `json:"id,omitempty"`
	Type     string                    `json:"type,omitempty"`
	Function *OpenAIStreamFunctionCall `json:"function,omitempty"`
}

OpenAIStreamToolCall represents a tool call within a stream chunk.

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