Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1002 B
Raw Blame
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
    site: 'dictionary',
    name: 'examples',
    access: 'read',
    description: 'Read real-world example sentences utilizing the word',
    domain: 'api.dictionaryapi.dev',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        {
            name: 'word',
            type: 'string',
            required: true,
            positional: true,
            help: 'Word to get example sentences for',
        },
    ],
    columns: ['word', 'example'],
    pipeline: [
        { fetch: { url: 'https://api.dictionaryapi.dev/api/v2/entries/en/${{ args.word | urlencode }}' } },
        { map: {
                word: '${{ item.word }}',
                example: `\${{ (() => { if (item.meanings) { for (const m of item.meanings) { if (m.definitions) { for (const d of m.definitions) { if (d.example) return d.example; } } } } return 'No example found in API.'; })() }}`,
            } },
        { limit: 1 },
    ],
});