命令行搜索工具

Airweave CLI是一个命令行界面工具,用于在连接的源中进行搜索,适合开发者和AI代理使用。

  • by airweave-ai
  • Python
  • 本地部署
  • 34 星标
  • 更新于
在 GitHub 查看 airweave-ai/cli

使用说明

Airweave命令行界面

命令行界面 Airweave。从任何终端搜索连接的源。专为开发人员和人工智能代理而构建。

安装

pip install airweave-cli

这将安装 airweave 二元的。

快速开始

# Set your API key
export AIRWEAVE_API_KEY="your-api-key"

# Search a collection
airweave search "quarterly revenue figures" --collection finance-data

# List collections
airweave collections list

认证

CLI按以下顺序解析凭据:

  1. AIRWEAVE_API_KEY 环境变量
  2. ~/.airweave/config.json (通过保存 airweave auth login)

对于交互式设置:

airweave auth login

这将提示您输入API密钥,对其进行验证,并将其保存在本地。

自托管

将CLI指向您自己的Airweave实例:

export AIRWEAVE_BASE_URL="https://airweave.internal.corp.com"

或者在 airweave auth login.

命令

搜索

airweave search "<query>" --collection <id> --mode classic --top-k 5
标志 短 默认 描述
--collection -c $AIRWEAVE_COLLECTION 集合可读ID
--mode -m classic 搜索模式: instant, classic,或 agentic
--top-k -k 10 结果数量
--offset 0 要跳过的结果(仅限即时/经典)

三种搜索模式:

  • 瞬间 --直接矢量搜索。最快,最适合简单查找。
  • 经典 --使用LLM生成的搜索计划进行AI优化搜索。 (默认)
  • 能动性 --对数据进行迭代搜索和推理的完整代理循环。
airweave search "error logs" --mode instant
airweave search "how does auth work?"                  # classic (default)
airweave search "summarize Q4 decisions" --mode agentic

管道:

airweave search "query" -c my-collection | jq '.results[0].textual_representation'

认证

airweave auth login     # interactive setup
airweave auth status    # show current auth state
airweave auth logout    # clear saved credentials

集合

airweave collections list                           # list all
airweave collections create --name "My Data"        # create
airweave collections get my-data-x7k9m              # get details

来源

airweave sources list --collection my-data          # list source connections
airweave sources sync <source-connection-id>        # trigger sync
airweave sources sync <id> --force                  # full re-sync

代理使用

CLI是为AI代理的非交互式使用而设计的。每个命令:

  • 将干净的JSON输出到stdout(默认)
  • 将所有错误发送到stderr
  • 使用正确的退出代码(0=成功,1=错误)

环境变量

export AIRWEAVE_API_KEY="sk-..."
export AIRWEAVE_COLLECTION="my-knowledge-base"
export AIRWEAVE_BASE_URL="https://api.airweave.ai"  # optional

管道

# Get the top result's content
airweave search "how to reset password" | jq -r '.results[0].textual_representation'

# Get the top result's source URL
airweave search "what is our refund policy" | jq -r '.results[0].web_url'

# List collection IDs
airweave collections list | jq -r '.[].readable_id'

CI/云功能

# GitHub Actions example
- name: Search Airweave
  env:
    AIRWEAVE_API_KEY: ${{ secrets.AIRWEAVE_API_KEY }}
    AIRWEAVE_COLLECTION: docs
  run: |
    result=$(airweave search "deployment guide")
    echo "$result" | jq '.results[:3]'

没有SDK导入,没有MCP服务器,没有配置文件——只有一个环境变量和一个shell。

配置

配置文件位置: ~/.airweave/config.json

{
  "api_key": "sk-...",
  "base_url": "https://api.airweave.ai",
  "collection": "my-default-collection"
}

所有设置的分辨率顺序:

  1. CLI标志(例如。 --collection)
  2. 环境变量(例如。 AIRWEAVE_COLLECTION)
  3. 配置文件
  4. 默认值/错误

贡献

git clone https://github.com/airweave-ai/cli.git
cd cli
poetry install
poetry run airweave --help