server

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletionRequest

type CompletionRequest = serverbase.CompletionRequest

Re-export types from serverbase for backward compatibility

type MemoryResponse

type MemoryResponse = serverbase.MemoryResponse

Re-export types from serverbase for backward compatibility

type OperationRequest

type OperationRequest = serverbase.OperationRequest

Re-export types from serverbase for backward compatibility

type PendingOperation

type PendingOperation = serverbase.PendingOperation

Re-export types from serverbase for backward compatibility

type ServerAgent

type ServerAgent struct {
	*serverbase.BaseServerAgent
	// contains filtered or unexported fields
}

ServerAgent wraps BaseServerAgent with chat-specific functionality

func NewAgent

func NewAgent(
	ctx context.Context,
	agentConfig agents.Config,
	modelConfig models.Config,
	port string,
	executeFn func(string, string) (string, error),
) (*ServerAgent, error)

NewAgent creates a new server agent

func (*ServerAgent) AddMessage

func (agent *ServerAgent) AddMessage(role roles.Role, content string)

AddMessage adds a message to the conversation history

func (*ServerAgent) CompressChatAgentContext added in v0.0.8

func (agent *ServerAgent) CompressChatAgentContext() (int, error)

CompressChatAgentContext compresses the chat agent context.

func (*ServerAgent) CompressChatAgentContextIfOverLimit added in v0.0.8

func (agent *ServerAgent) CompressChatAgentContextIfOverLimit() (int, error)

CompressChatAgentContextIfOverLimit compresses the chat agent context if it exceeds the size limit.

func (*ServerAgent) ExportMessagesToJSON

func (agent *ServerAgent) ExportMessagesToJSON() (string, error)

ExportMessagesToJSON exports the conversation history to JSON

func (*ServerAgent) GenerateCompletion

func (agent *ServerAgent) GenerateCompletion(userMessages []messages.Message) (*chat.CompletionResult, error)

GenerateCompletion sends messages and returns the completion result

func (*ServerAgent) GenerateCompletionWithReasoning

func (agent *ServerAgent) GenerateCompletionWithReasoning(userMessages []messages.Message) (*chat.ReasoningResult, error)

GenerateCompletionWithReasoning sends messages and returns the completion result with reasoning

func (*ServerAgent) GenerateStreamCompletion

func (agent *ServerAgent) GenerateStreamCompletion(
	userMessages []messages.Message,
	callback chat.StreamCallback,
) (*chat.CompletionResult, error)

GenerateStreamCompletion sends messages and streams the response via callback

func (*ServerAgent) GenerateStreamCompletionWithReasoning

func (agent *ServerAgent) GenerateStreamCompletionWithReasoning(
	userMessages []messages.Message,
	reasoningCallback chat.StreamCallback,
	responseCallback chat.StreamCallback,
) (*chat.ReasoningResult, error)

GenerateStreamCompletionWithReasoning sends messages and streams both reasoning and response

func (*ServerAgent) GetCompressorAgent added in v0.0.8

func (agent *ServerAgent) GetCompressorAgent() *compressor.Agent

GetCompressorAgent returns the compressor agent

func (*ServerAgent) GetContextSize

func (agent *ServerAgent) GetContextSize() int

GetContextSize returns the approximate size of the current context

func (*ServerAgent) GetContextSizeLimit added in v0.0.8

func (agent *ServerAgent) GetContextSizeLimit() int

GetContextSizeLimit returns the context size limit for compression

func (*ServerAgent) GetMaxSimilarities added in v0.0.8

func (agent *ServerAgent) GetMaxSimilarities() int

GetMaxSimilarities returns the maximum number of similar documents to retrieve

func (*ServerAgent) GetMessages

func (agent *ServerAgent) GetMessages() []messages.Message

GetMessages returns all conversation messages

func (*ServerAgent) GetModelID

func (agent *ServerAgent) GetModelID() string

GetModelID returns the model ID

func (*ServerAgent) GetName

func (agent *ServerAgent) GetName() string

GetName returns the agent name

func (*ServerAgent) GetPort

func (agent *ServerAgent) GetPort() string

GetPort returns the HTTP port

func (*ServerAgent) GetRagAgent added in v0.0.8

func (agent *ServerAgent) GetRagAgent() *rag.Agent

GetRagAgent returns the RAG agent

func (*ServerAgent) GetSimilarityLimit added in v0.0.8

func (agent *ServerAgent) GetSimilarityLimit() float64

GetSimilarityLimit returns the similarity limit for document retrieval

func (*ServerAgent) GetToolsAgent

func (agent *ServerAgent) GetToolsAgent() *tools.Agent

GetToolsAgent returns the tools agent

func (*ServerAgent) Kind

func (agent *ServerAgent) Kind() agents.Kind

Kind returns the agent type

func (*ServerAgent) ResetMessages

func (agent *ServerAgent) ResetMessages()

ResetMessages clears all messages except the system instruction

func (*ServerAgent) SetCompressorAgent added in v0.0.8

func (agent *ServerAgent) SetCompressorAgent(compressorAgent *compressor.Agent)

SetCompressorAgent sets the compressor agent

func (*ServerAgent) SetContextSizeLimit added in v0.0.8

func (agent *ServerAgent) SetContextSizeLimit(limit int)

SetContextSizeLimit sets the context size limit for compression

func (*ServerAgent) SetExecuteFunction

func (agent *ServerAgent) SetExecuteFunction(fn func(string, string) (string, error))

SetExecuteFunction allows the user to set a custom execute function

func (*ServerAgent) SetMaxSimilarities added in v0.0.8

func (agent *ServerAgent) SetMaxSimilarities(n int)

SetMaxSimilarities sets the maximum number of similar documents to retrieve

func (*ServerAgent) SetPort

func (agent *ServerAgent) SetPort(port string)

SetPort sets the HTTP port

func (*ServerAgent) SetRagAgent added in v0.0.8

func (agent *ServerAgent) SetRagAgent(ragAgent *rag.Agent)

SetRagAgent sets the RAG agent

func (*ServerAgent) SetSimilarityLimit added in v0.0.8

func (agent *ServerAgent) SetSimilarityLimit(limit float64)

SetSimilarityLimit sets the similarity limit for document retrieval

func (*ServerAgent) SetToolsAgent

func (agent *ServerAgent) SetToolsAgent(toolsAgent *tools.Agent)

SetToolsAgent sets the tools agent

func (*ServerAgent) StartServer

func (agent *ServerAgent) StartServer() error

StartServer starts the HTTP server with all routes

func (*ServerAgent) StopStream

func (agent *ServerAgent) StopStream()

StopStream interrupts the current streaming operation

type TokensResponse

type TokensResponse = serverbase.TokensResponse

Re-export types from serverbase for backward compatibility

type ToolCallNotification

type ToolCallNotification = serverbase.ToolCallNotification

Re-export types from serverbase for backward compatibility

Jump to

Keyboard shortcuts

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