version
This commit is contained in:
parent
ec8a9f11ae
commit
a3df958032
|
|
@ -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)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (c *Client) Signout(ctx context.Context) error {
|
||||
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.
|
||||
func (c *Client) Version(ctx context.Context) (string, error) {
|
||||
type versionResponse struct {
|
||||
version, err := do[struct {
|
||||
Version string `json:"version"`
|
||||
}
|
||||
version, err := do[versionResponse](c, ctx, "GET", "/api/version", nil)
|
||||
}](c, ctx, "GET", "/api/version", nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"golang.org/x/term"
|
||||
|
||||
"github.com/ollama/ollama/api"
|
||||
"github.com/ollama/ollama/client"
|
||||
"github.com/ollama/ollama/envconfig"
|
||||
"github.com/ollama/ollama/format"
|
||||
"github.com/ollama/ollama/parser"
|
||||
|
|
@ -1575,12 +1576,7 @@ func checkServerHeartbeat(cmd *cobra.Command, _ []string) error {
|
|||
}
|
||||
|
||||
func versionHandler(cmd *cobra.Command, _ []string) {
|
||||
client, err := api.ClientFromEnvironment()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
serverVersion, err := client.Version(cmd.Context())
|
||||
serverVersion, err := client.New().Version(cmd.Context())
|
||||
if err != nil {
|
||||
fmt.Println("Warning: could not connect to a running Ollama instance")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue