uip 上下文基础
"uip context-grounding" 的语法和选项,这是连接到 Python UiPath CLI 的桥梁,用于执行上下文锚定操作。
uip context-grounding 是指向基于 Python 的 UiPath SDK 上下文锚定操作的瘦桥。它会检测合适的 Python 解释器,确认已安装 uipath Python 包,并将其他所有内容作为 uipath context-grounding <args> 转发到 Python CLI — 除了 setup,此工具未定义自己的原生子命令。
与仅转发子命令名称固定白名单的uip codedagent不同, context-grounding-tool会转发任何无法识别的命令——在新的 Python 端动词之前,没有允许列表可供查阅。
有关精简包装器与完整工具的不同,请参阅工具(插件) 。
大纲
uip context-grounding setup [--force]
uip context-grounding <any-command> [args...]
uip context-grounding help
uip context-grounding
uip context-grounding setup [--force]
uip context-grounding <any-command> [args...]
uip context-grounding help
uip context-grounding
uip 上下文锚定设置
检测 Python 并验证是否已安装uipath包。结果缓存在基于用户的文件中,因此后续context-grounding命令可以立即解析 Python 二进制文件。
参数
无。
选项
--force— 即使存在缓存结果,也会重新运行检测。
示例
uip context-grounding setup
uip context-grounding setup --force
uip context-grounding setup
uip context-grounding setup --force
数据形状 ( --output json )
{
"Code": "ContextGroundingSetup",
"Data": {
"PythonPath": "/usr/bin/python3.11",
"Package": "uipath",
"PackageInstalled": "Yes",
"PackageVersion": "1.0.0"
}
}
{
"Code": "ContextGroundingSetup",
"Data": {
"PythonPath": "/usr/bin/python3.11",
"Package": "uipath",
"PackageInstalled": "Yes",
"PackageVersion": "1.0.0"
}
}
环境检查
- 允许的 Python 版本通过环境变量
PYTHON_TOOL_PYTHON_VERSIONS配置。空列表会在设置时引发Failure。 - 如果当前工作目录中存在
.venv目录,但未激活虚拟环境,安装程序将拒绝运行,并建议首先激活虚拟环境(在 Windows 上为.venv\Scripts\activate,在其他地方为source .venv/bin/activate)。
已转发的命令
任何不是 setup 或 help 的子命令都将作为 uipath CLI 转发到 Python uipath context-grounding <args> — 没有需要检查的固定白名单; Python 包明天添加的全新动词现在在这里有效,但有一个例外:
auth已阻止。调用uip context-grounding auth ...立即失败,并显示Result: ValidationError (退出代码3 )和“使用‘uip 登录’进行身份验证”消息。—除非您传递--force ,这会绕过这一个筛选器,并让auth调用至 Python。这与 --force 对 uip codedagent 的影响相反,--force 始终会被静默移除,并且永远不会到达 Python — 在这里,它是一个真正的(尽管很窄)退出填充。
示例
# Hand off to the Python CLI's index command
uip context-grounding index ./my-index
# Search a context grounding index
uip context-grounding search "invoice total" --index my-index
# Blocked without --force
uip context-grounding auth login
# Result: ValidationError — "Use 'uip login' for authentication."
# Bypasses the auth filter
uip context-grounding auth login --force
# Hand off to the Python CLI's index command
uip context-grounding index ./my-index
# Search a context grounding index
uip context-grounding search "invoice total" --index my-index
# Blocked without --force
uip context-grounding auth login
# Result: ValidationError — "Use 'uip login' for authentication."
# Bypasses the auth filter
uip context-grounding auth login --force
由于转发的命令由 uipath Python 包定义,因此它们的标志和输出形式为包发出的任何标志和形式,而不是 CLI 的标准 Code/Data 信封。将此处的 CLI 视为传输。对于参数表面,请运行 uip context-grounding <command> --help。
输出格式中继:当全局--output为json时,CLI 自动附加--format json到转发的命令(在执行--help调用或转发的参数已包含--format时跳过) — Python CLI必须支持--format json才能使其生效;没有其他输出格式会以这种方式中继。
纯调用和help都会转发— 与uip codedagent (纯help显示 Commander 自己的帮助)不同,不带参数的uip context-grounding会转发到exec --help ,而uip context-grounding help会显式转发到同一个exec --help调用。两者都显示 Python 包自己的帮助文本,而不是此工具的帮助文本。
身份验证中继:在转发之前,CLI 会读取uip login创建的会话并将其注入到 Python 子流程的环境中, uip codedagent使用的机制相同。如果您尚未登录,仍可转发; Python CLI 不会在没有这些变量的情况下运行。
退出代码
适用标准退出代码,以及专门用于上述被阻止auth命令的3 。否则,转发的子流程的退出代码将直接中继到父 Shell。
相关内容
- 工具(插件) —Thin-Wapper 工具模型。
uip codedagent— 相同的 Python 网桥模式,使用固定转发白名单,而不是转发所有内容。uip login— 创建中继到 Python 运行时的会话。uip tools— 安装、更新、卸载context-grounding-tool包本身。