Skip to content

feat(web-search): add Serply search backend - #718

Merged
haiphucnguyen merged 2 commits into
askimo-ai:mainfrom
googio:feat/serply-search
Sep 14, 2026
Merged

haiphucnguyen merged 2 commits into
askimo-ai:mainfrom
googio:feat/serply-search

Conversation

@googio

@googio googio commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Serply as a fifth web search backend, alongside DuckDuckGo, Brave, Tavily and SearxNG. Serply returns Google organic results, which is the one index the current backends do not cover.

Related Issue(s)

None. I saw #260 inviting new contributors and CONTRIBUTING's "propose something new", so I opened this directly. Happy to file an issue first if you would rather discuss it before code.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

SerplyBackend.kt is modelled on BraveBackend.kt: one GET, the key in a header, Accept-Encoding: gzip, and title / link / description mapped into SearchResult. Nothing new was introduced; it reuses the existing httpGet helper and kotlinx.serialization, so there is no new dependency.

The rest is the plumbing every backend needs:

  • SearchBackend.kt: one line in the implementations list.
  • WebSearchDispatcher.kt: a SERPLY branch. A blank key returns null, so the DuckDuckGo fallback takes over exactly as it does for Brave and Tavily.
  • AppConfig.kt: the enum value, the websearch.serply.key constant, a serplyApiKey field with its getSecureSerplyKey / setSecureSerplyKey pair, the resolution in the webSearch getter, the updateWebSearchField branch, and the serply_api_key: line in the default YAML. The key goes through SecureKeyManager like the other two, so askimo.yml only ever holds the ***keychain*** placeholder.
  • WebSearchSettingsSection.kt: state, the debounced keychain write, and the conditional field. This part is not optional: the dropdown iterates WebSearchBackend.entries, so adding the enum value without a field would ship a selectable entry with nowhere to paste a key.
  • messages.properties: two keys. I only touched the English file. LocalizationManager loads the base English strings first as a fallback and then overlays the locale file, so both keys resolve in all ten locales rather than rendering as raw key names. I left the nine translated files alone because I cannot write those languages to the standard the existing entries are at. Say the word and I will copy the English strings in as placeholders.
  • README.md: the feature line now names Serply.
  • reachability-metadata.json: the recorded WebSearchConfig constructor arity and a getSerplyApiKey entry. Adding a constructor parameter invalidates the registered signature, and WebSearchConfig is not in AskimoFeature's explicit list, so the JSON is its only reflection registration for the native CLI. I edited it by hand rather than regenerating with -Pagent, which needs a GraalVM toolchain I do not have set up. Drop the file from the PR if you would rather regenerate it yourself.

How to Test

./gradlew spotlessCheck detekt test

For the backend itself: Settings, Web Search, pick Serply from the backend dropdown, paste a key from serply.io, and press Test Backend.

I also ran the class against the live API from a scratch test (not committed, see the Checklist note). Three results came back, correctly mapped:

name=Serply count=3
  - Coroutines | Kotlin Documentation | https://kotlinlang.org/docs/coroutines-overview.html
  - Kotlin coroutines on Android | https://developer.android.com/kotlin/coroutines
  - Kotlin/kotlinx.coroutines - GitHub | https://github.com/kotlin/kotlinx.coroutines

and the failure path surfaces the status rather than silently returning nothing:

WARN io.askimo.tools.web.SerplyBackend -- Serply returned HTTP 401: {"detail":"Invalid API key"}
bad key -> Serply API returned HTTP 401

./gradlew test on this branch: 1646 tests, 84 skipped, 0 failures. detekt reports the same three findings on SerplyBackend.kt that it already reports on BraveBackend.kt, TavilyBackend.kt and SearxNGBackend.kt (two LabeledExpression, one TooGenericExceptionCaught), and the build stays green.

Screenshots / Recordings (if applicable)

None included. The new field calls the same AppComponents.appSecretTextField and the same settings.web_search.api_key strings as tavilyApiKeyField, so it renders identically to the Tavily field already in that pane, with the link pointing at serply.io instead.

Checklist

  • I have read the CONTRIBUTING guide
  • My branch is up to date with main (07d848a)
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

On the tests box: I did not add one, and I would rather say why than leave it unchecked without comment. None of the four existing backends has a test, and as written they cannot be unit tested without network, because httpGet reaches AppConfig.proxy and therefore needs AskimoHome registered. The scratch test I used above had to call AskimoHome.withTestBase to get that far. If you want coverage here, the useful change is a seam (an injectable fetcher on SearchBackend, or a parse function split out from search) that would cover all five backends at once. I am happy to do that as a follow-up, or in this PR if you prefer it landed together.

Additional Notes

Serply support is optional; behavior is unchanged when no Serply key is set, and the default backend stays DuckDuckGo.

