d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
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
116 lines
3.4 KiB
TypeScript
116 lines
3.4 KiB
TypeScript
import type { PdlAutocompleteParams, PdlAutocompleteResponse } from '@/tools/peopledatalabs/types'
|
|
import { PEOPLEDATALABS_API_KEY_PREFIX } from '@/tools/peopledatalabs/types'
|
|
import { buildQueryString } from '@/tools/peopledatalabs/utils'
|
|
import type { OutputProperty, ToolConfig } from '@/tools/types'
|
|
|
|
const SUGGESTION_PROPERTIES = {
|
|
name: { type: 'string', description: 'Suggestion value' },
|
|
count: { type: 'number', description: 'Number of records matching this value' },
|
|
meta: {
|
|
type: 'object',
|
|
description: 'Field-specific metadata (e.g., for `company`: id, website, industry)',
|
|
optional: true,
|
|
},
|
|
} as const satisfies Record<string, OutputProperty>
|
|
|
|
export const autocompleteTool: ToolConfig<PdlAutocompleteParams, PdlAutocompleteResponse> = {
|
|
id: 'pdl_autocomplete',
|
|
name: 'PDL Autocomplete',
|
|
description:
|
|
'Get autocomplete suggestions for a PDL field (title, skill, company, industry, location, school, major, role, sub_role).',
|
|
version: '1.0.0',
|
|
|
|
hosting: {
|
|
envKeyPrefix: PEOPLEDATALABS_API_KEY_PREFIX,
|
|
apiKeyParam: 'apiKey',
|
|
byokProviderId: 'peopledatalabs',
|
|
// Autocomplete is free on PDL (rate-limited only) — no credits consumed.
|
|
pricing: { type: 'per_request', cost: 0 },
|
|
rateLimit: {
|
|
mode: 'per_request',
|
|
requestsPerMinute: 60,
|
|
},
|
|
},
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'People Data Labs API key',
|
|
},
|
|
field: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Field to autocomplete: all_location, class, company, country, industry, location_name, major, region, role, school, sub_role, skill, title, website',
|
|
},
|
|
text: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Search text prefix',
|
|
},
|
|
size: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Number of suggestions to return (1-100, default 10)',
|
|
},
|
|
titlecase: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Return name fields in title case',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const qs = buildQueryString({
|
|
field: params.field,
|
|
text: params.text,
|
|
size: params.size,
|
|
titlecase: params.titlecase,
|
|
})
|
|
return `https://api.peopledatalabs.com/v5/autocomplete${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>
|
|
|
|
if (!response.ok) {
|
|
const error = (data.error as { message?: string })?.message
|
|
throw new Error(error || `People Data Labs error: ${response.status}`)
|
|
}
|
|
|
|
const items =
|
|
(data.data as { name: string; count: number; meta?: Record<string, unknown> }[]) ?? []
|
|
return {
|
|
success: true,
|
|
output: {
|
|
suggestions: items.map((item) => ({
|
|
name: item.name,
|
|
count: item.count ?? 0,
|
|
meta: item.meta ?? undefined,
|
|
})),
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
suggestions: {
|
|
type: 'array',
|
|
description: 'Autocomplete suggestions ordered by frequency',
|
|
items: { type: 'object', properties: SUGGESTION_PROPERTIES },
|
|
},
|
|
},
|
|
}
|