version
This commit is contained in:
@@ -429,19 +429,6 @@ func (c *Client) CreateBlob(ctx context.Context, digest string, r io.Reader) err
|
|||||||
return c.do(ctx, http.MethodPost, fmt.Sprintf("/api/blobs/%s", digest), r, nil)
|
return c.do(ctx, http.MethodPost, fmt.Sprintf("/api/blobs/%s", digest), r, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version returns the Ollama server version as a string.
|
|
||||||
func (c *Client) Version(ctx context.Context) (string, error) {
|
|
||||||
var version struct {
|
|
||||||
Version string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.do(ctx, http.MethodGet, "/api/version", nil, &version); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return version.Version, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Signout will signout a client for a local ollama server.
|
// Signout will signout a client for a local ollama server.
|
||||||
func (c *Client) Signout(ctx context.Context) error {
|
func (c *Client) Signout(ctx context.Context) error {
|
||||||
return c.do(ctx, http.MethodPost, "/api/signout", nil, nil)
|
return c.do(ctx, http.MethodPost, "/api/signout", nil, nil)
|
||||||
|
|||||||
@@ -100,10 +100,9 @@ func (c *Client) Delete(ctx context.Context, r api.DeleteRequest) error {
|
|||||||
|
|
||||||
// Version returns the Ollama server version.
|
// Version returns the Ollama server version.
|
||||||
func (c *Client) Version(ctx context.Context) (string, error) {
|
func (c *Client) Version(ctx context.Context) (string, error) {
|
||||||
type versionResponse struct {
|
version, err := do[struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
}
|
}](c, ctx, "GET", "/api/version", nil)
|
||||||
version, err := do[versionResponse](c, ctx, "GET", "/api/version", nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import (
|
|||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
|
||||||
"github.com/ollama/ollama/api"
|
"github.com/ollama/ollama/api"
|
||||||
|
"github.com/ollama/ollama/client"
|
||||||
"github.com/ollama/ollama/envconfig"
|
"github.com/ollama/ollama/envconfig"
|
||||||
"github.com/ollama/ollama/format"
|
"github.com/ollama/ollama/format"
|
||||||
"github.com/ollama/ollama/parser"
|
"github.com/ollama/ollama/parser"
|
||||||
@@ -1575,12 +1576,7 @@ func checkServerHeartbeat(cmd *cobra.Command, _ []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func versionHandler(cmd *cobra.Command, _ []string) {
|
func versionHandler(cmd *cobra.Command, _ []string) {
|
||||||
client, err := api.ClientFromEnvironment()
|
serverVersion, err := client.New().Version(cmd.Context())
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
serverVersion, err := client.Version(cmd.Context())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Warning: could not connect to a running Ollama instance")
|
fmt.Println("Warning: could not connect to a running Ollama instance")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user