diff --git a/server/images.go b/server/images.go index cc07bd0f..494f927e 100644 --- a/server/images.go +++ b/server/images.go @@ -503,9 +503,9 @@ func embeddingLayers(e EmbeddingParams) ([]*LayerReader, error) { }() // this will be used to check if we already have embeddings for a file - modelDigest, err := modelDigest(e.model) + modelInfo, err := os.Stat(e.model) if err != nil { - return nil, fmt.Errorf("model digest: %w", err) + log.Fatalf("Error getting file info: %s", err) } addedFiles := make(map[string]bool) // keep track of files that have already been added @@ -521,7 +521,7 @@ func embeddingLayers(e EmbeddingParams) ([]*LayerReader, error) { } addedFiles[filePath] = true // check if we already have embeddings for this file path - layerIdentifier := fmt.Sprintf("%s:%s", filePath, modelDigest) + layerIdentifier := fmt.Sprintf("%s:%s:%s:%d", filePath, e.model, modelInfo.ModTime().Format("2006-01-02 15:04:05"), modelInfo.Size()) digest, _ := GetSHA256Digest(strings.NewReader(layerIdentifier)) existing, err := existingFileEmbeddings(digest) if err != nil { @@ -591,17 +591,6 @@ func embeddingLayers(e EmbeddingParams) ([]*LayerReader, error) { return layers, nil } -func modelDigest(modelPath string) (string, error) { - modelFile, err := os.Open(modelPath) - if err != nil { - return "", fmt.Errorf("could not open model blob: %w", err) - } - defer modelFile.Close() - - digest, _ := GetSHA256Digest(modelFile) - return digest, nil -} - // existingFileEmbeddings checks if we already have embeddings for a file and loads them into a look-up map func existingFileEmbeddings(digest string) (map[string][]float64, error) { path, err := GetBlobsPath(digest)