ixp
latest
false
UiPath logo, featuring letters U and I in white

Communications Mining 用户指南

上次更新日期 2025年8月11日

配置 CLI

This section covers how to authenticate and configure re. It assumes you have installed the CLI. For more details, check the installation instructions.

The quick setup section is a short step-by-step reference for how to get started and configure the CLI. The rest of the page contains detailed instructions and goes into all of the available options.

快速设置

Install the command line tool for your platform (Linux, Mac, and Windows are supported).

Create a named context to avoid having to enter your tenant endpoint and API token every time. Provide your tenant endpoint:

re config add --name main --endpoint https://<my_api_endpoint>/re config add --name main --endpoint https://<my_api_endpoint>/

You will be asked to paste your API token:

I A new context `main` will be created.
  Enter API token [none]: MYSUPERSECRETTOKEN
I New context `main` was created.I A new context `main` will be created.
  Enter API token [none]: MYSUPERSECRETTOKEN
I New context `main` was created.

尝试运行命令以检查是否一切正常,例如

re get datasetsre get datasets
您可以使用-c--context全局标志,以在命令中使用特定上下文,例如
re -c main get datasetsre -c main get datasets
可以使用全局标志 (例如--token--endpoint--proxy等) 一次性覆盖任何上下文设置。命令行参数优先于上下文设置。

每次都提供凭据

对 CLI 进行身份验证的最简单方法是为每个命令指定端点和 API 令牌。 默认情况下, re将提示您以交互方式输入令牌。

例如,列出可用的数据集

➜ re --endpoint https://acme.reinfer.io get datasets
input: Enter API token [none]: MYSUPERSECRETAPITOKEN
 Name                                ID                Updated (UTC)        Title
 InvestmentBank/collateral-streams  aa9dda7c059e5a8d  2019-04-30 17:25:03  IB Collateral Streams
 InvestmentBank/george-test          1aaeacd49dfce8a0  2019-05-10 15:32:34  Test Dataset
 InvestmentBank/margin-call          b9d50fb2b38c3af5  2019-05-08 07:51:09  IB Margin Call
 InvestmentBank/margin-call-large    6d00b9f69ab059f6  2019-05-11 09:23:43  IB Margin Call Large➜ re --endpoint https://acme.reinfer.io get datasets
input: Enter API token [none]: MYSUPERSECRETAPITOKEN
 Name                                ID                Updated (UTC)        Title
 InvestmentBank/collateral-streams  aa9dda7c059e5a8d  2019-04-30 17:25:03  IB Collateral Streams
 InvestmentBank/george-test          1aaeacd49dfce8a0  2019-05-10 15:32:34  Test Dataset
 InvestmentBank/margin-call          b9d50fb2b38c3af5  2019-05-08 07:51:09  IB Margin Call
 InvestmentBank/margin-call-large    6d00b9f69ab059f6  2019-05-11 09:23:43  IB Margin Call Large
也可以使用--token指定令牌
➜ re --endpoint https://acme.reinfer.io --token MYSUPERSECRETAPITOKEN get datasets➜ re --endpoint https://acme.reinfer.io --token MYSUPERSECRETAPITOKEN get datasets

这通常不是一个好主意,因为 API 令牌将存储在您的 Shell 历史记录中。 最好将 API 令牌存储在环境变量中。

➜ re --endpoint https://acme.reinfer.io --token $REINFER_TOKEN get datasets➜ re --endpoint https://acme.reinfer.io --token $REINFER_TOKEN get datasets

但是,这仍然过于冗长、重复和不安全。

警告:

在某些情况下,使用命令行标志提供配置可能很有用。但是,建议使用 CLI 的方式是配置命名上下文。有关更多详细信息,请查看以下部分。

命名上下文

上下文是可应用于re命令的设置和凭据的集合。 当您指定上下文以运行命令时,设置和凭据将用于运行该命令。 配置文件中可以存储多个上下文。

