mirror of
https://github.com/syntrex-lab/gomcp.git
synced 2026-04-27 05:16:22 +02:00
- Rename Go module: sentinel-community/gomcp -> syntrex/gomcp (50+ files) - Rename npm package: sentinel-dashboard -> syntrex-dashboard - Update Cargo.toml repository URL to syntrex/syntrex - Update all doc references from DmitrL-dev/AISecurity to syntrex - Add root Makefile (build-all, test-all, lint-all, clean-all) - Add MIT LICENSE - Add .editorconfig (Go/Rust/TS/C cross-language) - Add .github/workflows/ci.yml (Go + Rust + Dashboard) - Add dashboard next.config.ts and .env.example - Clean ARCHITECTURE.md: remove brain/immune/strike/micro-swarm, fix 61->67 engines
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package pybridge
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/syntrex/gomcp/internal/domain/vectorstore"
|
|
)
|
|
|
|
// PyBridgeEmbedder wraps the Python bridge as an Embedder.
|
|
// This is a transitional adapter — will be replaced by ONNXEmbedder in Phase 3.2.
|
|
type PyBridgeEmbedder struct {
|
|
bridge *Bridge
|
|
dimension int
|
|
}
|
|
|
|
// NewPyBridgeEmbedder creates an Embedder backed by the Python bridge.
|
|
func NewPyBridgeEmbedder(bridge *Bridge) *PyBridgeEmbedder {
|
|
return &PyBridgeEmbedder{
|
|
bridge: bridge,
|
|
dimension: 384, // MiniLM-L12-v2 default.
|
|
}
|
|
}
|
|
|
|
// Embed computes an embedding via the Python subprocess.
|
|
func (e *PyBridgeEmbedder) Embed(ctx context.Context, text string) ([]float64, error) {
|
|
result, err := e.bridge.ComputeEmbedding(ctx, text)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("pybridge embed: %w", err)
|
|
}
|
|
if len(result.Embedding) > 0 {
|
|
e.dimension = len(result.Embedding) // Auto-detect from first result.
|
|
}
|
|
return result.Embedding, nil
|
|
}
|
|
|
|
// Dimension returns the embedding vector dimensionality.
|
|
func (e *PyBridgeEmbedder) Dimension() int {
|
|
return e.dimension
|
|
}
|
|
|
|
// Name returns the embedder identifier.
|
|
func (e *PyBridgeEmbedder) Name() string {
|
|
return "pybridge:sentence-transformers"
|
|
}
|
|
|
|
// Mode returns FULL — Python bridge uses neural embeddings.
|
|
func (e *PyBridgeEmbedder) Mode() vectorstore.OracleMode {
|
|
return vectorstore.OracleModeFull
|
|
}
|