Spaces:
Sleeping
Sleeping
Download apps/api/src/search/transform.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/search/transform.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/search/transform.ts
-
curl -L -o transform.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/search/transform.ts
1.35 kB
| import { Document } from "../controllers/v2/types"; | |
| import { SearchV2Response } from "../lib/entities"; | |
| export function transformToV1Response( | |
| searchResponse: SearchV2Response, | |
| ): Document[] { | |
| const documents: Document[] = []; | |
| if (searchResponse.web && searchResponse.web.length > 0) { | |
| for (const item of searchResponse.web) { | |
| documents.push({ | |
| ...item, | |
| url: item.url, | |
| title: item.title, | |
| description: item.description, | |
| } as Document); | |
| } | |
| } | |
| if (searchResponse.news && searchResponse.news.length > 0) { | |
| for (const item of searchResponse.news) { | |
| if (item.url) { | |
| documents.push({ | |
| ...item, | |
| url: item.url, | |
| title: item.title || "", | |
| description: item.snippet || "", | |
| } as Document); | |
| } | |
| } | |
| } | |
| if (searchResponse.images && searchResponse.images.length > 0) { | |
| for (const item of searchResponse.images) { | |
| if (item.url) { | |
| documents.push({ | |
| ...item, | |
| url: item.url, | |
| title: item.title || "", | |
| description: "", | |
| } as Document); | |
| } | |
| } | |
| } | |
| return documents; | |
| } | |
| export function filterDocumentsWithContent(documents: Document[]): Document[] { | |
| return documents.filter( | |
| doc => doc.serpResults || (doc.markdown && doc.markdown.trim().length > 0), | |
| ); | |
| } | |