mirror of
https://github.com/ollama/ollama.git
synced 2026-03-11 17:34:04 -05:00
* add ability to disable cloud
Users can now easily opt-out of cloud inference and web search by
setting
```
"disable_ollama_cloud": true
```
in their `~/.ollama/server.json` settings file. After a setting update,
the server must be restarted.
Alternatively, setting the environment variable `OLLAMA_NO_CLOUD=1` will
also disable cloud features. While users previously were able to avoid
cloud models by not pulling or `ollama run`ing them, this gives them an
easy way to enforce that decision. Any attempt to run a cloud model when
cloud is disabled will fail.
The app's old "airplane mode" setting, which did a similar thing for
hiding cloud models within the app is now unified with this new cloud
disabled mode. That setting has been replaced with a "Cloud" toggle,
which behind the scenes edits `server.json` and then restarts the
server.
* gate cloud models across TUI and launch flows when cloud is disabled
Block cloud models from being selected, launched, or written to
integration configs when cloud mode is turned off:
- TUI main menu: open model picker instead of launching with a
disabled cloud model
- cmd.go: add IsCloudModelDisabled checks for all Selection* paths
- LaunchCmd: filter cloud models from saved Editor configs before
launch, fall through to picker if none remain
- Editor Run() methods (droid, opencode, openclaw): filter cloud
models before calling Edit() and persist the cleaned list
- Export SaveIntegration, remove SaveIntegrationModel wrapper that
was accumulating models instead of replacing them
* rename saveIntegration to SaveIntegration in config.go and tests
* cmd/config: add --model guarding and empty model list fixes
* Update docs/faq.mdx
Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
* Update internal/cloud/policy.go
Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
* Update internal/cloud/policy.go
Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
* Update server/routes.go
Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
* Revert "Update internal/cloud/policy.go"
This reverts commit 8bff8615f9.
Since this error shows up in other integrations, we want it to be
prefixed with Ollama
* rename cloud status
* more status renaming
* fix tests that weren't updated after rename
---------
Co-authored-by: ParthSareen <parth.sareen@ollama.com>
Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
129 lines
3.1 KiB
Go
129 lines
3.1 KiB
Go
//go:build windows || darwin
|
|
|
|
package store
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/ollama/ollama/envconfig"
|
|
)
|
|
|
|
const serverConfigFilename = "server.json"
|
|
|
|
type serverConfig struct {
|
|
DisableOllamaCloud bool `json:"disable_ollama_cloud,omitempty"`
|
|
}
|
|
|
|
// CloudDisabled returns whether cloud features should be disabled.
|
|
// The source of truth is: OLLAMA_NO_CLOUD OR ~/.ollama/server.json:disable_ollama_cloud.
|
|
func (s *Store) CloudDisabled() (bool, error) {
|
|
disabled, _, err := s.CloudStatus()
|
|
return disabled, err
|
|
}
|
|
|
|
// CloudStatus returns whether cloud is disabled and the source of that decision.
|
|
// Source is one of: "none", "env", "config", "both".
|
|
func (s *Store) CloudStatus() (bool, string, error) {
|
|
if err := s.ensureDB(); err != nil {
|
|
return false, "", err
|
|
}
|
|
|
|
configDisabled, err := readServerConfigCloudDisabled()
|
|
if err != nil {
|
|
return false, "", err
|
|
}
|
|
|
|
envDisabled := envconfig.NoCloudEnv()
|
|
return envDisabled || configDisabled, cloudStatusSource(envDisabled, configDisabled), nil
|
|
}
|
|
|
|
// SetCloudEnabled writes the cloud setting to ~/.ollama/server.json.
|
|
func (s *Store) SetCloudEnabled(enabled bool) error {
|
|
if err := s.ensureDB(); err != nil {
|
|
return err
|
|
}
|
|
return setCloudEnabled(enabled)
|
|
}
|
|
|
|
func setCloudEnabled(enabled bool) error {
|
|
configPath, err := serverConfigPath()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.MkdirAll(filepath.Dir(configPath), 0o755); err != nil {
|
|
return fmt.Errorf("create server config directory: %w", err)
|
|
}
|
|
|
|
configMap := map[string]any{}
|
|
if data, err := os.ReadFile(configPath); err == nil {
|
|
if err := json.Unmarshal(data, &configMap); err != nil {
|
|
// If the existing file is invalid JSON, overwrite with a fresh object.
|
|
configMap = map[string]any{}
|
|
}
|
|
} else if !errors.Is(err, os.ErrNotExist) {
|
|
return fmt.Errorf("read server config: %w", err)
|
|
}
|
|
|
|
configMap["disable_ollama_cloud"] = !enabled
|
|
|
|
data, err := json.MarshalIndent(configMap, "", " ")
|
|
if err != nil {
|
|
return fmt.Errorf("marshal server config: %w", err)
|
|
}
|
|
data = append(data, '\n')
|
|
|
|
if err := os.WriteFile(configPath, data, 0o644); err != nil {
|
|
return fmt.Errorf("write server config: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func readServerConfigCloudDisabled() (bool, error) {
|
|
configPath, err := serverConfigPath()
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
data, err := os.ReadFile(configPath)
|
|
if err != nil {
|
|
if errors.Is(err, os.ErrNotExist) {
|
|
return false, nil
|
|
}
|
|
return false, fmt.Errorf("read server config: %w", err)
|
|
}
|
|
|
|
var cfg serverConfig
|
|
// Invalid or unexpected JSON should not block startup; treat as default.
|
|
if json.Unmarshal(data, &cfg) == nil {
|
|
return cfg.DisableOllamaCloud, nil
|
|
}
|
|
return false, nil
|
|
}
|
|
|
|
func serverConfigPath() (string, error) {
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
return "", fmt.Errorf("resolve home directory: %w", err)
|
|
}
|
|
return filepath.Join(home, ".ollama", serverConfigFilename), nil
|
|
}
|
|
|
|
func cloudStatusSource(envDisabled bool, configDisabled bool) string {
|
|
switch {
|
|
case envDisabled && configDisabled:
|
|
return "both"
|
|
case envDisabled:
|
|
return "env"
|
|
case configDisabled:
|
|
return "config"
|
|
default:
|
|
return "none"
|
|
}
|
|
}
|