From 10f84a5a1b1368975df98ad5dcd37f23f4b177b6 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 8 Jun 2026 19:04:08 +0200 Subject: [PATCH 1/2] Add support for dedicated OpenRouter model for web_fetch --- apps/api/src/services/fetch/fetch.service.ts | 21 +++++++++++++------- libs/common/src/lib/config.ts | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/api/src/services/fetch/fetch.service.ts b/apps/api/src/services/fetch/fetch.service.ts index 31034f81c..2425e476e 100644 --- a/apps/api/src/services/fetch/fetch.service.ts +++ b/apps/api/src/services/fetch/fetch.service.ts @@ -3,6 +3,7 @@ import { PropertyService } from '@ghostfolio/api/services/property/property.serv import { PROPERTY_API_KEY_OPENROUTER, PROPERTY_OPENROUTER_MODEL, + PROPERTY_OPENROUTER_MODEL_WEB_FETCH, PROPERTY_WEB_FETCH_ROUTES } from '@ghostfolio/common/config'; @@ -80,12 +81,18 @@ export class FetchService implements OnModuleInit { url: string; webFetchRoute: WebFetchRoute; }) { - const [openRouterApiKey, openRouterModel] = await Promise.all([ - this.propertyService.getByKey(PROPERTY_API_KEY_OPENROUTER), - this.propertyService.getByKey(PROPERTY_OPENROUTER_MODEL) - ]); - - if (!openRouterApiKey || !openRouterModel) { + const [openRouterApiKey, openRouterModel, openRouterModelWebFetch] = + await Promise.all([ + this.propertyService.getByKey(PROPERTY_API_KEY_OPENROUTER), + this.propertyService.getByKey(PROPERTY_OPENROUTER_MODEL), + this.propertyService.getByKey( + PROPERTY_OPENROUTER_MODEL_WEB_FETCH + ) + ]); + + const model = openRouterModelWebFetch || openRouterModel; + + if (!model || !openRouterApiKey) { return undefined; } @@ -93,7 +100,7 @@ export class FetchService implements OnModuleInit { const openRouterService = createOpenRouter({ apiKey: openRouterApiKey }); const { sources, text } = await generateText({ - model: openRouterService.chat(openRouterModel), + model: openRouterService.chat(model), prompt: [ 'You have access to a web_fetch tool. You MUST call it to retrieve the URL below, do not answer from prior knowledge.', 'Return the fetched response body exactly as received: raw body only, no commentary, no Markdown, and no code fences.', diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.ts index 5f2dd9a1c..7e7cd2ba5 100644 --- a/libs/common/src/lib/config.ts +++ b/libs/common/src/lib/config.ts @@ -252,6 +252,7 @@ export const PROPERTY_IS_DATA_GATHERING_ENABLED = 'IS_DATA_GATHERING_ENABLED'; export const PROPERTY_IS_READ_ONLY_MODE = 'IS_READ_ONLY_MODE'; export const PROPERTY_IS_USER_SIGNUP_ENABLED = 'IS_USER_SIGNUP_ENABLED'; export const PROPERTY_OPENROUTER_MODEL = 'OPENROUTER_MODEL'; +export const PROPERTY_OPENROUTER_MODEL_WEB_FETCH = 'OPENROUTER_MODEL_WEB_FETCH'; export const PROPERTY_SLACK_COMMUNITY_USERS = 'SLACK_COMMUNITY_USERS'; export const PROPERTY_STRIPE_CONFIG = 'STRIPE_CONFIG'; export const PROPERTY_SYSTEM_MESSAGE = 'SYSTEM_MESSAGE'; From 42112bccdaf365f02043eb01a37f53a961b808d6 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 8 Jun 2026 19:04:59 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07002a2d1..2da038365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added support for a dedicated _OpenRouter_ model for the `web_fetch` tool in the `FetchService` + ### Changed - Prefilled the form in the account balance management with the current cash balance