Skip to content

feat: allow setting ollama host#874

Merged
yingjiehe-xyz merged 6 commits intomainfrom
yingjiehe/ollama
Jan 29, 2025
Merged

feat: allow setting ollama host#874
yingjiehe-xyz merged 6 commits intomainfrom
yingjiehe/ollama

Conversation

@yingjiehe-xyz
Copy link
Copy Markdown
Contributor

@yingjiehe-xyz yingjiehe-xyz commented Jan 29, 2025

Allow setting ollama host during configuration

Test step:

  1. Run launchctl setenv OLLAMA_HOST "0.0.0.0:11111" on mac and start run ollama
  2. Check ollama ls: OLLAMA_HOST=0.0.0.0:11111 ollama ls
  3. Verify the ollama host by sending request:
curl http://localhost:11111/api/generate -d '{
 "model": "qwen2.5",
 "prompt":"Why is the sky blue?"
}'
{"model":"qwen2.5","created_at":"2025-01-29T02:53:09.321698Z","response":"The","done":false}
{"model":"qwen2.5","created_at":"2025-01-29T02:53:09.337099Z","response":" sky","done":false}
{"model":"qwen2.5","created_at":"2025-01-29T02:53:09.352554Z","response":" appears","done":false}
{"model":"qwen2.5","created_at":"2025-01-29T02:53:09.368318Z","response":" blue","done":false}
  1. Run the UI can test with host change
    image

  2. Run goose configure CLI:

┌   goose-configure 
│
◇  What would you like to configure?
│  Configure Providers 
│
◇  Which model provider should we use?
│  Ollama 
│
●  OLLAMA_HOST is already configured
│  
◇  Would you like to update this value?
│  Yes 
│
◇  Enter new value for OLLAMA_HOST
│  http://localhost:11111
│
◆  Enter a model from that provider:
│  qwen2.5 (default)
└  
  1. Verify the config yaml file:
extensions:
  developer:
    enabled: true
    name: developer
    type: builtin
default_model: claude-3-5-sonnet-latest
GOOSE_MODEL: llama3.2
OLLAMA_HOST: http://localhost:11111
default_provider: anthropic
DATABRICKS_HOST: https://block-lakehouse-production.cloud.databricks.com
GOOSE_PROVIDER: ollama
/Users/yingjiehe/.config/goose/config.yaml (END)

@michaelneale
Copy link
Copy Markdown
Collaborator

@yingjiehe-xyz looks good - but that implies that you have to set it each time? can you jsut have it default and press submit?

@angiejones
Copy link
Copy Markdown
Collaborator

@acekyd can you update the docs once this is merged?

@yingjiehe-xyz yingjiehe-xyz marked this pull request as ready for review January 29, 2025 03:17
@yingjiehe-xyz
Copy link
Copy Markdown
Contributor Author

@yingjiehe-xyz looks good - but that implies that you have to set it each time? can you jsut have it default and press submit?

no, we only need to set it once and it will be updated in the config.yaml

