Skip to content

chore(ollama): enable sentence and dictionary modes by default#924

Merged
tisfeng merged 3 commits intotisfeng:devfrom
Hephaest:main
Jun 27, 2025
Merged

chore(ollama): enable sentence and dictionary modes by default#924
tisfeng merged 3 commits intotisfeng:devfrom
Hephaest:main

Conversation

@Hephaest
Copy link
Copy Markdown
Contributor

@Hephaest Hephaest commented Jun 26, 2025

Description

I recently switched to using the Ollama service and noticed a significant issue affecting the user experience. When I select text and trigger the translation shortcut (Option+D), the fixed translation window appears, but the translation doesn’t execute.

This behavior only occurs with the Ollama service — other remote APIs I’ve used, such as OpenAI and Gemini, work as expected.

Screen.Recording.2025-06-26.at.11.20.05.mov

Root Cause

The problem was traced to the sentence mode setting, which was unexpectedly set to false by default when using Ollama. It’s unclear why this default differs from other services, but it appears to be unintentional or inconsistent with expected behavior.

Demo

I’ve fixed the bug and tested the fix locally. The translation now triggers as expected when using Ollama, and everything is functioning smoothly. 🎉

Screen.Recording.2025-06-26.at.11.09.47.mov

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Hephaest, Thank you for your first PR contribution 🎉 Hephaest

@Hephaest
Copy link
Copy Markdown
Contributor Author

Hephaest commented Jun 26, 2025

Hi @tisfeng Please help review this PR, and feel free to push the commit for further fix. 🙌🏼

BTW, I love this project, thanks for bring it to the open source world!

@tisfeng tisfeng changed the base branch from main to dev June 27, 2025 02:45
@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Jun 27, 2025

Thanks your PR!

The problem was traced to the sentence mode setting, which was unexpectedly set to false by default when using Ollama. It’s unclear why this default differs from other services, but it appears to be unintentional or inconsistent with expected behavior.

Because I previously tested and found that the Ollama model's explanation of words and sentences was not very good, so it was disabled by default.

Maybe it has improved a lot now, and it's ok to enable it by default.

This way, it can also be consistent with OpenAI and Gemini, no problem.

Make Ollma enable `Dictionary` and `Sentence` by default.
@tisfeng tisfeng requested review from Copilot and tisfeng June 27, 2025 03:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the Ollama service was not auto-triggering translations due to sentence mode being disabled by default.

  • Removed the overrides for isSentenceEnabledByDefault and isDictionaryEnabledByDefault, allowing the base class defaults to apply.
  • Ensures that sentence mode is enabled by default for Ollama, resolving the broken translation trigger.
Comments suppressed due to low confidence (1)

Easydict/Swift/Service/Ollama/OllamaService.swift:50

  • The removal of the sentence mode override appears to be intended to enable it by default via the base class. Please verify that the base implementation returns true to ensure auto-translation is correctly triggered. Additionally, confirm that removing the dictionary mode override is deliberate and that its behavior remains appropriate.
        [supportedModelsKey]

Comment thread Easydict/Swift/Service/Ollama/OllamaService.swift
@Hephaest
Copy link
Copy Markdown
Contributor Author

Hephaest commented Jun 27, 2025

@tisfeng Thanks for reply, you actually helped me realize how I fell into this issue. Sadly, my original "fix" was totally wrong 😅 The real issue was that I had turned off the translation toggle. With all three toggles (translation, sentence, dictionary) off, the system didn’t trigger auto-translation — which makes sense now.

Why I Turn It Off?

I originally disabled the toggles because I thought they only applied to the built-in prompt. Since I was using a custom prompt, I assumed they weren’t needed. But now I realize in order to achieve auto query, I at least need to toggle translation on.

image

Fun Fact Asides:

The demo "worked" because I had sentence mode turned on by default – even with translation and dictionary toggles off, auto-translation was still triggered. I even tested with only the dictionary toggle on… and it works! 😂

Back to this PR, your fix is definitely more robust and aligns better with how other online models behave. With Ollama now supporting non-Meta models, it makes sense to bring this into consistency across the board.

Thanks again — really appreciate the discussion and your help in figuring this out! 🙏

@Hephaest Hephaest changed the title fix(ollama): enable sentence mode by default for auto-translation fix(ollama): enable sentence and dictionary modes by default Jun 27, 2025
@Hephaest Hephaest changed the title fix(ollama): enable sentence and dictionary modes by default chore(ollama): enable sentence and dictionary modes by default Jun 27, 2025
@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Jun 27, 2025

ok, good 😊

@tisfeng tisfeng merged commit 244e8d5 into tisfeng:dev Jun 27, 2025
4 checks passed
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.

3 participants