Repository navigation
feat(web-search): add Serply search backend - #718
Conversation
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]>
|
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]>
|
Thanks @haiphucnguyen. The CLA is signed, CLAassistant flipped the badge on this PR. Signing it also surfaced something I owe you a fix for: 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 All three One thing I noticed but did not touch: The three new workflow runs are sitting at |
|
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
left a comment
There was a problem hiding this comment.
LGTM. Thank you @googio !
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
What Changed & Why
SerplyBackend.ktis modelled onBraveBackend.kt: one GET, the key in a header,Accept-Encoding: gzip, andtitle/link/descriptionmapped intoSearchResult. Nothing new was introduced; it reuses the existinghttpGethelper andkotlinx.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: aSERPLYbranch. A blank key returnsnull, so the DuckDuckGo fallback takes over exactly as it does for Brave and Tavily.AppConfig.kt: the enum value, thewebsearch.serply.keyconstant, aserplyApiKeyfield with itsgetSecureSerplyKey/setSecureSerplyKeypair, the resolution in thewebSearchgetter, theupdateWebSearchFieldbranch, and theserply_api_key:line in the default YAML. The key goes throughSecureKeyManagerlike the other two, soaskimo.ymlonly ever holds the***keychain***placeholder.WebSearchSettingsSection.kt: state, the debounced keychain write, and the conditional field. This part is not optional: the dropdown iteratesWebSearchBackend.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.LocalizationManagerloads 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 recordedWebSearchConfigconstructor arity and agetSerplyApiKeyentry. Adding a constructor parameter invalidates the registered signature, andWebSearchConfigis not inAskimoFeature'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 testFor 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:
and the failure path surfaces the status rather than silently returning nothing:
./gradlew teston this branch: 1646 tests, 84 skipped, 0 failures.detektreports the same three findings onSerplyBackend.ktthat it already reports onBraveBackend.kt,TavilyBackend.ktandSearxNGBackend.kt(twoLabeledExpression, oneTooGenericExceptionCaught), and the build stays green.Screenshots / Recordings (if applicable)
None included. The new field calls the same
AppComponents.appSecretTextFieldand the samesettings.web_search.api_keystrings astavilyApiKeyField, so it renders identically to the Tavily field already in that pane, with the link pointing at serply.io instead.Checklist
main(07d848a)./gradlew spotlessApplyand./gradlew detektlocally./gradlew testand all tests passgit commit -sOn 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
httpGetreachesAppConfig.proxyand therefore needsAskimoHomeregistered. The scratch test I used above had to callAskimoHome.withTestBaseto get that far. If you want coverage here, the useful change is a seam (an injectable fetcher onSearchBackend, or a parse function split out fromsearch) 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.