SuperAPI AI Directory

dingtalk-knowledge-search

Office & productivity

View repository

Updated 10-15 17:29

About this skill

Usage

cd <the_skill_dir_path>/scripts
python3 cli.py config check
python3 cli.py search "关键词1 关键词2 关键词3"
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<node_id>"
python3 cli.py read <node_id>

Configuration

First run configuration validation:

python3 cli.py config check

These configurations are required:

Configuration Purpose How to obtain
DINGTALK_APP_KEY Call the DingTalk Open Platform API DingTalk Open Platform -> Application Management -> Enterprise Internal Application -> Credentials and Basic Information
DINGTALK_APP_SECRET Obtain API token Same as above, view in the application credential information
DINGTALK_MY_USER_ID Current operator identity Admin Console -> Contacts -> Member Management -> Click a member to view userId
DINGTALK_MY_OPERATOR_ID operatorId/unionId of the document API With DINGTALK_MY_USER_ID , it can be automatically converted

Missing DINGTALK_MY_OPERATOR_ID , execute:

python3 cli.py config to-unionid

What you get

  • search: Returns a list of matching documents; can use --limit <n> to control the number
  • read: Returns Markdown; long content will be written to a file and the path returned; non-ALIDOC files will be downloaded as original files
  • PDF to text:read <pdf_node_or_url> --mode pdf2text will first download the PDF, then use the system pdftotext -layout to output .txt; if the system does not have pdftotext, it will prompt to install poppler-utils, and fall back to returning the PDF path
  • Default output: write to the .skills-workspace/dingtalk-knowledge-search/outputs/
  • Project accumulation: use --output-dir "$PWD/dingtalk-docs" --output-path to write the result to the current project
  • Output cache: download/conversion results will be kept in the user-level cache directory, and the remote modifiedTime will be reused when unchanged; by default, hard links are used to write to --output-dir, use --output-strategy copy to copy and isolate
  • Image localization: use --with img-local, images will be downloaded to the same directory as the Markdown .assets/<文档名>/
  • Image proxy: use --with img, saves local space, but depends on the proxy service and the validity period of the original link
  • diagram: use --with diagram to export together

Examples

python3 cli.py search "项目背景 年假 晋升" --limit 10
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<node_id>" --output-dir "$PWD/dingtalk-docs" --output-path
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<node_id>" --with img-local --with diagram --output-dir "$PWD/dingtalk-docs" --output-path
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<file_node_id>" --output-dir "$PWD/dingtalk-docs"
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<pdf_node_id>" --mode pdf2text --output-dir "$PWD/dingtalk-docs"
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<pdf_node_id>" --mode pdf2text --output-dir "$PWD/dingtalk-docs" --output-strategy copy

Cache

  • search Not cached, directly query the remote every time
  • node、resolve-url、blocks Still uses the SQLite API cache, affected by --cache-ttl influence
  • Output file cache is not affected by TTL, uses the remote modifiedTime to determine whether to reuse
  • Default output cache location:~/.dingtalk-skills/dingtalk-knowledge-search/output-cache/
  • Default --output-strategy link: hard-link the global cache to the current --output-dir, saving space; editing any hard-linked file will affect the same content
  • --output-strategy copy: copy to the current --output-dir, isolated from the global cache
  • python3 cli.py cache clear --namespace output --yes will delete output cache records and associated local files

Login

  • When a QR code scan is required, the command will return loginRequired: true and screenshotPath
  • After scanning the QR code, re-execute the same command