diff --git a/.github/workflows/pullfrog.yml b/.github/workflows/pullfrog.yml index 6516ae2e..d5030252 100644 --- a/.github/workflows/pullfrog.yml +++ b/.github/workflows/pullfrog.yml @@ -34,22 +34,21 @@ jobs: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - GOOGLE_GENERATIVE_AI_API_KEY: - ${{ secrets.GOOGLE_GENERATIVE_AI_API_KEY }} + GOOGLE_GENERATIVE_AI_API_KEY: ${{ secrets.GOOGLE_GENERATIVE_AI_API_KEY }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} XAI_API_KEY: ${{ secrets.XAI_API_KEY }} DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} MOONSHOT_API_KEY: ${{ secrets.MOONSHOT_API_KEY }} OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} - + # for Amazon Bedrock (https://docs.pullfrog.com/bedrock) # AWS_BEARER_TOKEN_BEDROCK: ${{ secrets.AWS_BEARER_TOKEN_BEDROCK }} # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} # AWS_REGION: us-east-1 # BEDROCK_MODEL_ID: - + # for Google Vertex AI (https://docs.pullfrog.com/vertex) # VERTEX_SERVICE_ACCOUNT_JSON: ${{ secrets.VERTEX_SERVICE_ACCOUNT_JSON }} # GOOGLE_CLOUD_PROJECT: my-project diff --git a/lua/CopilotChat/client.lua b/lua/CopilotChat/client.lua index 7bbc65d8..5a9898f3 100644 --- a/lua/CopilotChat/client.lua +++ b/lua/CopilotChat/client.lua @@ -323,10 +323,11 @@ function Client:ask(opts) local headers = self:authenticate(provider_name) local resolved_model = provider.resolve_model(headers, opts.model) opts.model = resolved_model - model_config = models[opts.model] - if not model_config then - error('Resolved model not found: ' .. opts.model) - end + -- The resolved model may not be present in the models cache when + -- model_picker_enabled is false for all API models (e.g. restricted accounts). + -- Fall back to the original config (e.g. from the 'auto' entry) so the + -- request can still be sent with the correct model id. + model_config = models[opts.model] or model_config end local options = { diff --git a/lua/CopilotChat/config/providers.lua b/lua/CopilotChat/config/providers.lua index ea5eea71..7ba89657 100644 --- a/lua/CopilotChat/config/providers.lua +++ b/lua/CopilotChat/config/providers.lua @@ -635,11 +635,18 @@ M.copilot = { error(err) end + -- Get all chat models, preferring those with model_picker_enabled. + -- Fall back to all chat models if none are picker-enabled (e.g. restricted accounts). + local all_chat_data = vim.tbl_filter(function(model) + return model.capabilities and model.capabilities.type == 'chat' + end, response.body.data) + + local picker_enabled_data = vim.tbl_filter(function(model) + return model.model_picker_enabled + end, all_chat_data) + local models = vim - .iter(response.body.data) - :filter(function(model) - return model.capabilities.type == 'chat' and model.model_picker_enabled - end) + .iter(#picker_enabled_data > 0 and picker_enabled_data or all_chat_data) :map(function(model) local supported_endpoints = model.supported_endpoints or {} -- Pre-compute whether this model uses the Responses API