25 lines
494 B
Go
25 lines
494 B
Go
package gollama
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ollama/ollama/api"
|
|
)
|
|
|
|
// Embed generates vector embeddings for the given texts.
|
|
func (c *Client) Embed(ctx context.Context, model string, texts []string) ([][]float32, error) {
|
|
name, err := c.resolveModel(model)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req := &api.EmbedRequest{
|
|
Model: name,
|
|
Input: texts,
|
|
}
|
|
resp, err := c.api.Embed(ctx, req)
|
|
if err != nil {
|
|
return nil, wrapError("embed", name, err)
|
|
}
|
|
return resp.Embeddings, nil
|
|
}
|