上下文有助于避免在使用每个命令时手动指定令牌、端点和其他配置。上下文由以下部分组成:

  • 用作上下文标识符的好记名称
  • 用于对发出请求的用户进行身份验证的API 令牌
  • CLI 将向其发出请求的端点
  • (可选) 用于所有请求的HTTP 代理
  • (可选)是否接受来自端点的无效 TLS 证书(仅适用于内部/开发 Communications Mining™ 集群)

您可以指定在未显式引用任何上下文时使用的默认上下文。

全局-c--context标志可用于使用特定上下文具有的名称,您可以在命令行上将其指定为单个命令的参数。

创建上下文

您可以使用以下命令创建新上下文或修改现有上下文
re config addre config add

如果在不使用任何选项的情况下运行,则该命令将以交互方式询问上下文名称、端点和令牌。

➜ re config add
* Context name: acme-prod
I A new context `acme-prod` will be created
* Enter API token [none]: MYSUPERSECRETTOKEN
* Endpoint [https://reinfer.io/]: https://acme.reinfer.io
I Default context set to `acme-prod`
I New context `acme-prod` was created➜ re config add
* Context name: acme-prod
I A new context `acme-prod` will be created
* Enter API token [none]: MYSUPERSECRETTOKEN
* Endpoint [https://reinfer.io/]: https://acme.reinfer.io
I Default context set to `acme-prod`
I New context `acme-prod` was created

创建第一个上下文时,系统会将其设置为活动上下文

➜ re config add --name acme-dev --endpoint https://acme.reinfer.io/
I A new context `acme-dev` will be created.
* Enter API token [none]: MYSUPERSECRETTOKEN
I Default context set to `acme-dev`
I New context `acme-dev` was created.➜ re config add --name acme-dev --endpoint https://acme.reinfer.io/
I A new context `acme-dev` will be created.
* Enter API token [none]: MYSUPERSECRETTOKEN
I Default context set to `acme-dev`
I New context `acme-dev` was created.

如果添加已存在名称的上下文,则会更新该上下文。

# Edit the acme-dev context if it already exists
re config add acme-dev# Edit the acme-dev context if it already exists
re config add acme-dev
要查看所有选项,请运行re config add -h 。其中最重要的是:
选项
名称说明
--name <name>将要创建或更新的上下文的名称
--endpoint <endpoint>将用于此上下文的 Communications Mining™ 集群端点
--token <token>将用于此上下文的重新推断 API 令牌
--proxy <proxy>指定后将用于所有请求的 HTTP 代理的 URL

当前上下文将用于所有后续命令。 以下内容将打印当前上下文的所有数据集。

re get datasetsre get datasets
可以使用全局标志(例如--token--endpoint--proxy一次性覆盖任何上下文设置。
re --proxy http://proxy.example get datasetsre --proxy http://proxy.example get datasets

使用上下文

您可以使用-c--context全局标志,以在命令中使用特定上下文,例如
re -c my-context get datasetsre -c my-context get datasets

重新配置

与管理命名上下文相关的所有操作都在re config命令的作用域内。 子命令用于创建、更新、设置默认值和删除上下文等。

For all the available options, check the command reference.

配置设置存储在哪里?

配置目录的位置因操作系统而异。Communications Mining™ 命令行工具遵循这些操作系统默认设置,通常可在以下位置找到配置目录

  • Linux 上的~/.config/reinfer
  • macOS 上的$HOME/.config/reinfer
  • Windows 上的%AppData%\reinfer
上下文设置存储在 JSON 文件contexts.json中,例如 Linux 上的~/.config/reinfer/contexts.json 。 它看起来像这样
{
  "current_context": "prod",
  "contexts": [
    {
      "name": "prod",
      "endpoint": "https://acme.reinfer.io/",
      "token": "MYSUPERSECRETTOKEN",
      "accept_invalid_certificates": false,
      "proxy": null
    }
  ]
}{
  "current_context": "prod",
  "contexts": [
    {
      "name": "prod",
      "endpoint": "https://acme.reinfer.io/",
      "token": "MYSUPERSECRETTOKEN",
      "accept_invalid_certificates": false,
      "proxy": null
    }
  ]
}
  • 快速设置
  • 每次都提供凭据
  • 命名上下文
  • 配置设置存储在哪里?

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。