Documentation
¶
Index ¶
- func ApplyChatRouteMetadata(metadata map[string]string, provider string, policy llmcore.RoutePolicy, ...) map[string]string
- func NormalizeEndpointMode(raw string) (string, *types.Error)
- func NormalizeProviderHint(raw string) (string, *types.Error)
- func NormalizeRouteMetadata(in map[string]string) map[string]string
- func NormalizeRoutePolicy(raw string) (llmcore.RoutePolicy, *types.Error)
- func NormalizeRouteTags(in []string) []string
- func SupportedRoutePolicies() []string
- func ToTypesAgentError(err error) *types.Error
- type AgentExecuteRequest
- type AgentExecuteResponse
- type AgentOperation
- type AgentResolver
- type AgentService
- type ChatCompletionResult
- type ChatConverter
- type ChatService
- type DefaultAgentService
- func (s *DefaultAgentService) ExecuteAgent(ctx context.Context, req AgentExecuteRequest, traceID string) (*AgentExecuteResponse, time.Duration, *types.Error)
- func (s *DefaultAgentService) ExecuteAgentStream(ctx context.Context, req AgentExecuteRequest, traceID string, ...) *types.Error
- func (s *DefaultAgentService) GetAgent(ctx context.Context, agentID string) (*discovery.AgentInfo, *types.Error)
- func (s *DefaultAgentService) ListAgents(ctx context.Context) ([]*discovery.AgentInfo, *types.Error)
- func (s *DefaultAgentService) PlanAgent(ctx context.Context, req AgentExecuteRequest, traceID string) (*agent.PlanResult, *types.Error)
- func (s *DefaultAgentService) ResolveForOperation(ctx context.Context, agentID string, op AgentOperation) (agent.Agent, *types.Error)
- type DefaultChatService
- func (s *DefaultChatService) Complete(ctx context.Context, req *api.ChatRequest) (*ChatCompletionResult, *types.Error)
- func (s *DefaultChatService) DefaultRoutePolicy() string
- func (s *DefaultChatService) Stream(ctx context.Context, req *api.ChatRequest) (<-chan llmcore.UnifiedChunk, *types.Error)
- func (s *DefaultChatService) SupportedRoutePolicies() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyChatRouteMetadata ¶
func ApplyChatRouteMetadata(metadata map[string]string, provider string, policy llmcore.RoutePolicy, endpointMode string) map[string]string
ApplyChatRouteMetadata merges provider, policy, and endpoint mode into metadata.
func NormalizeEndpointMode ¶
NormalizeEndpointMode validates and normalizes the endpoint mode.
func NormalizeProviderHint ¶
NormalizeProviderHint validates and normalizes the provider hint.
func NormalizeRouteMetadata ¶
NormalizeRouteMetadata trims metadata keys.
func NormalizeRoutePolicy ¶
func NormalizeRoutePolicy(raw string) (llmcore.RoutePolicy, *types.Error)
NormalizeRoutePolicy validates and normalizes the route policy.
func NormalizeRouteTags ¶
NormalizeRouteTags deduplicates and trims route tags.
func SupportedRoutePolicies ¶
func SupportedRoutePolicies() []string
SupportedRoutePolicies returns the list of valid route policy values.
func ToTypesAgentError ¶
ToTypesAgentError converts an error to *types.Error when needed.
Types ¶
type AgentExecuteRequest ¶
type AgentExecuteRequest struct {
AgentID string `json:"agent_id"`
Content string `json:"content"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
RoutePolicy string `json:"route_policy,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
Context map[string]any `json:"context,omitempty"`
Variables map[string]string `json:"variables,omitempty"`
}
AgentExecuteRequest is the request payload for agent execute/plan/stream operations.
type AgentExecuteResponse ¶
type AgentExecuteResponse struct {
TraceID string `json:"trace_id"`
Content string `json:"content"`
Metadata map[string]any `json:"metadata,omitempty"`
TokensUsed int `json:"tokens_used,omitempty"`
Cost float64 `json:"cost,omitempty"`
Duration string `json:"duration"`
FinishReason string `json:"finish_reason,omitempty"`
}
AgentExecuteResponse is the response payload for agent execute operations.
type AgentOperation ¶
type AgentOperation string
AgentOperation identifies the business intent for resolver fallback messages.
const ( AgentOperationExecute AgentOperation = "execution" AgentOperationStream AgentOperation = "streaming" AgentOperationPlan AgentOperation = "planning" )
type AgentResolver ¶
AgentResolver resolves an agent ID to a live Agent instance. This decouples the handler from how agents are stored/managed at runtime.
type AgentService ¶
type AgentService interface {
ResolveForOperation(ctx context.Context, agentID string, op AgentOperation) (agent.Agent, *types.Error)
ListAgents(ctx context.Context) ([]*discovery.AgentInfo, *types.Error)
GetAgent(ctx context.Context, agentID string) (*discovery.AgentInfo, *types.Error)
ExecuteAgent(ctx context.Context, req AgentExecuteRequest, traceID string) (*AgentExecuteResponse, time.Duration, *types.Error)
PlanAgent(ctx context.Context, req AgentExecuteRequest, traceID string) (*agent.PlanResult, *types.Error)
ExecuteAgentStream(ctx context.Context, req AgentExecuteRequest, traceID string, emitter agent.RuntimeStreamEmitter) *types.Error
}
AgentService encapsulates runtime agent resolution and endpoint availability checks.
type ChatCompletionResult ¶
type ChatCompletionResult struct {
Response *api.ChatResponse
Raw *llm.ChatResponse
Duration time.Duration
}
ChatCompletionResult captures completion output and execution metadata.
type ChatConverter ¶
type ChatConverter interface {
ToLLMRequest(req *api.ChatRequest) *llm.ChatRequest
ToAPIResponse(resp *llm.ChatResponse) *api.ChatResponse
}
ChatConverter centralizes request/response conversion between API and LLM layers. Implementations are provided by the handlers layer.
type ChatService ¶
type ChatService interface {
Complete(ctx context.Context, req *api.ChatRequest) (*ChatCompletionResult, *types.Error)
Stream(ctx context.Context, req *api.ChatRequest) (<-chan llmcore.UnifiedChunk, *types.Error)
SupportedRoutePolicies() []string
DefaultRoutePolicy() string
}
ChatService encapsulates chat routing and gateway invocation logic.
func NewDefaultChatService ¶
func NewDefaultChatService( gateway llmcore.Gateway, chatProvider llm.Provider, toolManager agent.ToolManager, converter ChatConverter, logger *zap.Logger, ) ChatService
NewDefaultChatService constructs a ChatService with gateway, provider, tool manager, and converter.
type DefaultAgentService ¶
type DefaultAgentService struct {
// contains filtered or unexported fields
}
DefaultAgentService is the default AgentService implementation used by AgentHandler.
func NewDefaultAgentService ¶
func NewDefaultAgentService(registry discovery.Registry, resolver AgentResolver) *DefaultAgentService
NewDefaultAgentService constructs a service with resolver+registry fallback strategy.
func (*DefaultAgentService) ExecuteAgent ¶
func (s *DefaultAgentService) ExecuteAgent(ctx context.Context, req AgentExecuteRequest, traceID string) (*AgentExecuteResponse, time.Duration, *types.Error)
func (*DefaultAgentService) ExecuteAgentStream ¶
func (s *DefaultAgentService) ExecuteAgentStream(ctx context.Context, req AgentExecuteRequest, traceID string, emitter agent.RuntimeStreamEmitter) *types.Error
func (*DefaultAgentService) ListAgents ¶
func (*DefaultAgentService) PlanAgent ¶
func (s *DefaultAgentService) PlanAgent(ctx context.Context, req AgentExecuteRequest, traceID string) (*agent.PlanResult, *types.Error)
func (*DefaultAgentService) ResolveForOperation ¶
func (s *DefaultAgentService) ResolveForOperation(ctx context.Context, agentID string, op AgentOperation) (agent.Agent, *types.Error)
ResolveForOperation resolves an agent for execute/stream/plan operations.
type DefaultChatService ¶
type DefaultChatService struct {
// contains filtered or unexported fields
}
DefaultChatService is the default ChatService implementation.
func (*DefaultChatService) Complete ¶
func (s *DefaultChatService) Complete(ctx context.Context, req *api.ChatRequest) (*ChatCompletionResult, *types.Error)
func (*DefaultChatService) DefaultRoutePolicy ¶
func (s *DefaultChatService) DefaultRoutePolicy() string
func (*DefaultChatService) Stream ¶
func (s *DefaultChatService) Stream(ctx context.Context, req *api.ChatRequest) (<-chan llmcore.UnifiedChunk, *types.Error)
func (*DefaultChatService) SupportedRoutePolicies ¶
func (s *DefaultChatService) SupportedRoutePolicies() []string