fix: OxylabsLoader request params and result processing (#5286)

Fix OxylabsLoader request params and result processing
This commit is contained in:
Rostyslav Borovyk 2025-10-03 02:56:51 +03:00 committed by GitHub
parent 9b8fee3d8f
commit 6fe5b98d6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 6 deletions

View File

@ -100,7 +100,7 @@ export class OxylabsLoader extends BaseDocumentLoader {
const params = { const params = {
source: this.params.source, source: this.params.source,
geo_location: this.params.geo_location, geo_location: this.params.geo_location,
render: this.params.render, render: this.params.render ? 'html' : null,
parse: this.params.parse, parse: this.params.parse,
user_agent_type: this.params.user_agent_type, user_agent_type: this.params.user_agent_type,
markdown: !this.params.parse, markdown: !this.params.parse,
@ -110,11 +110,14 @@ export class OxylabsLoader extends BaseDocumentLoader {
const response = await this.sendAPIRequest<OxylabsResponse>(params) const response = await this.sendAPIRequest<OxylabsResponse>(params)
const docs: OxylabsDocument[] = response.data.results.map((result, index) => ({ const docs: OxylabsDocument[] = response.data.results.map((result, index) => {
id: `${response.data.job.id.toString()}-${index}`, const content = typeof result.content === 'string' ? result.content : JSON.stringify(result.content)
pageContent: result.content, return {
metadata: {} id: `${response.data.job.id.toString()}-${index}`,
})) pageContent: content,
metadata: {}
}
})
return docs return docs
} }