alibabacloud-iqs-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

alibabacloud-iqs-search

alibabacloud-iqs-search

Prerequisites

前置要求

  • Node.js >= 18.0.0 (scripts use native fetch API, no external npm dependencies)
  • Node.js >= 18.0.0(脚本使用原生fetch API,无额外npm依赖)

When to Use

适用场景

  • User asks for current/recent information
  • User provides a URL to read
  • Need to verify facts or get real-time data
  • Research tasks requiring multiple sources
  • 用户查询当前/最新信息
  • 用户提供需要读取的URL
  • 需要核实事实或获取实时数据
  • 需要多来源支持的调研任务

Decision Tree

决策树

Step 1: Determine Operation Type

步骤1:确定操作类型

  • If user provides a URL → Use
    readpage
  • If user asks a question needing web info → Use
    search
  • 如果用户提供了URL → 使用
    readpage
  • 如果用户的问题需要网页信息支持 → 使用
    search

Step 2: For Search Operations

步骤2:搜索操作处理

Follow the best practices to determine parameter values. Use default values when uncertain:
  • engineType
  • timeRange
  • contents
遵循最佳实践确定参数值,不确定时使用默认值:
  • engineType
  • timeRange
  • contents

Step 3: For Page Reading

步骤3:页面读取操作处理

Follow the best practices to determine parameter values. Use default values when uncertain:
  • format
  • extractArticle
  • stealthMode
遵循最佳实践确定参数值,不确定时使用默认值:
  • format
  • extractArticle
  • stealthMode

Parameters & Best Practices

参数说明与最佳实践

Search Parameters

搜索参数

ParameterTypeRequiredDefaultDescription
--query
stringYes-Search query (1-500 chars)
--engineType
stringNo
LiteAdvanced
Search engine type
--timeRange
stringNo
NoLimit
Time range filter
--contents
stringNo-Type of return content
--numResults
intNo
10
Number of search results (1-10)
参数类型必填默认值说明
--query
string-搜索关键词(1-500字符)
--engineType
string
LiteAdvanced
搜索引擎类型
--timeRange
string
NoLimit
时间范围过滤
--contents
string-返回内容类型
--numResults
int
10
搜索结果数量(1-10)

Search Best Practices

搜索最佳实践

1. Query Optimization (
--query
)
  • Keep queries concise (< 30 chars for best results)
  • Use specific keywords, avoid stop words
  • For news: include time context in query
2. Engine Selection (
--engineType
)
  • LiteAdvanced
    : Semantic search, 1-50 results, general use
  • Generic
    : Fast, 10 results, news/realtime
3. Time Range Selection (
--timeRange
)
  • NoLimit
    : Default when uncertain - engine optimizes based on query relevance
  • OneDay
    : Today only
  • OneWeek
    : Last 7 days
  • OneMonth
    : Last 30 days
  • OneYear
    : Last 365 days
4. Content Return (
--contents
)
  • mainText
    : Return full main text content - Use when detailed information is needed, such as technical documentation, research reports, or in-depth articles
  • summary
    : Return concise summary only - Use when a quick overview is sufficient, or when the page content is too large and token reduction is needed
5. Result Count (
--numResults
)
  • Control number of results returned (default: 10, range: 1-10)

