d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
180 lines
4.8 KiB
TypeScript
180 lines
4.8 KiB
TypeScript
import type { PdlCompanyEnrichParams, PdlCompanyEnrichResponse } from '@/tools/peopledatalabs/types'
|
|
import {
|
|
PDL_COMPANY_OUTPUT_PROPERTIES,
|
|
PDL_CREDIT_USD,
|
|
PEOPLEDATALABS_API_KEY_PREFIX,
|
|
} from '@/tools/peopledatalabs/types'
|
|
import { buildQueryString, projectCompany } from '@/tools/peopledatalabs/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const companyEnrichTool: ToolConfig<PdlCompanyEnrichParams, PdlCompanyEnrichResponse> = {
|
|
id: 'pdl_company_enrich',
|
|
name: 'PDL Company Enrich',
|
|
description:
|
|
'Enrich a single company using People Data Labs. Match by name, website, LinkedIn URL, ticker, or PDL ID.',
|
|
version: '1.0.0',
|
|
|
|
hosting: {
|
|
envKeyPrefix: PEOPLEDATALABS_API_KEY_PREFIX,
|
|
apiKeyParam: 'apiKey',
|
|
byokProviderId: 'peopledatalabs',
|
|
pricing: {
|
|
type: 'custom',
|
|
// PDL charges 1 credit per matched request; misses (404) are free.
|
|
getCost: (_params, output) => {
|
|
const cost = output.matched === true ? PDL_CREDIT_USD : 0
|
|
return { cost, metadata: { credits: output.matched === true ? 1 : 0 } }
|
|
},
|
|
},
|
|
rateLimit: {
|
|
mode: 'per_request',
|
|
requestsPerMinute: 60,
|
|
},
|
|
},
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'People Data Labs API key',
|
|
},
|
|
name: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Company name',
|
|
},
|
|
website: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Company website domain',
|
|
},
|
|
profile: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'LinkedIn company URL',
|
|
},
|
|
ticker: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Stock ticker',
|
|
},
|
|
pdl_id: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'PDL company ID',
|
|
},
|
|
location: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Company location (helps disambiguate)',
|
|
},
|
|
locality: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'City',
|
|
},
|
|
region: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'State/region',
|
|
},
|
|
country: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Country',
|
|
},
|
|
min_likelihood: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Minimum match likelihood (1-10)',
|
|
},
|
|
required: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Required-fields expression',
|
|
},
|
|
titlecase: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Return name fields in title case',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const qs = buildQueryString({
|
|
name: params.name,
|
|
website: params.website,
|
|
profile: params.profile,
|
|
ticker: params.ticker,
|
|
pdl_id: params.pdl_id,
|
|
location: params.location,
|
|
locality: params.locality,
|
|
region: params.region,
|
|
country: params.country,
|
|
min_likelihood: params.min_likelihood,
|
|
required: params.required,
|
|
titlecase: params.titlecase,
|
|
})
|
|
return `https://api.peopledatalabs.com/v5/company/enrich${qs}`
|
|
},
|
|
method: 'GET',
|
|
headers: (params) => ({
|
|
'X-Api-Key': params.apiKey,
|
|
Accept: 'application/json',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = (await response.json()) as Record<string, unknown>
|
|
const status = (data.status as number) ?? response.status
|
|
|
|
if (status === 404) {
|
|
return { success: true, output: { matched: false, likelihood: null, company: null } }
|
|
}
|
|
|
|
if (!response.ok) {
|
|
const error = (data.error as { message?: string })?.message
|
|
throw new Error(error || `People Data Labs error: ${response.status}`)
|
|
}
|
|
|
|
const hasFields = data.name || data.website || data.id
|
|
return {
|
|
success: true,
|
|
output: {
|
|
matched: Boolean(hasFields),
|
|
likelihood: (data.likelihood as number) ?? null,
|
|
company: hasFields ? projectCompany(data) : null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
matched: { type: 'boolean', description: 'Whether a company record was matched' },
|
|
likelihood: {
|
|
type: 'number',
|
|
description: 'Match likelihood score (1-10), null if no match',
|
|
optional: true,
|
|
},
|
|
company: {
|
|
type: 'object',
|
|
description: 'Matched company record',
|
|
optional: true,
|
|
properties: PDL_COMPANY_OUTPUT_PROPERTIES,
|
|
},
|
|
},
|
|
}
|