18 Commits

Author SHA1 Message Date
Dmitry Torokhov
2f9daf2bc6 feat(ollama): provide a helper to enable ollama when service is available
Ollama is disabled by default, as it normally does not require API keys
to be defined. Users are supposed to override is_env_set() method in
their configs to enable Ollama.

Provide check_endpoint_alive() helper in Ollama provider module that can
be used directly in place of is_env_set() and checks whether the server
replies to "get list of models" query:

...
  ollama = {
    is_env_set = require("avante.providers.ollama").check_endpoint_alive,
  },
...
2025-10-16 22:09:54 -07:00
Dmitry Torokhov
3e8557a29e fix(ollama): properly handle errors from curl when querying models
Without on_error() handler curl.get() will raise an error which then
will interrupt execution of the plenary job. This interruption will
result in timeout handling code triggering, introducing unneeded delay
and ugly stack traces.

Fix the problem by defining on_error() and callback() handlers and
explicitly wait for job completion with pcall() and Job:wait(). This
allows proper error handling and control over error messages.

Because plenary's curl implementation mangles stderr data, use a local
table to map select error codes to descriptive text messages.

Also do not emit hard error when endpoint is not configured, use
Utils.error().
2025-10-16 22:09:54 -07:00
Dmitry Torokhov
cccf5344ef feat(ollama): do not inherit default models from OpenAI provider
With Ollama majority of people are using their own models, and Ollama
provider by default queries the server for list of models, so there is
no need to inherit anything.
2025-10-16 22:09:54 -07:00
Dmitry Torokhov
0716819a0e feat(providers): fail gracefully when a provider is misconfigured (#2768) 2025-10-15 18:43:55 +08:00
yetone
1e0c8520bc fix: the last used model caused the loss of the model configured in the profile in the model selector (#2600) 2025-08-12 15:33:31 +08:00
Dmitry Torokhov
aa606b6147 refactor(history): change HistoryMessage:new() to accept role and item
Change the constructor to accept role and a single content item instead
of raw AvanteLLMMessage instance. This will help when we will start
changing message.content from being a string or a list of tables to just
a string or a single table.
2025-07-22 17:49:28 +08:00
Dmitry Torokhov
34907fc1cd refactor(history): start moving history-related code into avante/history
The utils module has grown too big and contains unrelated functionality.
Start moving code related to managing history messages comprising chat
history into lua/avante/history module to keep the code more manageable.
2025-07-16 12:49:15 +08:00
yetone
b72581b23b fix: ollama is_env_set (#2304) 2025-06-23 12:05:50 +08:00
Karl Bowden
ce9f6a8ec1 feat: fetch ollama models to display in the model selector (#2287) 2025-06-22 16:36:28 +08:00
Avinash Thakur
8396cc77e4 feat: allow overriding provider headers (#2161) 2025-06-08 02:04:00 +08:00
yetone
bc403ddcbf feat: ReAct tool calling (#2104) 2025-05-31 08:53:34 +08:00
e8c5f4f13e feat(provider/ollama): allow optional API key without blocking the request (#1898) 2025-04-30 22:17:31 +08:00
yetone
f10b8383e3 refactor: history messages (#1934) 2025-04-30 03:07:18 +08:00
Ricardo Maraschini
cff8cbf9c5 feat: add config for ollama keep alive (#1858) 2025-04-17 10:47:51 +08:00
kyrisu
20fea1e717 refactor: rename is_o_series_model to is_reasoning_model (#1632) 2025-03-19 01:45:28 +08:00
yetone
f9f92dc9d4 Revert "fix: Always handle the extra response outside of stream, such as the exceptions from bedrock (#1526)" (#1569)
This reverts commit f9ab6934d2.
2025-03-12 19:10:05 +08:00
brook hong
f9ab6934d2 fix: Always handle the extra response outside of stream, such as the exceptions from bedrock (#1526) 2025-03-12 16:29:32 +08:00
yetone
750ee80971 feat: add ollama as supported provider (#1543)
* feat: add ollama as supported provider

*This implementation is only working with `stream = true`*
- Uses the actual ollama api and allows for passing additional options
- Properly passes the system prompt to api

Use ollama as provider in opts like this:
opts = {
        debug = true,
        provider = "ollama",
        ollama = {
                api_key_name = "",
                endpoint = "http://127.0.0.1:11434",
                model = "qwen2.5-coder:latest",
                options = {
                        num_ctx = 32768,
                        temperature = 0,
                },
                stream = true,
        },

* fix: ollama types

---------

Co-authored-by: jtabke <25010496+jtabke@users.noreply.github.com>
2025-03-10 02:23:56 +08:00