- Upgraded Go version to 1.25 and updated several dependencies, including `testify` to v1.11.1 and added new indirect dependencies for JSON schema validation. - Refactored the assistant's context management to utilize a new `context.Uses` structure, improving the handling of vision, audio, search, and fetch configurations. - Enhanced the assistant's request building process to support new response formats, including JSON schema validation, ensuring better integration with various tools and services.
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package context
|
|
|
|
import "net/http"
|
|
|
|
// StreamChunkType represents the type of content in a streaming chunk
|
|
type StreamChunkType string
|
|
|
|
// Stream chunk type constants - indicates what type of content is in the current chunk
|
|
const (
|
|
ChunkText StreamChunkType = "text" // Regular text content
|
|
ChunkThinking StreamChunkType = "thinking" // Reasoning/thinking content (o1, DeepSeek R1)
|
|
ChunkToolCall StreamChunkType = "tool_call" // Tool/function call
|
|
ChunkRefusal StreamChunkType = "refusal" // Model refusal
|
|
ChunkMetadata StreamChunkType = "metadata" // Metadata (usage, finish_reason, etc.)
|
|
ChunkError StreamChunkType = "error" // Error chunk
|
|
ChunkUnknown StreamChunkType = "unknown" // Unknown/unrecognized chunk type
|
|
)
|
|
|
|
// StreamFunc the streaming function callback
|
|
// Parameters:
|
|
// - chunkType: the type of content in this chunk (text, thinking, tool_call, etc.)
|
|
// - data: the actual chunk data (could be text, JSON, or other format)
|
|
//
|
|
// Returns:
|
|
// - int: status code (0 = continue, non-zero = stop streaming)
|
|
type StreamFunc func(chunkType StreamChunkType, data []byte) int
|
|
|
|
// Writer is an alias for http.ResponseWriter interface used by an agent to construct a response.
|
|
// A Writer may not be used after the agent execution has completed.
|
|
type Writer = http.ResponseWriter
|
|
|
|
// Agent the agent interface
|
|
type Agent interface {
|
|
|
|
// Stream stream the agent
|
|
Stream(ctx *Context, messages []Message, handler StreamFunc) error
|
|
|
|
// Run run the agent
|
|
Run(ctx *Context, messages []Message) (*Response, error)
|
|
}
|