Skip to content

feat: add You.com as a search backend#151

Open
ydc-oss-bot wants to merge 1 commit into
memfreeme:mainfrom
ydc-oss-bot:feat/youcom-search-provider
Open

feat: add You.com as a search backend#151
ydc-oss-bot wants to merge 1 commit into
memfreeme:mainfrom
ydc-oss-bot:feat/youcom-search-provider

Conversation

@ydc-oss-bot

Copy link
Copy Markdown

What

Adds You.com Search API as a selectable web search backend in MemFree, alongside the existing Serper (Google) and Exa backends.

Why

MemFree supports multiple search engines (Google, Exa, Vector) and CONTRIBUTING.md explicitly invites integrating additional search engines. You.com offers a free tier (100 searches/day, IP-based, no livecrawl) and returns web results + images, making it a natural drop-in alternative web backend.

How

  • New YouComSearch class (frontend/lib/search/youcom.ts) implementing the existing SearchSource interface. It calls POST https://api.you.com/v1/agents/search with the X-API-Key header (from YDC_API_KEY), then maps resultsTextSource[] and imagesImageSource[]. It reuses the existing fetchWithTimeout helper and logError, mirroring SerperSearch.
  • Registered in getSearchEngine (frontend/lib/search/search.ts) via the engines option that was already declared on SearchOptions but unused. Passing engines: ['youcom'] selects You.com; default behavior is unchanged (Serper remains the default for the ALL/TWEET categories, Exa for ACADEMIC).
  • Added YDC_API_KEY to frontend/lib/env.ts and frontend/env-example.
  • Added a moduleNameMapper for the @/ path alias to jest.config.js so path-aliased runtime imports resolve under Jest (previously only type-only @/ imports worked because they were erased during transform).
  • Added unit tests (frontend/lib/search/tests/youcom.test.ts) covering the request shape/response mapping and the error path.

API key

Uses YDC_API_KEY (the convention used across You.com's own docs and SDKs). Get a free key at https://api.you.com. Optional — if unset, the backend returns an empty result and logs the error, the same way Serper/Exa behave without keys.

Testing

cd frontend
npx jest lib/search/tests/youcom.test.ts

Both tests pass:

  • calls the You.com API with the right request and maps results
  • returns empty result and logs when the API errors

The pre-existing test suite (local-history, local-limit) is unaffected; the one pre-existing failure in local-history.test.ts predates this change.

Backward compatibility

No changes to default search behavior. You.com is opt-in via the engines option, so existing users see no difference unless they explicitly select it.

Add YouComSearch, a new SearchSource implementation that calls the
You.com Search API (POST https://api.you.com/v1/agents/search) and
maps results/images into MemFree's TextSource/ImageSource shapes.

You.com is selectable via the existing (previously unused) `engines`
option on SearchOptions: pass `engines: ['youcom']` to getSearchEngine
to use it instead of the default Serper backend. Default behavior is
unchanged.

- Add YDC_API_KEY env var (lib/env.ts, env-example)
- Register You.com in getSearchEngine (lib/search/search.ts)
- Add YouComSearch class (lib/search/youcom.ts)
- Add unit tests (lib/search/tests/youcom.test.ts)
- Add moduleNameMapper for @/ alias to jest.config.js so path-aliased
  runtime imports resolve under jest
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

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