Disclosure: I work with Serply. Happy to adjust scope, naming, or drop this
entirely if it isn't a direction you want for the project.

Adds Serply as a fifth web search backend alongside DuckDuckGo, Brave,
Tavily and SearxNG. Serply returns Google organic results, which is the
one index the existing backends do not cover.

The backend mirrors BraveBackend: a single GET with the key in an
X-Api-Key header, gzip accepted, results mapped from title/link/
description into SearchResult. An empty key falls through to the
DuckDuckGo fallback in WebSearchDispatcher, same as Brave and Tavily.

The key is stored through SecureKeyManager like the other two, so
askimo.yml only ever holds the ***keychain*** placeholder.

Also updates the CLI reachability metadata for the new WebSearchConfig
constructor arity and adds the desktop settings field and dropdown
entry, since the dropdown iterates WebSearchBackend.entries.

Signed-off-by: serply <[email protected]>
@CLAassistant

CLAassistant commented Sep 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Thank you @googio . Serply looks like the interesting search solution. The PR looks good to me, can you sign the CLA then I can merge? Thank you

:desktop:checkI18nKeys compares every locale file against the base
messages.properties as a set, so shipping the two new keys in English
only failed format-check on all nine files.

Each description follows the file it lands in: the second sentence is
the neighbouring Tavily line re-vendored, so it keeps whatever wording
and punctuation that translator already chose for "Requires a <vendor>
API key". The vendor name itself stays "Serply" everywhere, matching
how Brave Search, Tavily and SearxNG are left untranslated.

One deviation worth flagging: messages_zh_CN.properties spells the term
for API key two ways, 密钥 in 35 places and 密鉅 in 10, including the
four lines in this settings block. The new line uses 密钥, the correct
and dominant spelling, rather than propagating the typo.

Signed-off-by: serply <[email protected]>
@googio

googio commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @haiphucnguyen. The CLA is signed, CLAassistant flipped the badge on this PR.

Signing it also surfaced something I owe you a fix for: format-check was red on the previous push. :desktop:checkI18nKeys compares every locale file against the base messages.properties as a set, so shipping the two new keys in English only failed on all nine translated files. The PR body says I left those files alone on purpose and offered to fill them in; the check is right to reject that, so 9aef8bc fills them in properly.

Each description follows the file it lands in. The second sentence is that file's own Tavily line re-vendored, so it keeps whatever wording and punctuation the translator there already chose for "Requires a API key", and the vendor name stays "Serply" the same way Brave Search, Tavily and SearxNG stay untranslated. I did not use TBT stubs because no locale file carries one today and the locale layer overlays the English base, so a stub would reach the UI. These files are Crowdin targets, so the next crowdin download will overwrite my wording with the translators' own, which is the right outcome.

All three format-check steps pass locally on JDK 25:

$ ./gradlew --no-daemon desktop:checkI18nKeys desktop:detectMissingLocalizations
> Task :desktop:checkI18nKeys
Found 1531 keys in base messages.properties
messages_de.properties - All keys present (1531 keys)
messages_es.properties - All keys present (1531 keys)
messages_fr.properties - All keys present (1531 keys)
messages_ja_JP.properties - All keys present (1531 keys)
messages_ko_KR.properties - All keys present (1531 keys)
messages_pt_BR.properties - All keys present (1531 keys)
messages_vi_VN.properties - All keys present (1531 keys)
messages_zh_CN.properties - All keys present (1531 keys)
messages_zh_TW.properties - All keys present (1531 keys)
All 9 language files have all required keys!

> Task :desktop:detectMissingLocalizations
Found 1531 existing keys in messages.properties
Found 1228 distinct key references in source code
No missing localization keys found!

BUILD SUCCESSFUL in 7s

$ ./gradlew --no-daemon spotlessCheck -PspotlessRatchetFrom=upstream/main
BUILD SUCCESSFUL in 7s

One thing I noticed but did not touch: messages_zh_CN.properties spells the term for API key two ways, 密钥 in 35 places and 密鉅 in 10, and the four web-search lines are among the 10. My new line uses 密钥, the correct and dominant spelling, rather than propagating the typo. The 10-line cleanup felt out of scope for a provider PR, but I am happy to send it as its own if you want it.

The three new workflow runs are sitting at action_required, so they need your approval to start.

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Nevermind, I will fix these issues in the follow up PR :). Wish you all the best with Serply

Since our doc is closed source (I wish user can edit the doc but it is integrated with our website now). So I am going to update the doc with new search solution is Serply.

@haiphucnguyen haiphucnguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thank you @googio !

@haiphucnguyen
haiphucnguyen merged commit f37fc6d into askimo-ai:main Sep 14, 2026
10 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