chore: import upstream snapshot with attribution
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
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
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import { searchTool } from '@/tools/duckduckgo/search'
|
||||
|
||||
export const duckduckgoSearchTool = searchTool
|
||||
@@ -0,0 +1,189 @@
|
||||
import type { DuckDuckGoSearchParams, DuckDuckGoSearchResponse } from '@/tools/duckduckgo/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const searchTool: ToolConfig<DuckDuckGoSearchParams, DuckDuckGoSearchResponse> = {
|
||||
id: 'duckduckgo_search',
|
||||
name: 'DuckDuckGo Search',
|
||||
description:
|
||||
'Search the web using DuckDuckGo Instant Answers API. Returns instant answers, abstracts, and related topics for your query. Free to use without an API key.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
query: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The search query to execute',
|
||||
},
|
||||
noHtml: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Remove HTML from text in results (default: true)',
|
||||
},
|
||||
skipDisambig: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Skip disambiguation results (default: false)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const baseUrl = 'https://api.duckduckgo.com/'
|
||||
const searchParams = new URLSearchParams({
|
||||
q: params.query,
|
||||
format: 'json',
|
||||
no_html: params.noHtml !== false ? '1' : '0',
|
||||
skip_disambig: params.skipDisambig ? '1' : '0',
|
||||
})
|
||||
return `${baseUrl}?${searchParams.toString()}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
Accept: 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
const mapTopic = (topic: any) => ({
|
||||
FirstURL: topic.FirstURL,
|
||||
Text: topic.Text,
|
||||
Result: topic.Result,
|
||||
Icon: topic.Icon
|
||||
? {
|
||||
URL: topic.Icon.URL,
|
||||
Height: topic.Icon.Height,
|
||||
Width: topic.Icon.Width,
|
||||
}
|
||||
: undefined,
|
||||
})
|
||||
|
||||
/**
|
||||
* RelatedTopics may contain nested disambiguation groups of the shape
|
||||
* `{ Name, Topics: [...] }`. Flatten those so the actual topics are
|
||||
* surfaced instead of empty objects.
|
||||
*/
|
||||
const relatedTopics = (data.RelatedTopics || []).flatMap((topic: any) =>
|
||||
Array.isArray(topic.Topics) ? topic.Topics.map(mapTopic) : [mapTopic(topic)]
|
||||
)
|
||||
|
||||
// Map results (external links)
|
||||
const results = (data.Results || []).map((result: any) => ({
|
||||
FirstURL: result.FirstURL,
|
||||
Text: result.Text,
|
||||
Result: result.Result,
|
||||
Icon: result.Icon
|
||||
? {
|
||||
URL: result.Icon.URL,
|
||||
Height: result.Icon.Height,
|
||||
Width: result.Icon.Width,
|
||||
}
|
||||
: undefined,
|
||||
}))
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
heading: data.Heading || '',
|
||||
abstract: data.Abstract || '',
|
||||
abstractText: data.AbstractText || '',
|
||||
abstractSource: data.AbstractSource || '',
|
||||
abstractURL: data.AbstractURL || '',
|
||||
definition: data.Definition || '',
|
||||
definitionSource: data.DefinitionSource || '',
|
||||
definitionURL: data.DefinitionURL || '',
|
||||
image: data.Image || '',
|
||||
answer: data.Answer || '',
|
||||
answerType: data.AnswerType || '',
|
||||
type: data.Type || '',
|
||||
redirect: data.Redirect || '',
|
||||
relatedTopics,
|
||||
results,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
heading: {
|
||||
type: 'string',
|
||||
description: 'The heading/title of the instant answer',
|
||||
},
|
||||
abstract: {
|
||||
type: 'string',
|
||||
description: 'A short abstract summary of the topic',
|
||||
},
|
||||
abstractText: {
|
||||
type: 'string',
|
||||
description: 'Plain text version of the abstract',
|
||||
},
|
||||
abstractSource: {
|
||||
type: 'string',
|
||||
description: 'The source of the abstract (e.g., Wikipedia)',
|
||||
},
|
||||
abstractURL: {
|
||||
type: 'string',
|
||||
description: 'URL to the source of the abstract',
|
||||
},
|
||||
definition: {
|
||||
type: 'string',
|
||||
description: 'Dictionary-style definition if available',
|
||||
},
|
||||
definitionSource: {
|
||||
type: 'string',
|
||||
description: 'The source of the definition',
|
||||
},
|
||||
definitionURL: {
|
||||
type: 'string',
|
||||
description: 'URL to the source of the definition',
|
||||
},
|
||||
image: {
|
||||
type: 'string',
|
||||
description: 'URL to an image related to the topic',
|
||||
},
|
||||
answer: {
|
||||
type: 'string',
|
||||
description: 'Direct answer if available (e.g., for calculations)',
|
||||
},
|
||||
answerType: {
|
||||
type: 'string',
|
||||
description: 'Type of the answer (e.g., calc, ip, etc.)',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Response type: A (article), D (disambiguation), C (category), N (name), E (exclusive)',
|
||||
},
|
||||
redirect: {
|
||||
type: 'string',
|
||||
description: '!bang redirect URL, populated only for bang queries',
|
||||
},
|
||||
relatedTopics: {
|
||||
type: 'array',
|
||||
description: 'Array of related topics with URLs and descriptions',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
FirstURL: { type: 'string', description: 'URL to the related topic' },
|
||||
Text: { type: 'string', description: 'Description of the related topic' },
|
||||
Result: { type: 'string', description: 'HTML result snippet' },
|
||||
},
|
||||
},
|
||||
},
|
||||
results: {
|
||||
type: 'array',
|
||||
description: 'Array of external link results',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
FirstURL: { type: 'string', description: 'URL of the result' },
|
||||
Text: { type: 'string', description: 'Description of the result' },
|
||||
Result: { type: 'string', description: 'HTML result snippet' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Common types for DuckDuckGo tools
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
// Search tool types
|
||||
export interface DuckDuckGoSearchParams {
|
||||
query: string
|
||||
noHtml?: boolean
|
||||
skipDisambig?: boolean
|
||||
}
|
||||
|
||||
interface DuckDuckGoRelatedTopic {
|
||||
FirstURL?: string
|
||||
Text?: string
|
||||
Result?: string
|
||||
Icon?: {
|
||||
URL?: string
|
||||
Height?: number | string
|
||||
Width?: number | string
|
||||
}
|
||||
}
|
||||
|
||||
interface DuckDuckGoResult {
|
||||
FirstURL?: string
|
||||
Text?: string
|
||||
Result?: string
|
||||
Icon?: {
|
||||
URL?: string
|
||||
Height?: number | string
|
||||
Width?: number | string
|
||||
}
|
||||
}
|
||||
|
||||
interface DuckDuckGoSearchOutput {
|
||||
heading: string
|
||||
abstract: string
|
||||
abstractText: string
|
||||
abstractSource: string
|
||||
abstractURL: string
|
||||
definition: string
|
||||
definitionSource: string
|
||||
definitionURL: string
|
||||
image: string
|
||||
answer: string
|
||||
answerType: string
|
||||
type: string
|
||||
redirect: string
|
||||
relatedTopics: DuckDuckGoRelatedTopic[]
|
||||
results: DuckDuckGoResult[]
|
||||
}
|
||||
|
||||
export interface DuckDuckGoSearchResponse extends ToolResponse {
|
||||
output: DuckDuckGoSearchOutput
|
||||
}
|
||||
|
||||
export type DuckDuckGoResponse = DuckDuckGoSearchResponse
|
||||
Reference in New Issue
Block a user