embedder

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package embedder 提供文本转向量的实现 支持 OpenAI 兼容 API 和 Ollama 原生 API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Embedder

type Embedder interface {
	Embed(ctx context.Context, text string) ([]float32, error)
}

Embedder 文本转向量接口

func NewOllama

func NewOllama(config *OllamaConfig) Embedder

func NewOpenAI

func NewOpenAI(config *OpenAIConfig) Embedder

type OllamaConfig

type OllamaConfig struct {
	BaseURL string // 如 "http://localhost:11434"
	Model   string // 如 "nomic-embed-text"
	Timeout time.Duration
}

type OpenAIConfig

type OpenAIConfig struct {
	BaseURL string // 如 "https://api.openai.com/v1" 或 "http://localhost:11434/v1"
	APIKey  string
	Model   string
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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