Josh Yan hace 9 meses
padre
commit
86a874fceb
Se han modificado 4 ficheros con 19 adiciones y 19 borrados
  1. 1 1
      parser/parser.go
  2. 1 1
      server/images.go
  3. 2 2
      server/manifest.go
  4. 15 15
      server/routes_create_test.go

+ 1 - 1
parser/parser.go

@@ -139,7 +139,7 @@ func ParseFile(r io.Reader) (*File, error) {
 					}
 					}
 
 
 					continue
 					continue
-				} else if isSpace(r){
+				} else if isSpace(r) {
 					return nil, errInvalidVersion
 					return nil, errInvalidVersion
 				} else if _, err := semver.NewVersion(s); err != nil {
 				} else if _, err := semver.NewVersion(s); err != nil {
 					return nil, errInvalidVersion
 					return nil, errInvalidVersion

+ 1 - 1
server/images.go

@@ -550,7 +550,7 @@ func CreateModel(ctx context.Context, name model.Name, modelFileDir, quantizatio
 				}
 				}
 			}
 			}
 		}
 		}
-	}		
+	}
 
 
 	var err2 error
 	var err2 error
 	layers = slices.DeleteFunc(layers, func(layer *Layer) bool {
 	layers = slices.DeleteFunc(layers, func(layer *Layer) bool {

+ 2 - 2
server/manifest.go

@@ -18,7 +18,7 @@ type Manifest struct {
 	MediaType     string   `json:"mediaType"`
 	MediaType     string   `json:"mediaType"`
 	Config        *Layer   `json:"config"`
 	Config        *Layer   `json:"config"`
 	Layers        []*Layer `json:"layers"`
 	Layers        []*Layer `json:"layers"`
-	Ollama		  string   `json:"ollama"`
+	Ollama        string   `json:"ollama"`
 
 
 	filepath string
 	filepath string
 	fi       os.FileInfo
 	fi       os.FileInfo
@@ -116,7 +116,7 @@ func WriteManifest(name model.Name, config *Layer, layers []*Layer, ollama strin
 		MediaType:     "application/vnd.docker.distribution.manifest.v2+json",
 		MediaType:     "application/vnd.docker.distribution.manifest.v2+json",
 		Config:        config,
 		Config:        config,
 		Layers:        layers,
 		Layers:        layers,
-		Ollama:		   ollama,
+		Ollama:        ollama,
 	}
 	}
 
 
 	return json.NewEncoder(f).Encode(m)
 	return json.NewEncoder(f).Encode(m)

+ 15 - 15
server/routes_create_test.go

@@ -498,7 +498,7 @@ func TestCreateTemplateSystem(t *testing.T) {
 			Modelfile: fmt.Sprintf("FROM %s\nTEMPLATE {{ .Prompt", createBinFile(t, nil, nil)),
 			Modelfile: fmt.Sprintf("FROM %s\nTEMPLATE {{ .Prompt", createBinFile(t, nil, nil)),
 			Stream:    &stream,
 			Stream:    &stream,
 		})
 		})
-	
+
 		if w.Code != http.StatusBadRequest {
 		if w.Code != http.StatusBadRequest {
 			t.Fatalf("expected status code 400, actual %d", w.Code)
 			t.Fatalf("expected status code 400, actual %d", w.Code)
 		}
 		}
@@ -510,7 +510,7 @@ func TestCreateTemplateSystem(t *testing.T) {
 			Modelfile: fmt.Sprintf("FROM %s\nTEMPLATE {{ if .Prompt }}", createBinFile(t, nil, nil)),
 			Modelfile: fmt.Sprintf("FROM %s\nTEMPLATE {{ if .Prompt }}", createBinFile(t, nil, nil)),
 			Stream:    &stream,
 			Stream:    &stream,
 		})
 		})
-	
+
 		if w.Code != http.StatusBadRequest {
 		if w.Code != http.StatusBadRequest {
 			t.Fatalf("expected status code 400, actual %d", w.Code)
 			t.Fatalf("expected status code 400, actual %d", w.Code)
 		}
 		}
@@ -522,7 +522,7 @@ func TestCreateTemplateSystem(t *testing.T) {
 			Modelfile: fmt.Sprintf("FROM %s\nTEMPLATE {{  Prompt }}", createBinFile(t, nil, nil)),
 			Modelfile: fmt.Sprintf("FROM %s\nTEMPLATE {{  Prompt }}", createBinFile(t, nil, nil)),
 			Stream:    &stream,
 			Stream:    &stream,
 		})
 		})
-	
+
 		if w.Code != http.StatusBadRequest {
 		if w.Code != http.StatusBadRequest {
 			t.Fatalf("expected status code 400, actual %d", w.Code)
 			t.Fatalf("expected status code 400, actual %d", w.Code)
 		}
 		}
