alibabacloud-iqs-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesealibabacloud-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
搜索参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Search query (1-500 chars) |
| string | No | | Search engine type |
| string | No | | Time range filter |
| string | No | - | Type of return content |
| int | No | | Number of search results (1-10) |
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| string | 是 | - | 搜索关键词(1-500字符) |
| string | 否 | | 搜索引擎类型 |
| string | 否 | | 时间范围过滤 |
| string | 否 | - | 返回内容类型 |
| int | 否 | | 搜索结果数量(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- : Semantic search, 1-50 results, general use
LiteAdvanced - : Fast, 10 results, news/realtime
Generic
3. Time Range Selection ()
--timeRange- : Default when uncertain - engine optimizes based on query relevance
NoLimit - : Today only
OneDay - : Last 7 days
OneWeek - : Last 30 days
OneMonth - : Last 365 days
OneYear
4. Content Return ()
--contents- : Return full main text content - Use when detailed information is needed, such as technical documentation, research reports, or in-depth articles
mainText - : Return concise summary only - Use when a quick overview is sufficient, or when the page content is too large and token reduction is needed
summary
5. Result Count ()
--numResults- Control number of results returned (default: 10, range: 1-10)
1. 查询词优化()
--query- 保持查询简洁(最佳效果建议控制在30字符以内)
- 使用具体关键词,避免停用词
- 搜索新闻时:在查询中加入时间上下文
2. 引擎选择()
--engineType- :语义搜索,返回1-50条结果,通用场景
LiteAdvanced - :速度快,返回10条结果,适合新闻/实时信息搜索
Generic
3. 时间范围选择()
--timeRange- :不确定时的默认值,引擎会根据查询相关性优化结果
NoLimit - :仅当天
OneDay - :近7天
OneWeek - :近30天
OneMonth - :近365天
OneYear
4. 返回内容设置()
--contents- :返回完整正文内容,适用于需要详细信息的场景,比如技术文档、研究报告或深度文章
mainText - :仅返回简明摘要,适用于只需要快速概览,或页面内容过大需要减少token消耗的场景
summary
5. 结果数量设置()
--numResults- 控制返回的结果数量(默认:10,范围:1-10)
ReadPage Parameters
页面读取参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Target page URL |
| string | No | | Return format |
| number | No | | Total timeout in milliseconds |
| number | No | | Page load timeout in milliseconds |
| number | No | | Enable stealth mode (0 or 1) |
| boolean | No | | Extract main article content only |
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| string | 是 | - | 目标页面URL |
| string | 否 | | 返回格式 |
| number | 否 | | 总超时时间,单位毫秒 |
| number | 否 | | 页面加载超时时间,单位毫秒 |
| number | 否 | | 启用隐身模式(0或1) |
| boolean | 否 | | 仅提取正文内容 |
ReadPage Best Practices
页面读取最佳实践
1. Format Selection ()
--format- : Best for articles, preserves structure (default)
markdown - : Best for data extraction
text - : When structure analysis needed
html
2. Article Extraction ()
--extractArticle- Enable for: blogs, news articles
- Disable for: product pages, directories
3. Handling Failures (, )
--timeout--stealth- If timeout: Retry with increased value
--timeout - 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 LiteAdvancedbash
node scripts/search.mjs --query "量子计算原理" --engineType LiteAdvancedReal-time Information Search
实时信息搜索
bash
node scripts/search.mjs --query "最新金融政策" --engineType Generic --timeRange OneWeekbash
node scripts/search.mjs --query "最新金融政策" --engineType Generic --timeRange OneWeekSearch with Results Limit
限制返回结果数量的搜索
bash
node scripts/search.mjs --query "www.aliyun.com" --engineType LiteAdvanced --numResults 3bash
node scripts/search.mjs --query "www.aliyun.com" --engineType LiteAdvanced --numResults 3Search with Full Content
返回完整内容的搜索
bash
node scripts/search.mjs --query "AI 法案" --engineType LiteAdvanced --contents mainTextbash
node scripts/search.mjs --query "AI 法案" --engineType LiteAdvanced --contents mainTextSearch with Summary Only
仅返回摘要的搜索
bash
node scripts/search.mjs --query "人工智能行业年度报告" --engineType LiteAdvanced --contents summarybash
node scripts/search.mjs --query "人工智能行业年度报告" --engineType LiteAdvanced --contents summaryReadPage Examples
页面读取示例
Page Reading with Markdown Format
Markdown格式页面读取
bash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --extractArticle truebash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --extractArticle truePage Reading with Plain Text Format
纯文本格式页面读取
bash
node scripts/readpage.mjs --url "https://example.com/article" --format text --timeout 60000bash
node scripts/readpage.mjs --url "https://example.com/article" --format text --timeout 60000Page Reading with Stealth Mode
隐身模式页面读取
bash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --stealth 1 --extractArticle truebash
node scripts/readpage.mjs --url "https://example.com/article" --format markdown --stealth 1 --extractArticle trueError 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/envbash
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/envbash
ALIYUN_IQS_API_KEY=your-api-key