Skip to content

feat: support Anthropic, DeepSeek, Mistral and Gemini models - #172

Merged
barredterra merged 4 commits into
developfrom
feat/multi-provider-models
Oct 15, 2026
Merged

barredterra merged 4 commits into
developfrom
feat/multi-provider-models

Conversation

@barredterra

@barredterra barredterra commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Ask ALYF can now use models from OpenAI, Anthropic, DeepSeek, Mistral and Gemini. Chat and vision models are built with LangChain's init_chat_model instead of ChatOpenAI and any-llm completions.

Changes

  • Settings: LLM Provider and Vision LLM Provider are Autocomplete fields with a label and a value for each provider. The value is the init_chat_model provider key, for example "google_genai". On save, the value must be one of the options.
  • Chat model: build_chat_model uses init_chat_model. It sends the API key and the base URL only when they are set. The Responses API stays for OpenAI only.
  • Vision model: document extraction uses the same model factory and ainvoke. The OpenAI-style image block stays, because the integrations convert it and it keeps detail: "high".
  • Reasoning effort: each integration takes the Reasoning Effort setting under its own name. OpenAI uses reasoning_effort, Anthropic uses effort and Gemini uses thinking_level. Gemini has no level above "high", so "xhigh" and "max" become "high". DeepSeek and Mistral get no reasoning argument, and the field is hidden for them. The warning for unsupported levels stays OpenAI-only, because only LangChain's OpenAI model data lists the levels.
  • No temperature: newer models (for example gpt-5.x and recent Claude models) reject non-default values with a 400 error. Each provider now uses its default.
  • Harness profile: Deep Agents finds a harness profile by the provider name that the model reports. The profile was registered for "openai" only, so other providers would get write_file, edit_file and execute again. The profile is now registered for the provider of the model that is built.
  • Model list: any-llm still lists the models. A small map changes the provider key to the any-llm name ("google_genai" → "gemini", "mistralai" → "mistral").
  • Form: Base URL and Vision API Key are optional. Reasoning Effort shows only for OpenAI, Anthropic and Gemini.
  • Dependencies: langchain-anthropic, langchain-deepseek, langchain-google-genai, langchain-mistralai and any-llm-sdk[mistral].
  • Patch: changes the old values "OpenAI" and "OpenAI Compatible" to "openai". An OpenAI-compatible endpoint is now "openai" with a Base URL.

Migration

Install the new Python requirements (for example bench setup requirements), then run bench migrate.

Known limits

  • The capability checks on save (tool calling, vision) use LiteLLM with OpenAI names. For other providers, models are usually unknown to this check and are allowed.
  • Document extraction no longer sends response_format=json_object, which only OpenAI supports. It uses the prompt and the existing JSON parser.
  • If the API key is missing, the user sees the provider's error message, not an Ask ALYF message.

Tests

  • Unit tests for reasoning effort per provider, document extraction with a shared and a separate vision model, provider mapping, provider validation, the model factory, the harness profile for OpenAI and Anthropic, and no temperature in the Anthropic request.
  • The full app test suite passes.
  • The tests use fake API keys. A manual test with a real Anthropic model found the temperature error that this PR fixes.

Build chat and vision models with LangChain's `init_chat_model`
instead of `ChatOpenAI` and any-llm completions.

- LLM Provider and Vision LLM Provider are Autocomplete fields with
  OpenAI, Anthropic, DeepSeek, Mistral and Gemini. Validate the value
  on save.
- Register the harness profile for the provider that the model
  reports, so write and execute tools stay excluded for all providers.
- Do not send a temperature. Newer models reject non-default values.
- Make Base URL and Vision API Key optional.
- Show Reasoning Effort only for OpenAI.
- Add a patch that changes "OpenAI" and "OpenAI Compatible" to "openai".
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High impact] The reviewed changes appear safe to merge; no new actionable issue was established.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Settings[Ask ALYF Settings] --> Factory[Shared model factory]
  Factory --> Chat[Chat and field agents]
  Factory --> Vision[Document extraction]
  Chat --> Provider[Configured provider]
  Vision --> Provider
  Legacy[Old provider labels] --> Patch[Migration patch]
  Patch --> Settings
Loading

Reviews (3) · Last reviewed commit: "refactor: move provider patch out of the..." · Reviewed by Greptile

Comment thread ask_alyf/ask_alyf/doctype/ask_alyf_settings/ask_alyf_settings.json
Comment thread ask_alyf/ask_alyf/tools.py
- Remove the remaining mandatory conditions from Base URL, Vision Base
  URL and Vision API Key. A separate vision model can now read its
  credentials from the environment, and the old "OpenAI Compatible"
  conditions could no longer be true.
- Add tests for document extraction with a shared and a separate vision
  model. They check the credentials, the image message and the parsed
  model response.
Each integration takes the Reasoning Effort setting under its own name:
OpenAI as `reasoning_effort`, Anthropic as `effort` and Gemini as
`thinking_level`. Gemini has no level above "high", so "xhigh" and
"max" become "high". DeepSeek and Mistral get no reasoning argument.

The warning for unsupported levels stays OpenAI-only, because only
LangChain's OpenAI model data lists the supported levels.
@barredterra
barredterra merged commit 9f16aea into develop Oct 15, 2026
10 checks passed
@barredterra
barredterra deleted the feat/multi-provider-models branch October 15, 2026 17:52
@barredterra

Copy link
Copy Markdown
Member Author

@Mergifyio backport version-16-hotfix version-15-hotfix

@mergify

mergify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

backport version-16-hotfix version-15-hotfix

✅ Backports have been created

Details

Cherry-pick of 9f16aea has failed:

On branch mergify/bp/version-15-hotfix/pr-172
Your branch is up to date with 'origin/version-15-hotfix'.

You are currently cherry-picking commit 9f16aea.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   ask_alyf/ask_alyf/agent.py
	modified:   ask_alyf/ask_alyf/doctype/ask_alyf_settings/ask_alyf_settings.js
	modified:   ask_alyf/ask_alyf/doctype/ask_alyf_settings/ask_alyf_settings.json
	modified:   ask_alyf/ask_alyf/doctype/ask_alyf_settings/ask_alyf_settings.py
	modified:   ask_alyf/ask_alyf/doctype/ask_alyf_settings/test_ask_alyf_settings.py
	modified:   ask_alyf/ask_alyf/field_agent.py
	modified:   ask_alyf/ask_alyf/test_code_tools.py
	modified:   ask_alyf/ask_alyf/test_field_agent.py
	modified:   ask_alyf/patches.txt
	new file:   ask_alyf/patches/use_langchain_provider_keys.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   ask_alyf/ask_alyf/tools.py
	both modified:   pyproject.toml

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

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.

1 participant