This commit is contained in:
Michael Yang 2023-12-01 12:10:27 -08:00
parent cde13bcdea
commit 4b77fcb2b9

View file

@ -1038,8 +1038,6 @@ func checkServerHeartbeat(cmd *cobra.Command, _ []string) error {
} }
func versionHandler(cmd *cobra.Command, _ []string) { func versionHandler(cmd *cobra.Command, _ []string) {
fmt.Printf("ollama version %s\n", version.Version)
client, err := api.ClientFromEnvironment() client, err := api.ClientFromEnvironment()
if err != nil { if err != nil {
return return
@ -1047,11 +1045,15 @@ func versionHandler(cmd *cobra.Command, _ []string) {
serverVersion, err := client.Version(cmd.Context()) serverVersion, err := client.Version(cmd.Context())
if err != nil { 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 { 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{ CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true, DisableDefaultCmd: true,
}, },
Version: version.Version,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if version, _ := cmd.Flags().GetBool("version"); version { if version, _ := cmd.Flags().GetBool("version"); version {
versionHandler(cmd, args) versionHandler(cmd, args)