Documentation
¶
Index ¶
- func CORSMiddleware(cfg CORSConfig) gin.HandlerFunc
- func CachingMiddleware() gin.HandlerFunc
- func CompressionMiddleware() gin.HandlerFunc
- func ErrorHandlerMiddleware() gin.HandlerFunc
- func MetricsMiddleware() gin.HandlerFunc
- func RateLimiter(cfg RateLimiterConfig) gin.HandlerFunc
- func RegisterShutdownHook(hook func())
- func RequestLogger() gin.HandlerFunc
- func RouteToVersion(c *gin.Context, handlers map[APIVersion]gin.HandlerFunc)
- func SetupMetricsHandler() gin.HandlerFunc
- func VersioningMiddleware(config VersioningConfig) gin.HandlerFunc
- type APIError
- func HandleValidationErrors(err error) *APIError
- func NewAPIError(code ErrorCode, message string, httpCode int, err error) *APIError
- func NewBadRequestError(message string, err error) *APIError
- func NewContextNotFoundError(contextID string, err error) *APIError
- func NewForbiddenError(message string, err error) *APIError
- func NewInternalServerError(message string, err error) *APIError
- func NewNotFoundError(message string, err error) *APIError
- func NewUnauthorizedError(message string, err error) *APIError
- func NewValidationError(message string, details interface{}) *APIError
- type APIVersion
- type AgentAPI
- type AuthConfig
- type CORSConfig
- type Config
- type ContextManagerInterface
- type CrossModelSearchRequest
- type CrossModelSearchResult
- type Embedding
- type EmbeddingAPIV2
- func (api *EmbeddingAPIV2) BatchGenerateEmbeddings(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) CreateAgentConfig(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) CrossModelSearch(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) GenerateEmbedding(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) GetAgentConfig(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) GetAgentCosts(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) GetAgentModels(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) GetProviderHealth(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) RegisterRoutes(router *mux.Router)
- func (api *EmbeddingAPIV2) SearchEmbeddings(w http.ResponseWriter, r *http.Request)
- func (api *EmbeddingAPIV2) UpdateAgentConfig(w http.ResponseWriter, r *http.Request)
- type EmbeddingRepositoryInterface
- type EmbeddingSearchRequest
- type ErrorCode
- type ErrorResponse
- type MCPAPI
- type ModelAPI
- type PerformanceConfig
- type RateLimitConfig
- type RateLimiterConfig
- type SearchByVectorRequest
- type SearchEmbeddingsRequest
- type SearchHandler
- func (h *SearchHandler) HandleSearch(w http.ResponseWriter, r *http.Request)
- func (h *SearchHandler) HandleSearchByVector(w http.ResponseWriter, r *http.Request)
- func (h *SearchHandler) HandleSearchSimilar(w http.ResponseWriter, r *http.Request)
- func (h *SearchHandler) RegisterRoutes(router *http.ServeMux)
- type SearchRequest
- type SearchResponse
- type SearchResult
- type Server
- func (s *Server) Initialize(ctx context.Context) error
- func (s *Server) RegisterWebhookRoutes(router *mux.Router)
- func (s *Server) SetupVectorAPI(ctx context.Context) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start() error
- func (s *Server) StartTLS(certFile, keyFile string) error
- type StoreEmbeddingRequest
- type ToolAPI
- type VectorAPI
- type VectorDatabaseAdapter
- func (a *VectorDatabaseAdapter) BatchDeleteEmbeddings(ctx context.Context, contentType, contentID, contextID string) (int, error)
- func (a *VectorDatabaseAdapter) Close() error
- func (a *VectorDatabaseAdapter) DeleteEmbedding(ctx context.Context, id string) error
- func (a *VectorDatabaseAdapter) EnsureSchema(ctx context.Context) error
- func (a *VectorDatabaseAdapter) GetEmbeddingByID(ctx context.Context, id string) (*Embedding, error)
- func (a *VectorDatabaseAdapter) Initialize(ctx context.Context) error
- func (a *VectorDatabaseAdapter) SearchEmbeddings(ctx context.Context, queryVector []float32, contextID string, modelID string, ...) ([]*Embedding, error)
- func (a *VectorDatabaseAdapter) StoreEmbedding(ctx context.Context, embedding *Embedding) error
- func (a *VectorDatabaseAdapter) Transaction(ctx context.Context, fn func(tx *sqlx.Tx) error) error
- type VersionedHandlers
- type VersioningConfig
- type WebhookProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶
func CORSMiddleware(cfg CORSConfig) gin.HandlerFunc
CORSMiddleware adds CORS headers to responses
func CachingMiddleware ¶
func CachingMiddleware() gin.HandlerFunc
CachingMiddleware adds HTTP caching headers
func CompressionMiddleware ¶
func CompressionMiddleware() gin.HandlerFunc
CompressionMiddleware adds gzip compression to responses
func ErrorHandlerMiddleware ¶
func ErrorHandlerMiddleware() gin.HandlerFunc
ErrorHandlerMiddleware catches and formats errors consistently
func MetricsMiddleware ¶
func MetricsMiddleware() gin.HandlerFunc
MetricsMiddleware collects API metrics
func RateLimiter ¶
func RateLimiter(cfg RateLimiterConfig) gin.HandlerFunc
RateLimiter middleware implements rate limiting per IP address
func RegisterShutdownHook ¶
func RegisterShutdownHook(hook func())
RegisterShutdownHook registers a function to be called during server shutdown
func RequestLogger ¶
func RequestLogger() gin.HandlerFunc
RequestLogger middleware logs HTTP requests
func RouteToVersion ¶
func RouteToVersion(c *gin.Context, handlers map[APIVersion]gin.HandlerFunc)
RouteToVersion routes requests to the appropriate version handler
func SetupMetricsHandler ¶
func SetupMetricsHandler() gin.HandlerFunc
SetupMetricsHandler sets up the Prometheus metrics handler
func VersioningMiddleware ¶
func VersioningMiddleware(config VersioningConfig) gin.HandlerFunc
VersioningMiddleware adds API versioning support
Types ¶
type APIError ¶
APIError represents an API error with associated metadata
func HandleValidationErrors ¶
HandleValidationErrors converts field validation errors to a standardized format
func NewAPIError ¶
NewAPIError creates a new API error
func NewBadRequestError ¶
NewBadRequestError creates a bad request error
func NewContextNotFoundError ¶
NewContextNotFoundError creates a context not found error
func NewForbiddenError ¶
NewForbiddenError creates a forbidden error
func NewInternalServerError ¶
NewInternalServerError creates an internal server error
func NewNotFoundError ¶
NewNotFoundError creates a not found error
func NewUnauthorizedError ¶
NewUnauthorizedError creates an unauthorized error
func NewValidationError ¶
NewValidationError creates a validation error
func (*APIError) WithDetails ¶
WithDetails adds details to the error
type APIVersion ¶
type APIVersion string
APIVersion represents a specific API version
const ( APIVersionUnspecified APIVersion = "" APIVersionV1 APIVersion = "v1" APIVersionV2 APIVersion = "v2" )
Supported API versions
func GetAPIVersion ¶
func GetAPIVersion(c *gin.Context) APIVersion
GetAPIVersion returns the API version from the context
type AgentAPI ¶
type AgentAPI struct {
// contains filtered or unexported fields
}
AgentAPI handles agent management endpoints Implements tenant-scoped CRUD operations for agents using the repository pattern.
func NewAgentAPI ¶
func NewAgentAPI(repo repository.AgentRepository) *AgentAPI
func (*AgentAPI) RegisterRoutes ¶
func (a *AgentAPI) RegisterRoutes(router *gin.RouterGroup)
RegisterRoutes registers agent endpoints under /agents
type AuthConfig ¶
type AuthConfig struct {
JWTSecret string `mapstructure:"jwt_secret"`
APIKeys interface{} `mapstructure:"api_keys"`
}
AuthConfig holds authentication configuration
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string
AllowedMethods []string
AllowedHeaders []string
ExposedHeaders []string
AllowCredentials bool
MaxAge int
}
CORSConfig holds CORS configuration
type Config ¶
type Config struct {
ListenAddress string `mapstructure:"listen_address"`
ReadTimeout time.Duration `mapstructure:"read_timeout"`
WriteTimeout time.Duration `mapstructure:"write_timeout"`
IdleTimeout time.Duration `mapstructure:"idle_timeout"`
EnableCORS bool `mapstructure:"enable_cors"`
EnableSwagger bool `mapstructure:"enable_swagger"`
TLS *securitytls.Config `mapstructure:"tls"` // TLS configuration
Auth AuthConfig `mapstructure:"auth"`
RateLimit RateLimitConfig `mapstructure:"rate_limit"`
Versioning VersioningConfig `mapstructure:"versioning"`
Performance PerformanceConfig `mapstructure:"performance"`
Webhook interfaces.WebhookConfig `mapstructure:"webhook"`
}
Config holds configuration for the API server
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults
type ContextManagerInterface ¶
type ContextManagerInterface interface {
CreateContext(ctx context.Context, context *models.Context) (*models.Context, error)
GetContext(ctx context.Context, contextID string) (*models.Context, error)
UpdateContext(ctx context.Context, contextID string, context *models.Context, options *models.ContextUpdateOptions) (*models.Context, error)
DeleteContext(ctx context.Context, contextID string) error
ListContexts(ctx context.Context, agentID, sessionID string, options map[string]interface{}) ([]*models.Context, error)
SearchInContext(ctx context.Context, contextID, query string) ([]models.ContextItem, error)
SummarizeContext(ctx context.Context, contextID string) (string, error)
}
ContextManagerInterface defines the interface for context management
type CrossModelSearchRequest ¶
type CrossModelSearchRequest struct {
Query string `json:"query" validate:"required"`
SearchModel string `json:"search_model,omitempty"`
IncludeModels []string `json:"include_models,omitempty"`
ExcludeModels []string `json:"exclude_models,omitempty"`
Limit int `json:"limit,omitempty"`
MinSimilarity float64 `json:"min_similarity,omitempty"`
MetadataFilter map[string]interface{} `json:"metadata_filter,omitempty"`
}
type CrossModelSearchResult ¶
type Embedding ¶
type Embedding struct {
ID string `json:"id" db:"id"`
Vector []float32 `json:"vector" db:"vector"`
Dimensions int `json:"dimensions" db:"dimensions"`
ModelID string `json:"model_id" db:"model_id"`
ContentType string `json:"content_type" db:"content_type"`
ContentID string `json:"content_id" db:"content_id"`
Namespace string `json:"namespace" db:"namespace"`
ContextID string `json:"context_id" db:"context_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
Metadata map[string]interface{} `json:"metadata" db:"metadata"`
Similarity float64 `json:"similarity" db:"similarity"`
}
Embedding represents a vector embedding in the internal database model format This struct mirrors the internal/database.Embedding struct to avoid importing it directly
type EmbeddingAPIV2 ¶
type EmbeddingAPIV2 struct {
// contains filtered or unexported fields
}
EmbeddingAPIV2 handles embedding API requests for multi-agent system
func NewEmbeddingAPIV2 ¶
func NewEmbeddingAPIV2(embeddingService *embedding.ServiceV2, agentService embedding.AgentService) *EmbeddingAPIV2
NewEmbeddingAPIV2 creates a new embedding API handler
func (*EmbeddingAPIV2) BatchGenerateEmbeddings ¶
func (api *EmbeddingAPIV2) BatchGenerateEmbeddings(w http.ResponseWriter, r *http.Request)
BatchGenerateEmbeddings handles POST /api/v2/embeddings/batch
func (*EmbeddingAPIV2) CreateAgentConfig ¶
func (api *EmbeddingAPIV2) CreateAgentConfig(w http.ResponseWriter, r *http.Request)
CreateAgentConfig handles POST /api/v2/embeddings/agents
func (*EmbeddingAPIV2) CrossModelSearch ¶
func (api *EmbeddingAPIV2) CrossModelSearch(w http.ResponseWriter, r *http.Request)
CrossModelSearch handles POST /api/v2/embeddings/search/cross-model
func (*EmbeddingAPIV2) GenerateEmbedding ¶
func (api *EmbeddingAPIV2) GenerateEmbedding(w http.ResponseWriter, r *http.Request)
GenerateEmbedding handles POST /api/v2/embeddings
func (*EmbeddingAPIV2) GetAgentConfig ¶
func (api *EmbeddingAPIV2) GetAgentConfig(w http.ResponseWriter, r *http.Request)
GetAgentConfig handles GET /api/v2/embeddings/agents/{agentId}
func (*EmbeddingAPIV2) GetAgentCosts ¶
func (api *EmbeddingAPIV2) GetAgentCosts(w http.ResponseWriter, r *http.Request)
GetAgentCosts handles GET /api/v2/embeddings/agents/{agentId}/costs
func (*EmbeddingAPIV2) GetAgentModels ¶
func (api *EmbeddingAPIV2) GetAgentModels(w http.ResponseWriter, r *http.Request)
GetAgentModels handles GET /api/v2/embeddings/agents/{agentId}/models
func (*EmbeddingAPIV2) GetProviderHealth ¶
func (api *EmbeddingAPIV2) GetProviderHealth(w http.ResponseWriter, r *http.Request)
GetProviderHealth handles GET /api/v2/embeddings/providers/health
func (*EmbeddingAPIV2) RegisterRoutes ¶
func (api *EmbeddingAPIV2) RegisterRoutes(router *mux.Router)
RegisterRoutes registers embedding API routes
func (*EmbeddingAPIV2) SearchEmbeddings ¶
func (api *EmbeddingAPIV2) SearchEmbeddings(w http.ResponseWriter, r *http.Request)
SearchEmbeddings handles POST /api/v2/embeddings/search
func (*EmbeddingAPIV2) UpdateAgentConfig ¶
func (api *EmbeddingAPIV2) UpdateAgentConfig(w http.ResponseWriter, r *http.Request)
UpdateAgentConfig handles PUT /api/v2/embeddings/agents/{agentId}
type EmbeddingRepositoryInterface ¶
type EmbeddingRepositoryInterface interface {
StoreEmbedding(ctx context.Context, embedding *repository.Embedding) error
SearchEmbeddings(ctx context.Context, queryVector []float32, contextID string, modelID string, limit int, similarityThreshold float64) ([]*repository.Embedding, error)
SearchEmbeddings_Legacy(ctx context.Context, queryVector []float32, contextID string, limit int) ([]*repository.Embedding, error)
GetContextEmbeddings(ctx context.Context, contextID string) ([]*repository.Embedding, error)
DeleteContextEmbeddings(ctx context.Context, contextID string) error
GetEmbeddingsByModel(ctx context.Context, contextID string, modelID string) ([]*repository.Embedding, error)
GetSupportedModels(ctx context.Context) ([]string, error)
DeleteModelEmbeddings(ctx context.Context, contextID string, modelID string) error
}
EmbeddingRepositoryInterface defines the interface for embedding repository operations
type EmbeddingSearchRequest ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode represents a standardized error code
const ( // General errors ErrBadRequest ErrorCode = "BAD_REQUEST" ErrForbidden ErrorCode = "FORBIDDEN" ErrNotFound ErrorCode = "NOT_FOUND" ErrMethodNotAllowed ErrorCode = "METHOD_NOT_ALLOWED" ErrConflict ErrorCode = "CONFLICT" ErrTooManyRequests ErrorCode = "TOO_MANY_REQUESTS" ErrInternalServer ErrorCode = "INTERNAL_SERVER_ERROR" // Domain-specific errors ErrContextNotFound ErrorCode = "CONTEXT_NOT_FOUND" ErrContextTooLarge ErrorCode = "CONTEXT_TOO_LARGE" ErrContextInvalid ErrorCode = "CONTEXT_INVALID" // Vector/embedding errors ErrEmbeddingFailed ErrorCode = "EMBEDDING_FAILED" ErrEmbeddingInvalid ErrorCode = "EMBEDDING_INVALID" // Tool-specific errors ErrToolNotFound ErrorCode = "TOOL_NOT_FOUND" ErrActionNotFound ErrorCode = "ACTION_NOT_FOUND" ErrActionFailed ErrorCode = "ACTION_FAILED" ErrActionInvalid ErrorCode = "ACTION_INVALID" // Model-specific errors ErrModelNotFound ErrorCode = "MODEL_NOT_FOUND" ErrModelInvalid ErrorCode = "MODEL_INVALID" // Validation errors ErrValidationFailed ErrorCode = "VALIDATION_FAILED" )
Standard error codes
type ErrorResponse ¶
type ErrorResponse struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Details interface{} `json:"details,omitempty"`
TraceID string `json:"trace_id,omitempty"`
}
ErrorResponse is the standard response format for errors
type MCPAPI ¶
type MCPAPI struct {
// contains filtered or unexported fields
}
MCPAPI handles the MCP-specific API endpoints
func NewMCPAPI ¶
func NewMCPAPI(contextManager interface{}) *MCPAPI
NewMCPAPI creates a new MCP API handler
func (*MCPAPI) RegisterRoutes ¶
func (api *MCPAPI) RegisterRoutes(router *gin.RouterGroup)
RegisterRoutes registers all MCP API routes
type ModelAPI ¶
type ModelAPI struct {
// contains filtered or unexported fields
}
ModelAPI handles model management endpoints Implements tenant-scoped CRUD operations for models using the repository pattern.
func NewModelAPI ¶
func NewModelAPI(repo repository.ModelRepository) *ModelAPI
NewModelAPI creates a new ModelAPI with the provided repository
func (*ModelAPI) RegisterRoutes ¶
func (m *ModelAPI) RegisterRoutes(router *gin.RouterGroup)
RegisterRoutes registers model endpoints under /models
type PerformanceConfig ¶
type PerformanceConfig struct {
// Connection pooling for database
DBMaxIdleConns int `mapstructure:"db_max_idle_conns"`
DBMaxOpenConns int `mapstructure:"db_max_open_conns"`
DBConnMaxLifetime time.Duration `mapstructure:"db_conn_max_lifetime"`
// HTTP client settings
HTTPMaxIdleConns int `mapstructure:"http_max_idle_conns"`
HTTPMaxConnsPerHost int `mapstructure:"http_max_conns_per_host"`
HTTPIdleConnTimeout time.Duration `mapstructure:"http_idle_conn_timeout"`
// Response optimization
EnableCompression bool `mapstructure:"enable_compression"`
EnableETagCaching bool `mapstructure:"enable_etag_caching"`
// Cache control settings
StaticContentMaxAge time.Duration `mapstructure:"static_content_max_age"`
DynamicContentMaxAge time.Duration `mapstructure:"dynamic_content_max_age"`
// Circuit breaker settings for external services
CircuitBreakerEnabled bool `mapstructure:"circuit_breaker_enabled"`
CircuitBreakerTimeout time.Duration `mapstructure:"circuit_breaker_timeout"`
MaxRetries int `mapstructure:"max_retries"`
RetryBackoff time.Duration `mapstructure:"retry_backoff"`
}
PerformanceConfig holds configuration for performance optimization
type RateLimitConfig ¶
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled"`
Limit int `mapstructure:"limit"`
Period time.Duration `mapstructure:"period"`
BurstFactor int `mapstructure:"burst_factor"`
}
RateLimitConfig holds rate limiting configuration
type RateLimiterConfig ¶
RateLimiterConfig holds the configuration for rate limiting
func DefaultRateLimiterConfig ¶
func DefaultRateLimiterConfig() RateLimiterConfig
DefaultRateLimiterConfig provides sensible defaults
func NewRateLimiterConfigFromConfig ¶
func NewRateLimiterConfigFromConfig(cfg RateLimitConfig) RateLimiterConfig
NewRateLimiterConfigFromConfig creates a rate limiter config from the API config
type SearchByVectorRequest ¶
type SearchByVectorRequest struct {
// Pre-computed vector to search with
Vector []float32 `json:"vector"`
// ContentTypes to filter by
ContentTypes []string `json:"content_types,omitempty"`
// Filters to apply to metadata
Filters []embedding.SearchFilter `json:"filters,omitempty"`
// Sorting criteria
Sorts []embedding.SearchSort `json:"sorts,omitempty"`
// Maximum number of results to return
Limit int `json:"limit,omitempty"`
// Number of results to skip (for pagination)
Offset int `json:"offset,omitempty"`
// Minimum similarity threshold (0.0 to 1.0)
MinSimilarity float32 `json:"min_similarity,omitempty"`
// Weight factors for scoring
WeightFactors map[string]float32 `json:"weight_factors,omitempty"`
}
SearchByVectorRequest represents a vector search request with a pre-computed vector
type SearchEmbeddingsRequest ¶
type SearchEmbeddingsRequest struct {
ContextID string `json:"context_id" binding:"required"`
QueryEmbedding []float32 `json:"query_embedding" binding:"required"`
Limit int `json:"limit" binding:"required"`
ModelID string `json:"model_id"`
SimilarityThreshold float64 `json:"similarity_threshold"`
}
SearchEmbeddingsRequest represents a request to search embeddings
type SearchHandler ¶
type SearchHandler struct {
// contains filtered or unexported fields
}
SearchHandler manages vector search API endpoints
func NewSearchHandler ¶
func NewSearchHandler(searchService embedding.SearchService) *SearchHandler
NewSearchHandler creates a new search handler
func (*SearchHandler) HandleSearch ¶
func (h *SearchHandler) HandleSearch(w http.ResponseWriter, r *http.Request)
HandleSearch handles text-based vector search requests
func (*SearchHandler) HandleSearchByVector ¶
func (h *SearchHandler) HandleSearchByVector(w http.ResponseWriter, r *http.Request)
HandleSearchByVector handles vector-based search requests
func (*SearchHandler) HandleSearchSimilar ¶
func (h *SearchHandler) HandleSearchSimilar(w http.ResponseWriter, r *http.Request)
HandleSearchSimilar handles "more like this" search requests
func (*SearchHandler) RegisterRoutes ¶
func (h *SearchHandler) RegisterRoutes(router *http.ServeMux)
RegisterRoutes registers the search endpoints with the provided router
type SearchRequest ¶
type SearchRequest struct {
// Query text to search for
Query string `json:"query"`
// ContentTypes to filter by
ContentTypes []string `json:"content_types,omitempty"`
// Filters to apply to metadata
Filters []embedding.SearchFilter `json:"filters,omitempty"`
// Sorting criteria
Sorts []embedding.SearchSort `json:"sorts,omitempty"`
// Maximum number of results to return
Limit int `json:"limit,omitempty"`
// Number of results to skip (for pagination)
Offset int `json:"offset,omitempty"`
// Minimum similarity threshold (0.0 to 1.0)
MinSimilarity float32 `json:"min_similarity,omitempty"`
// Weight factors for scoring
WeightFactors map[string]float32 `json:"weight_factors,omitempty"`
}
SearchRequest represents a vector search request
type SearchResponse ¶
type SearchResponse struct {
// Results is the list of search results
Results []*embedding.SearchResult `json:"results"`
// Total is the total number of results found (for pagination)
Total int `json:"total"`
// HasMore indicates if there are more results available
HasMore bool `json:"has_more"`
// Query information for debugging and auditing
Query struct {
// Text or ContentID that was searched for
Input string `json:"input,omitempty"`
// Options that were used for the search
Options *embedding.SearchOptions `json:"options,omitempty"`
} `json:"query"`
}
SearchResponse represents the API response for search endpoints
type SearchResult ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the API server
func NewServer ¶
func NewServer(engine *core.Engine, cfg Config, db *sqlx.DB, metrics observability.MetricsClient, config *config.Config) *Server
NewServer creates a new API server with internal/database implementation
func (*Server) Initialize ¶
Initialize initializes all components and routes
func (*Server) RegisterWebhookRoutes ¶
RegisterWebhookRoutes registers webhook routes for all providers on the given router
func (*Server) SetupVectorAPI ¶
SetupVectorAPI initializes and registers the vector API routes
type StoreEmbeddingRequest ¶
type StoreEmbeddingRequest struct {
ContextID string `json:"context_id" binding:"required"`
ContentIndex int `json:"content_index" binding:"required"`
Text string `json:"text" binding:"required"`
Embedding []float32 `json:"embedding" binding:"required"`
ModelID string `json:"model_id" binding:"required"`
}
StoreEmbeddingRequest represents a request to store an embedding
type ToolAPI ¶
type ToolAPI struct {
// contains filtered or unexported fields
}
ToolAPI handles API endpoints for tool operations
func NewToolAPI ¶
func NewToolAPI(adapterBridge interface{}) *ToolAPI
NewToolAPI creates a new tool API handler
func (*ToolAPI) RegisterRoutes ¶
func (api *ToolAPI) RegisterRoutes(router *gin.RouterGroup)
RegisterRoutes registers all tool API routes
type VectorAPI ¶
type VectorAPI struct {
// contains filtered or unexported fields
}
VectorAPI handles the vector operations API endpoints
func NewVectorAPI ¶
func NewVectorAPI(embedRepo EmbeddingRepositoryInterface, logger observability.Logger) *VectorAPI
NewVectorAPI creates a new vector API handler
func (*VectorAPI) RegisterRoutes ¶
func (v *VectorAPI) RegisterRoutes(group *gin.RouterGroup)
RegisterRoutes registers the vector API routes with the given router group
type VectorDatabaseAdapter ¶
type VectorDatabaseAdapter struct {
// contains filtered or unexported fields
}
VectorDatabaseAdapter provides compatibility between internal/database.VectorDatabase and pkg/database.VectorDatabase This adapter allows us to migrate code incrementally without breaking existing functionality
func NewVectorDatabaseAdapter ¶
func NewVectorDatabaseAdapter(db *sqlx.DB, cfg interface{}, logger observability.Logger) (*VectorDatabaseAdapter, error)
NewVectorDatabaseAdapter creates a new adapter that wraps a pkg/database.VectorDatabase instance but exposes it with the same interface as internal/database.VectorDatabase
func (*VectorDatabaseAdapter) BatchDeleteEmbeddings ¶
func (a *VectorDatabaseAdapter) BatchDeleteEmbeddings(ctx context.Context, contentType, contentID, contextID string) (int, error)
BatchDeleteEmbeddings deletes multiple embeddings matching criteria
func (*VectorDatabaseAdapter) Close ¶
func (a *VectorDatabaseAdapter) Close() error
Close closes the vector database connection
func (*VectorDatabaseAdapter) DeleteEmbedding ¶
func (a *VectorDatabaseAdapter) DeleteEmbedding(ctx context.Context, id string) error
DeleteEmbedding deletes an embedding from the database
func (*VectorDatabaseAdapter) EnsureSchema ¶
func (a *VectorDatabaseAdapter) EnsureSchema(ctx context.Context) error
EnsureSchema ensures the vector database schema exists
func (*VectorDatabaseAdapter) GetEmbeddingByID ¶
func (a *VectorDatabaseAdapter) GetEmbeddingByID(ctx context.Context, id string) (*Embedding, error)
GetEmbeddingByID retrieves an embedding by ID
func (*VectorDatabaseAdapter) Initialize ¶
func (a *VectorDatabaseAdapter) Initialize(ctx context.Context) error
Initialize initializes the vector database tables and indexes
func (*VectorDatabaseAdapter) SearchEmbeddings ¶
func (a *VectorDatabaseAdapter) SearchEmbeddings(ctx context.Context, queryVector []float32, contextID string, modelID string, limit int, similarityThreshold float64) ([]*Embedding, error)
SearchEmbeddings searches for similar embeddings in the vector database
func (*VectorDatabaseAdapter) StoreEmbedding ¶
func (a *VectorDatabaseAdapter) StoreEmbedding(ctx context.Context, embedding *Embedding) error
StoreEmbedding stores an embedding vector in the database
func (*VectorDatabaseAdapter) Transaction ¶
Transaction initiates a transaction and passes control to the provided function
type VersionedHandlers ¶
type VersionedHandlers struct {
// contains filtered or unexported fields
}
VersionedHandlers holds handlers for different API versions
func NewVersionedHandlers ¶
func NewVersionedHandlers() *VersionedHandlers
NewVersionedHandlers creates a new versioned handlers instance
func (*VersionedHandlers) Add ¶
func (vh *VersionedHandlers) Add(version APIVersion, handler gin.HandlerFunc) *VersionedHandlers
Add adds a handler for a specific version
func (*VersionedHandlers) AddDefault ¶
func (vh *VersionedHandlers) AddDefault(handler gin.HandlerFunc) *VersionedHandlers
AddDefault adds a default handler
func (*VersionedHandlers) Handle ¶
func (vh *VersionedHandlers) Handle(c *gin.Context)
Handle handles a request with the appropriate version handler
type VersioningConfig ¶
type VersioningConfig struct {
Enabled bool `mapstructure:"enabled"`
DefaultVersion string `mapstructure:"default_version"`
SupportedVersions []string `mapstructure:"supported_versions"`
}
VersioningConfig holds API versioning configuration
type WebhookProvider ¶
type WebhookProvider struct {
Name string
Enabled func() bool
Endpoint func() string
Handler func() http.HandlerFunc
Middleware func() mux.MiddlewareFunc // can be nil
}
WebhookProvider represents a webhook provider's registration logic Extend this struct for additional providers (e.g., GitLab, Bitbucket)