1. 查询词优化(
--query
  • 保持查询简洁(最佳效果建议控制在30字符以内)
  • 使用具体关键词,避免停用词
  • 搜索新闻时:在查询中加入时间上下文
2. 引擎选择(
--engineType
  • LiteAdvanced
    :语义搜索,返回1-50条结果,通用场景
  • Generic
    :速度快,返回10条结果,适合新闻/实时信息搜索
3. 时间范围选择(
--timeRange
  • NoLimit
    :不确定时的默认值,引擎会根据查询相关性优化结果
  • OneDay
    :仅当天
  • OneWeek
    :近7天
  • OneMonth
    :近30天
  • OneYear
    :近365天
4. 返回内容设置(
--contents
  • mainText
    :返回完整正文内容,适用于需要详细信息的场景,比如技术文档、研究报告或深度文章
  • summary
    :仅返回简明摘要,适用于只需要快速概览,或页面内容过大需要减少token消耗的场景
5. 结果数量设置(
--numResults
  • 控制返回的结果数量(默认:10,范围:1-10)

ReadPage Parameters

页面读取参数

ParameterTypeRequiredDefaultDescription
--url
stringYes-Target page URL
--format
stringNo
markdown
Return format
--timeout
numberNo
60000
Total timeout in milliseconds
--pageTimeout
numberNo
15000
Page load timeout in milliseconds
--stealth
numberNo
0
Enable stealth mode (0 or 1)
--extractArticle
booleanNo
false
Extract main article content only
参数类型必填默认值说明
--url
string-目标页面URL
--format
string
markdown
返回格式
--timeout
number
60000
总超时时间,单位毫秒
--pageTimeout
number
15000
页面加载超时时间,单位毫秒
--stealth
number
0
启用隐身模式(0或1)
--extractArticle
boolean
false
仅提取正文内容

ReadPage Best Practices

页面读取最佳实践

1. Format Selection (
--format
)
  • markdown
    : Best for articles, preserves structure (default)
  • text
    : Best for data extraction
  • html
    : When structure analysis needed
2. Article Extraction (
--extractArticle
)
  • Enable for: blogs, news articles
  • Disable for: product pages, directories
3. Handling Failures (
--timeout
,
--stealth
)
  • If timeout: Retry with increased
    --timeout
    value
  • If blocked: Enable
    --stealth 1
  • If still fails: Report to user
1. 格式选择(
--format
  • markdown
    :最适合文章场景,可保留结构(默认值)
  • text
    :最适合数据提取场景
  • html
    :需要结构分析时使用
2. 正文提取设置(
--extractArticle
  • 启用场景:博客、新闻文章
  • 禁用场景:产品页、目录页
3. 故障处理(
--timeout
--stealth
  • 如果超时:调大
    --timeout
    值后重试
  • 如果被拦截:启用
    --stealth 1
  • 如果仍然失败:告知用户

Command Line Usage

命令行使用

Search Examples

搜索示例

Basic Search

基础搜索

bash
node scripts/search.mjs --query "量子计算原理" --engineType LiteAdvanced
bash
node scripts/search.mjs --query "量子计算原理" --engineType LiteAdvanced

Real-time Information Search

实时信息搜索

bash
node scripts/search.mjs --query "最新金融政策" --engineType Generic --timeRange OneWeek
bash
node scripts/search.mjs --query "最新金融政策" --engineType Generic --timeRange OneWeek

Search with Results Limit

限制返回结果数量的搜索

bash
node scripts/search.mjs --query "www.aliyun.com" --engineType LiteAdvanced --numResults 3
bash
node scripts/search.mjs --query "www.aliyun.com" --engineType LiteAdvanced --numResults 3

Search with Full Content

返回完整内容的搜索

bash
node scripts/search.mjs --query "AI 法案" --engineType LiteAdvanced --contents mainText
bash
node scripts/search.mjs --query "AI 法案" --engineType LiteAdvanced --contents mainText

Search with Summary Only

仅返回摘要的搜索

bash
node scripts/search.mjs --query "人工智能行业年度报告" --engineType LiteAdvanced --contents summary
bash
node scripts/search.mjs --query "人工智能行业年度报告" --engineType LiteAdvanced --contents summary

ReadPage Examples

页面读取示例

Page Reading with Markdown Format

Markdown格式页面读取

bash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --extractArticle true
bash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --extractArticle true

Page Reading with Plain Text Format

纯文本格式页面读取

bash
node scripts/readpage.mjs --url "https://example.com/article" --format text --timeout 60000
bash
node scripts/readpage.mjs --url "https://example.com/article" --format text --timeout 60000

Page Reading with Stealth Mode

隐身模式页面读取

bash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --stealth 1 --extractArticle true
bash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --stealth 1 --extractArticle true

Error Handling

错误处理

ALIYUN_IQS_API_KEY Configuration Error

ALIYUN_IQS_API_KEY配置错误

If the API Key is not configured, prompt the user to visit the IQS official website to obtain an API Key and configure it using one of the following methods:
Method 1: Environment Variable
bash
export ALIYUN_IQS_API_KEY="your-api-key"
Method 2: Configuration File
Create or edit
~/.alibabacloud/iqs/env
:
bash
ALIYUN_IQS_API_KEY=your-api-key
如果未配置API Key,提示用户访问IQS官方网站获取API Key,并使用以下任意一种方式配置:
方式1:环境变量
bash
export ALIYUN_IQS_API_KEY="your-api-key"
方式2:配置文件
创建或编辑
~/.alibabacloud/iqs/env
bash
ALIYUN_IQS_API_KEY=your-api-key