feat: specific provider for auto-suggestions (#569)
This commit is contained in:
		
							parent
							
								
									8184275770
								
							
						
					
					
						commit
						0642905c80
					
				| @ -192,6 +192,7 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_ | ||||
| { | ||||
|   ---@alias Provider "claude" | "openai" | "azure" | "gemini" | "cohere" | "copilot" | string | ||||
|   provider = "claude", -- Recommend using Claude | ||||
|   auto_suggestions_provider = "claude", -- Since auto-suggestions are a high-frequency operation and therefore expensive, it is recommended to specify an inexpensive provider or even a free provider: copilot | ||||
|   claude = { | ||||
|     endpoint = "https://api.anthropic.com", | ||||
|     model = "claude-3-5-sonnet-20240620", | ||||
|  | ||||
| @ -11,6 +11,7 @@ M.defaults = { | ||||
|   debug = false, | ||||
|   ---@alias Provider "claude" | "openai" | "azure" | "gemini" | "cohere" | "copilot" | [string] | ||||
|   provider = "claude", -- Only recommend using Claude | ||||
|   auto_suggestions_provider = "claude", | ||||
|   ---@alias Tokenizer "tiktoken" | "hf" | ||||
|   -- Used for counting tokens and encoding text. | ||||
|   -- By default, we will use tiktoken. | ||||
|  | ||||
| @ -33,6 +33,7 @@ local group = api.nvim_create_augroup("avante_llm", { clear = true }) | ||||
| ---@field bufnr integer | ||||
| ---@field instructions string | ||||
| ---@field mode LlmMode | ||||
| ---@field provider AvanteProviderFunctor | nil | ||||
| ---@field on_chunk AvanteChunkParser | ||||
| ---@field on_complete AvanteCompleteParser | ||||
| 
 | ||||
| @ -40,7 +41,7 @@ local group = api.nvim_create_augroup("avante_llm", { clear = true }) | ||||
| M.stream = function(opts) | ||||
|   local mode = opts.mode or "planning" | ||||
|   ---@type AvanteProviderFunctor | ||||
|   local Provider = P[Config.provider] | ||||
|   local Provider = opts.provider or P[Config.provider] | ||||
| 
 | ||||
|   -- Check if the instructions contains an image path | ||||
|   local image_paths = {} | ||||
|  | ||||
| @ -2,7 +2,7 @@ local Utils = require("avante.utils") | ||||
| local Llm = require("avante.llm") | ||||
| local Highlights = require("avante.highlights") | ||||
| local Config = require("avante.config") | ||||
| local Provider = require("avante.providers") | ||||
| local Providers = require("avante.providers") | ||||
| local api = vim.api | ||||
| local fn = vim.fn | ||||
| 
 | ||||
| @ -37,7 +37,7 @@ function Suggestion:new(id) | ||||
|   instance._contexts = {} | ||||
|   if Config.behaviour.auto_suggestions then | ||||
|     if not vim.g.avante_login or vim.g.avante_login == false then | ||||
|       api.nvim_exec_autocmds("User", { pattern = Provider.env.REQUEST_LOGIN_PATTERN }) | ||||
|       api.nvim_exec_autocmds("User", { pattern = Providers.env.REQUEST_LOGIN_PATTERN }) | ||||
|       vim.g.avante_login = true | ||||
|     end | ||||
|     instance:setup_autocmds() | ||||
| @ -65,7 +65,10 @@ function Suggestion:suggest() | ||||
| 
 | ||||
|   local full_response = "" | ||||
| 
 | ||||
|   local provider = Providers[Config.auto_suggestions_provider] | ||||
| 
 | ||||
|   Llm.stream({ | ||||
|     provider = provider, | ||||
|     bufnr = bufnr, | ||||
|     ask = true, | ||||
|     file_content = code_content, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 yetone
						yetone