@@ -624,7 +624,7 @@ func TestCreateDetectTemplate(t *testing.T) {
 	})
 	})
 }
 }
 
 
-func TestCreateVersion(t *testing.T){
+func TestCreateVersion(t *testing.T) {
 	gin.SetMode(gin.TestMode)
 	gin.SetMode(gin.TestMode)
 
 
 	p := t.TempDir()
 	p := t.TempDir()
@@ -640,12 +640,12 @@ func TestCreateVersion(t *testing.T){
 
 
 	if w.Code != http.StatusOK {
 	if w.Code != http.StatusOK {
 		t.Fatalf("expected status code 200, actual %d", w.Code)
 		t.Fatalf("expected status code 200, actual %d", w.Code)
-	} 
+	}
 
 
 	checkFileExists(t, filepath.Join(p, "manifests", "*", "*", "*", "*"), []string{
 	checkFileExists(t, filepath.Join(p, "manifests", "*", "*", "*", "*"), []string{
 		filepath.Join(p, "manifests", "registry.ollama.ai", "library", "test", "latest"),
 		filepath.Join(p, "manifests", "registry.ollama.ai", "library", "test", "latest"),
 	})
 	})
-	
+
 	f, err := os.Open(filepath.Join(p, "manifests", "registry.ollama.ai", "library", "test", "latest"))
 	f, err := os.Open(filepath.Join(p, "manifests", "registry.ollama.ai", "library", "test", "latest"))
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
@@ -667,11 +667,11 @@ func TestCreateVersion(t *testing.T){
 			Modelfile: fmt.Sprintf("FROM %s\nLICENSE MIT\nLICENSE Apache-2.0", createBinFile(t, nil, nil)),
 			Modelfile: fmt.Sprintf("FROM %s\nLICENSE MIT\nLICENSE Apache-2.0", createBinFile(t, nil, nil)),
 			Stream:    &stream,
 			Stream:    &stream,
 		})
 		})
-		
+
 		if w.Code != http.StatusOK {
 		if w.Code != http.StatusOK {
 			t.Fatalf("expected status code 200, actual %d", w.Code)
 			t.Fatalf("expected status code 200, actual %d", w.Code)
 		}
 		}
-		
+
 		checkFileExists(t, filepath.Join(p, "manifests", "*", "*", "noversion", "*"), []string{
 		checkFileExists(t, filepath.Join(p, "manifests", "*", "*", "noversion", "*"), []string{
 			filepath.Join(p, "manifests", "registry.ollama.ai", "library", "noversion", "latest"),
 			filepath.Join(p, "manifests", "registry.ollama.ai", "library", "noversion", "latest"),
 		})
 		})
@@ -686,7 +686,7 @@ func TestCreateVersion(t *testing.T){
 		if err := bts.Decode(&m); err != nil {
 		if err := bts.Decode(&m); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
-		
+
 		if m.Ollama != "" {
 		if m.Ollama != "" {
 			t.Errorf("got %s != want \"\"", m.Ollama)
 			t.Errorf("got %s != want \"\"", m.Ollama)
 		}
 		}
@@ -713,25 +713,25 @@ func TestCreateVersion(t *testing.T){
 
 
 		if w.Code != http.StatusOK {
 		if w.Code != http.StatusOK {
 			t.Fatalf("expected status code 200, actual %d", w.Code)
 			t.Fatalf("expected status code 200, actual %d", w.Code)
-		} 
-	
+		}
+
 		checkFileExists(t, filepath.Join(p, "manifests", "*", "*", "fromvalid", "*"), []string{
 		checkFileExists(t, filepath.Join(p, "manifests", "*", "*", "fromvalid", "*"), []string{
 			filepath.Join(p, "manifests", "registry.ollama.ai", "library", "fromvalid", "latest"),
 			filepath.Join(p, "manifests", "registry.ollama.ai", "library", "fromvalid", "latest"),
 		})
 		})
-		
+
 		f, err := os.Open(filepath.Join(p, "manifests", "registry.ollama.ai", "library", "fromvalid", "latest"))
 		f, err := os.Open(filepath.Join(p, "manifests", "registry.ollama.ai", "library", "fromvalid", "latest"))
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 		bts := json.NewDecoder(f)
 		bts := json.NewDecoder(f)
-	
+
 		var m Manifest
 		var m Manifest
 		if err := bts.Decode(&m); err != nil {
 		if err := bts.Decode(&m); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
-	
+
 		if m.Ollama != "0.2.3" {
 		if m.Ollama != "0.2.3" {
 			t.Errorf("got %s != want 0.2.3", m.Ollama)
 			t.Errorf("got %s != want 0.2.3", m.Ollama)
 		}
 		}
 	})
 	})
-}
+}