Skip to content

Commit 29f5cbd

Browse files
authored
feat: add dev get html skeleton tool (#273)
* feat: add dev get html skeleton tool * rename page to chunk
1 parent 3977986 commit 29f5cbd

File tree

11 files changed

+494
-30
lines changed

11 files changed

+494
-30
lines changed

package-lock.json

Lines changed: 166 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
"@apify/datastructures": "^2.0.3",
3939
"@apify/log": "^2.5.16",
4040
"@modelcontextprotocol/sdk": "^1.17.4",
41+
"@types/cheerio": "^0.22.35",
4142
"@types/turndown": "^5.0.5",
4243
"ajv": "^8.17.1",
4344
"algoliasearch": "^5.31.0",
4445
"apify": "^3.4.2",
4546
"apify-client": "^2.12.6",
47+
"cheerio": "^1.1.2",
4648
"express": "^4.21.2",
4749
"to-json-schema": "^0.2.5",
4850
"turndown": "^7.2.0",
@@ -71,6 +73,7 @@
7173
"start": "npm run start:dev",
7274
"start:prod": "node dist/main.js",
7375
"start:dev": "tsx src/main.ts",
76+
"start:standby": "APIFY_META_ORIGIN=STANDBY npm run start",
7477
"lint": "eslint .",
7578
"lint:fix": "eslint . --fix",
7679
"build": "tsc -b src",

src/const.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ export enum HelperTools {
4444
STORE_SEARCH = 'search-actors',
4545
DOCS_SEARCH = 'search-apify-docs',
4646
DOCS_FETCH = 'fetch-apify-docs',
47+
GET_HTML_SKELETON = 'get-html-skeleton',
4748
}
4849

50+
export const ACTOR_RAG_WEB_BROWSER = 'apify/rag-web-browser';
51+
4952
export const defaults = {
5053
actors: [
51-
'apify/rag-web-browser',
54+
ACTOR_RAG_WEB_BROWSER,
5255
],
5356
};
5457

@@ -67,6 +70,8 @@ export const ACTOR_CACHE_MAX_SIZE = 500;
6770
export const ACTOR_CACHE_TTL_SECS = 30 * 60; // 30 minutes
6871
export const APIFY_DOCS_CACHE_MAX_SIZE = 500;
6972
export const APIFY_DOCS_CACHE_TTL_SECS = 60 * 60; // 1 hour
73+
export const GET_HTML_SKELETON_CACHE_TTL_SECS = 5 * 60; // 5 minutes
74+
export const GET_HTML_SKELETON_CACHE_MAX_SIZE = 200;
7075

7176
export const ACTOR_PRICING_MODEL = {
7277
/** Rental Actors */

src/state.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import { ACTOR_CACHE_MAX_SIZE, ACTOR_CACHE_TTL_SECS, APIFY_DOCS_CACHE_MAX_SIZE, APIFY_DOCS_CACHE_TTL_SECS } from './const.js';
1+
import {
2+
ACTOR_CACHE_MAX_SIZE,
3+
ACTOR_CACHE_TTL_SECS,
4+
APIFY_DOCS_CACHE_MAX_SIZE,
5+
APIFY_DOCS_CACHE_TTL_SECS,
6+
GET_HTML_SKELETON_CACHE_MAX_SIZE,
7+
GET_HTML_SKELETON_CACHE_TTL_SECS,
8+
} from './const.js';
29
import type { ActorDefinitionPruned, ApifyDocsSearchResult } from './types.js';
310
import { TTLLRUCache } from './utils/ttl-lru.js';
411

512
export const actorDefinitionPrunedCache = new TTLLRUCache<ActorDefinitionPruned>(ACTOR_CACHE_MAX_SIZE, ACTOR_CACHE_TTL_SECS);
613
export const searchApifyDocsCache = new TTLLRUCache<ApifyDocsSearchResult[]>(APIFY_DOCS_CACHE_MAX_SIZE, APIFY_DOCS_CACHE_TTL_SECS);
714
/** Stores processed Markdown content */
815
export const fetchApifyDocsCache = new TTLLRUCache<string>(APIFY_DOCS_CACHE_MAX_SIZE, APIFY_DOCS_CACHE_TTL_SECS);
16+
/** Stores HTML content per URL so we can paginate the tool output */
17+
export const getHtmlSkeletonCache = new TTLLRUCache<string>(GET_HTML_SKELETON_CACHE_MAX_SIZE, GET_HTML_SKELETON_CACHE_TTL_SECS);

0 commit comments

Comments
 (0)