aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-09-08 12:15:59 -0400
committerXe Iaso <me@xeiaso.net>2024-09-08 12:15:59 -0400
commit8f5901e8db2de662915994df0a98c6cd72ee4774 (patch)
treee88712afcfcabf6b8e2e76c5443d55cf06f53379 /web
parentd1f4cb439f3ef7ac5cee30b54282afdae1bc34ef (diff)
downloadx-8f5901e8db2de662915994df0a98c6cd72ee4774.tar.xz
x-8f5901e8db2de662915994df0a98c6cd72ee4774.zip
move more static websites to k8s
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'web')
-rw-r--r--web/ollama/ollama.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/web/ollama/ollama.go b/web/ollama/ollama.go
index a5c71c3..8859715 100644
--- a/web/ollama/ollama.go
+++ b/web/ollama/ollama.go
@@ -240,23 +240,28 @@ func Hallucinate[T valid.Interface](ctx context.Context, c *Client, opts Halluci
}
type EmbedRequest struct {
- Model string `json:"model"`
- Prompt string `json:"prompt"`
-
- Options map[string]any `json:"options"`
+ Model string `json:"model"`
+ Input []string `json:"input"`
+ Truncate bool `json:"truncate"`
+ Options map[string]any `json:"options"`
+ KeepAlive string `json:"keep_alive"`
}
type EmbedResponse struct {
- Embedding []float64 `json:"embedding"`
+ Embeddings [][]float64 `json:"embedding"`
}
func (c *Client) Embeddings(ctx context.Context, er *EmbedRequest) (*EmbedResponse, error) {
+ if er.KeepAlive == "" {
+ er.KeepAlive = (9999 * time.Minute).String()
+ }
+
buf := &bytes.Buffer{}
if err := json.NewEncoder(buf).Encode(er); err != nil {
return nil, fmt.Errorf("ollama: error encoding request: %w", err)
}
- req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/embeddings", buf)
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/embed", buf)
if err != nil {
return nil, fmt.Errorf("ollama: error creating request: %w", err)
}