Michael Yang 1 year ago
parent
commit
4b77fcb2b9
1 changed files with 6 additions and 5 deletions
  1. 6 5
      cmd/cmd.go

+ 6 - 5
cmd/cmd.go

@@ -1038,8 +1038,6 @@ func checkServerHeartbeat(cmd *cobra.Command, _ []string) error {
 }
 
 func versionHandler(cmd *cobra.Command, _ []string) {
-	fmt.Printf("ollama version %s\n", version.Version)
-
 	client, err := api.ClientFromEnvironment()
 	if err != nil {
 		return
@@ -1047,11 +1045,15 @@ func versionHandler(cmd *cobra.Command, _ []string) {
 
 	serverVersion, err := client.Version(cmd.Context())
 	if err != nil {
-		return
+		fmt.Println("Warning: could not connect to a running Ollama instance")
+	}
+
+	if serverVersion != "" {
+		fmt.Printf("ollama version is %s\n", serverVersion)
 	}
 
 	if serverVersion != version.Version {
-		fmt.Printf("ollama host version %s\n", serverVersion)
+		fmt.Printf("Warning: client version is %s\n", version.Version)
 	}
 }
 
@@ -1067,7 +1069,6 @@ func NewCLI() *cobra.Command {
 		CompletionOptions: cobra.CompletionOptions{
 			DisableDefaultCmd: true,
 		},
-		Version: version.Version,
 		Run: func(cmd *cobra.Command, args []string) {
 			if version, _ := cmd.Flags().GetBool("version"); version {
 				versionHandler(cmd, args)