@sammcj sammcj mentioned this pull request Jan 29, 2025
body: JSON.stringify({
key: keyName,
value: apiKey.trim(),
isSecret: isSecretKey(keyName),
Copy link
Copy Markdown
Contributor

@salman1993 salman1993 Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexhancock @lily-de i think it'd be good to have a secret toggle when setting up the provider - we can probably infer and autofill based on the name (key, token, password, etc)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could do this.

Since we're talking here:

On first look, I have mixed feelings about the API design. The /secrets/store endpoint having a boolean param for isSecret is a bit confusing.

What do you both think about renaming the endpoint if we want to store things that are not secret/sensitive sometimes? @yingjiehe-xyz @salman1993

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like /value/store or /config/store? Those are just the first things that come to mind - likely better options.

Copy link
Copy Markdown
Contributor Author

@yingjiehe-xyz yingjiehe-xyz Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree on that, how about /config/store? it sounds good. Then we may have one more followup question, do we still want to have the API and handler in secrets.ts file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to rename the secrets.ts to something like config.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we can do /config/store and also rename file to config.ts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

synced with @salman1993 offline, let's go with /config/store and rename secrets.ts to something like config.ts

Copy link
Copy Markdown
Contributor

@salman1993 salman1993 Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexhancock can we do the renaming in a separate refactor PR? i think it'll be easier to review

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's fine

@salman1993
Copy link
Copy Markdown
Contributor

salman1993 commented Jan 29, 2025

we can add .with_max_tokens(10) to make provider test faster

let model_config = goose::model::ModelConfig::new(model.clone());

before (took about 10s cause it generated lot of tokens)
Screenshot 2025-01-29 at 7 26 26 AM

much quicker after
Screenshot 2025-01-29 at 7 28 58 AM

@salman1993
Copy link
Copy Markdown
Contributor

salman1993 commented Jan 29, 2025

lgtm! tested this out both in the UI and the CLI. added some minor comments. let's also get a review from one of the UI folks

@yingjiehe-xyz
Copy link
Copy Markdown
Contributor Author

we can add .with_max_tokens(10) to make provider test faster

let model_config = goose::model::ModelConfig::new(model.clone());

before (took about 10s cause it generated lot of tokens) Screenshot 2025-01-29 at 7 26 26 AM

much quicker after Screenshot 2025-01-29 at 7 28 58 AM

Thanks, done

Comment on lines +162 to +164
◇ Provider Ollama requires OLLAMA_HOST, please enter a value
│ http://localhost:11434
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowkey just a bit confused because i definitely have ran ollama models without this parameter being set. if the user doesn't set this, can they still use the ollama provider or will the UI lock them out from doing so because of how things currently work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the default value, the config should be empty for the current users, and then the default value will be populated:

.unwrap_or_else(|_| OLLAMA_HOST.to_string());

@lily-de
Copy link
Copy Markdown
Contributor

lily-de commented Jan 29, 2025

Small things that need to be updated:

  1. The tooltip for the little (!) people see if Ollama is not configured is not technically correct anymore since it's no longer that it just needs to be installed and running, they can also enter a host url -- code here. "Ollama app must be installed on your machine and open."
  2. Users have no way of updating or deleting that host url in the UI due to how we were treating ollama as a special case. If you put in your host url first, you still see the (+) button on the configure screen
  3. Old thing I noticed but applies to Ollama and Databricks -- adding host url gives you this toast: Successfully added API key for Ollama --> should be host
  4. I think this tooltip is now sort of messed up too -- like if you have a key stored for ollama it will say it's "installed an running on your machine" when you hover over the green check
Screenshot 2025-01-29 at 1 50 16 PM

@yingjiehe-xyz
Copy link
Copy Markdown
Contributor Author

Small things that need to be updated:

  1. The tooltip for the little (!) people see if Ollama is not configured is not technically correct anymore since it's no longer that it just needs to be installed and running, they can also enter a host url -- code here. "Ollama app must be installed on your machine and open."
  2. Users have no way of updating or deleting that host url in the UI due to how we were treating ollama as a special case. If you put in your host url first, you still see the (+) button on the configure screen
  3. Old thing I noticed but applies to Ollama and Databricks -- adding host url gives you this toast: Successfully added API key for Ollama --> should be host
  4. I think this tooltip is now sort of messed up too -- like if you have a key stored for ollama it will say it's "installed an running on your machine" when you hover over the green check
Screenshot 2025-01-29 at 1 50 16 PM

Thanks for the call! Synced offline, let's do it in the following PR

@yingjiehe-xyz yingjiehe-xyz merged commit 129e4a9 into main Jan 29, 2025
@yingjiehe-xyz yingjiehe-xyz deleted the yingjiehe/ollama branch January 29, 2025 19:34
@yingjiehe-xyz yingjiehe-xyz linked an issue Jan 30, 2025 that may be closed by this pull request
ahau-square pushed a commit that referenced this pull request May 2, 2025
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom Ollama

6 participants