From fc5350123f97c4c6c2f2b0af6e8c744af9693f24 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 21 Jul 2025 18:40:57 -0700 Subject: [PATCH 1/3] update deep research api --- src/web/interfaces/deep_research.ts | 74 +++++++++++++++++++++++++++++ src/web/web.ts | 5 ++ 2 files changed, 79 insertions(+) create mode 100644 src/web/interfaces/deep_research.ts diff --git a/src/web/interfaces/deep_research.ts b/src/web/interfaces/deep_research.ts new file mode 100644 index 0000000..c4de3a6 --- /dev/null +++ b/src/web/interfaces/deep_research.ts @@ -0,0 +1,74 @@ +// Input parameters interface for reference +export interface DeepResearchParams { + query: string; + spell_check?: boolean; + safe_search?: "strict" | "moderate" | "off"; + country_code?: string; + max_depth?: number; + max_breadth?: number; + max_output_tokens?: number; + target_output_tokens?: number; +} + +export interface DeepResearchResponse { + success: boolean; + query: string; + results: string; + sources: SearchResult[]; + geo_results: GeoResult[]; + image_urls: string[]; + links: string[]; +} + +interface SearchResult { + title: string; + url: string; + description: string; + content: string | null; + site_name?: string; + site_long_name?: string; + age?: string; // ISO date string + language?: string; + image_urls: string[]; + links: string[]; + is_safe: boolean; + favicon: string; + thumbnail?: string; + snippets?: any[]; + related_index?: RelatedResult[]; +} + +interface RelatedResult { + title: string; + url: string; + description: string; + is_safe: boolean; +} + +interface GeoResult { + type: string; + full_address: string; + name: string; + name_preferred?: string; + place_formatted?: string; + postcode?: string; + district?: string; + place?: string; + region?: { + name: string; + region_code?: string; + region_code_full?: string; + }; + country?: { + name: string; + country_code?: string; + country_code_alpha_3?: string; + }; + language: string; + geoloc: { + type: string; + coordinates: [number, number]; // [longitude, latitude] + }; + poi_category?: string[]; + additional_properties?: any; +} diff --git a/src/web/web.ts b/src/web/web.ts index 0a83123..2bcddfa 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -2,6 +2,7 @@ import { respToFileChoice } from "../helpers"; import { RequestClient } from "../request"; import { HTMLAnyParams } from "./interfaces/html_to_any"; import { AIScrapeParams, AIScrapeResponse } from "./interfaces/scrape"; +import { DeepResearchParams, DeepResearchResponse } from "./interfaces/deep_research"; class Web { constructor(private readonly client: RequestClient) {} @@ -13,6 +14,10 @@ class Web { const resp = await this.client.fetchJSS("/web/html_to_any", "POST", params); return respToFileChoice(resp); }; + + deep_research = async (params: DeepResearchParams): Promise => { + return await this.client.fetchJSS("/web/deep_research", "POST", params); + }; } export default Web; From 5115ab8d4642972a5b5de2a999b6c6093da9c18a Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 21 Jul 2025 18:41:49 -0700 Subject: [PATCH 2/3] update types --- src/web/interfaces/deep_research.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/web/interfaces/deep_research.ts b/src/web/interfaces/deep_research.ts index c4de3a6..8d69030 100644 --- a/src/web/interfaces/deep_research.ts +++ b/src/web/interfaces/deep_research.ts @@ -21,9 +21,9 @@ export interface DeepResearchResponse { } interface SearchResult { - title: string; - url: string; - description: string; + title?: string; + url?: string; + description?: string; content: string | null; site_name?: string; site_long_name?: string; @@ -31,7 +31,7 @@ interface SearchResult { language?: string; image_urls: string[]; links: string[]; - is_safe: boolean; + is_safe?: boolean; favicon: string; thumbnail?: string; snippets?: any[]; @@ -39,10 +39,10 @@ interface SearchResult { } interface RelatedResult { - title: string; - url: string; - description: string; - is_safe: boolean; + title?: string; + url?: string; + description?: string; + is_safe?: boolean; } interface GeoResult { From 6dffafc35409b90897a7821d8e42612f8e5c582e Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 21 Jul 2025 18:43:59 -0700 Subject: [PATCH 3/3] linting --- src/validate/interfaces.ts | 2 +- src/web/web.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validate/interfaces.ts b/src/validate/interfaces.ts index ab2ef3d..4eaa84a 100644 --- a/src/validate/interfaces.ts +++ b/src/validate/interfaces.ts @@ -16,7 +16,7 @@ export interface NSFWValidationResponse { gore: boolean; nsfw_score: number; nudity_score: number; - gore_score: number; + gore_score: number; } export interface ProfanityParams { diff --git a/src/web/web.ts b/src/web/web.ts index 2bcddfa..fe9cdfe 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -1,8 +1,8 @@ import { respToFileChoice } from "../helpers"; import { RequestClient } from "../request"; +import { DeepResearchParams, DeepResearchResponse } from "./interfaces/deep_research"; import { HTMLAnyParams } from "./interfaces/html_to_any"; import { AIScrapeParams, AIScrapeResponse } from "./interfaces/scrape"; -import { DeepResearchParams, DeepResearchResponse } from "./interfaces/deep_research"; class Web { constructor(private readonly client: RequestClient) {}