sourcegraph / cody

Type less, code more: Cody is an AI code assistant that uses advanced search and codebase context to help you write and fix code.
https://cody.dev
Apache License 2.0
2.64k stars 288 forks source link

bug: ollama URL for chat is hardcoded to localhost:11434 #3970

Closed vbehar closed 3 weeks ago

vbehar commented 5 months ago

Version

v1.14.0

Describe the bug

when enabling the experimental feature to use a model hosted on ollama, cody can only talks to localhost:11434 - we can't configure a different URL - as we do for the completion feature for example.

Expected behavior

be able to configure the Ollama URL - same as what is currently done for the completion feature

Additional context

we have a shared ollama instance, and we would like to use it to chat, instead of asking every dev to install ollama locally

jdorfman commented 5 months ago

Thanks @vbehar I notified the team =)

harshal-cuminai commented 5 months ago

@jdorfman any timeline on when will this be fixed. I need it urgently. I can use a pre-release version on vscode.

I am currently on (pre-release) v1.17.1714749264

jdorfman commented 5 months ago

@harshal-cuminai I will ask them and follow up when I hear back.

vijayabhaskar-ev commented 4 months ago

@jdorfman Can i take up this issue?

jdorfman commented 4 months ago

@vijayabhaskar-ev let me check with @dominiccooney

jdorfman commented 4 months ago

@vijayabhaskar-ev it's yours :)

abeatrix commented 4 months ago

@vijayabhaskar-ev we have updated the Ollama chat client where the endpoint can now be configured with the cody.dev.models field in your VS Code settings:

    "cody.dev.models": [
        {
            "provider": "ollama",
            "model": "llama3:instruct",
            "apiEndpoint": "http://YOU_OLLAMA-HOST"
        }
    ],

I did find a bug that is causing Ollama clients not to work atm, but once this PR https://github.com/sourcegraph/cody/pull/4564 is merged, we will release a patch that you can try and confirm if this issue has been resolved 🙇‍♀️

jdorfman commented 4 months ago

@vijayabhaskar-ev please give us feedback. Good or bad.

vijayabhaskar-ev commented 4 months ago

@jdorfman Using the below config is not working .

"cody.dev.models": [
        {
            "provider": "ollama",
            "model": "llama3:instruct",
            "apiEndpoint": "http://YOU_OLLAMA-HOST"
        }
    ],
Currently this is the one working.
      "cody.autocomplete.advanced.provider": "experimental-ollama",
    "cody.autocomplete.experimental.ollamaOptions": {
      "url": "http://localhost:11434",
      "model": "codellama"
    },
Am i missing something. Please let me know if i need to make any other config changes @abeatrix  
ByerRA commented 4 months ago

I can also confirm that currently using the suggested change of "cody.dev.models" in the settings file isn't working using Cody pre-release v.1.23.1718550982.

On the machine where we have Ollama running, it works just fine using the suggested "cody.dev.mnodels" configuration and I can see and select any of the Ollama models loaded to chat with.

But on another machine on the same network (like my laptop) if I use the suggested "cody.dev.models" configuration I can now at least see and select the Ollama model I configured in the "cody.dev.models" and select it for chat but when I try to chat with it, it just sits there doing nothing and I can confirm that on the machine running Ollama it's not doing anything.

jdorfman commented 4 months ago

@abeatrix any ideas?

cc @kynlos

abeatrix commented 4 months ago

@ByerRA That looks like a networking configuration issue with your Ollama instance since you are able to chat with Ollama using "cody.dev. models" when it's hosted on the same machine, but it doesn't work if the Ollama instance is hosted on a different machine?

Does it work if you try to send this curl command from your local machine to Ollama that is hosted on a separate machine?

curl http://YOU_OLLAMA-HOST/api/generate -d '{
  "model": "llama3:instruct",
  "prompt": "Why is the sky blue?"
}'
vijayabhaskar-ev commented 4 months ago

@ByerRA I too hosted ollama on aws and it works fine.

ByerRA commented 4 months ago

On any machine on my network including my laptop in question when I enter...

curl http://10.1.1.23:11434/api/generate -d '{"model": "llama3","prompt": "Why is the sky blue?"}'

I get output...

{"model":"llama3","created_at":"2024-06-19T21:24:55.226312671Z","response":"A","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:55.446845782Z","response":" classic","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:55.649150723Z","response":" question","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:55.847251318Z","response":"!\n\n","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:56.047841372Z","response":"The","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:56.249757Z","response":" sky","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:56.451015883Z","response":" appears","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:56.646876362Z","response":" blue","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:56.845326247Z","response":" because","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:57.051867034Z","response":" of","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:57.259307694Z","response":" a","done":false}
{"model":"llama3","created_at":"2024-06-19T21:24:57.476004467Z","response":" phenomenon","done":false}

And I've even tested this across my VPN and had no problems.

abeatrix commented 3 months ago

@ByerRA can you share your cody.dev.models settings with me so we can investigate further?

ByerRA commented 3 months ago

Here is my complete config file...

{
    "editor.inlineSuggest.suppressSuggestions": false,
    "workbench.startupEditor": "none",
    "cody.autocomplete.advanced.provider": "experimental-ollama",
    "cody.autocomplete.advanced.serverEndpoint": "http://10.1.1.23:11434",
    "cody.autocomplete.experimental.ollamaOptions": {
        "url": "http://10.1.1.23:11434",
        "model": "deepseek"
    },
    "cody.dev.models": [{
        "provider": "ollama",
        "model": "deepseek",
        "apiEndpoint": "http://10.1.1.23:11434",
    }],
    "editor.minimap.enabled": false,
    "cody.experimental.ollamaChat": true,
    "redhat.telemetry.enabled": false,
    "cody.autocomplete.languages": {
        "*": true
    },
    "extensions.ignoreRecommendations": true,
    "terminal.integrated.enableMultiLinePasteWarning": "never",
    "explorer.confirmDelete": false
}
abeatrix commented 3 months ago

@ByerRA thank you! Is deepseek the model name you pulled from Ollama? Or should it be deepseek-coder?
I'm trying to reproduce the issue but couldn't find a model with just deepseek on Ollama library 😅

ByerRA commented 3 months ago

Yes, you are correct, it should be "deepseek-coder", my typing mistake.

abeatrix commented 3 months ago

@ByerRA oh nice! Did updating the model name fix the issue for you?

valerybugakov commented 3 weeks ago

The cody.dev.models setting solves the original issue. Feel free to reopen if it's not the case.