> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 删除组织

LangSmith UI 目前不支持从自托管的 LangSmith 实例中删除单个组织。但是，可以通过直接从 ClickHouse 中所有物化视图（runs\_history 视图除外）以及 runs 和 feedbacks 表中移除所有痕迹，然后从 Postgres 的 tenants 表中移除该组织来实现。

此命令使用组织 ID 作为参数。

### 前提条件

确保您已准备好以下工具/项目。

1. kubectl

   * [https://kubernetes.io/docs/tasks/tools/](https://kubernetes.io/docs/tasks/tools/)

2. PostgreSQL 客户端

   * [https://www.postgresql.org/download/](https://www.postgresql.org/download/)

3. PostgreSQL 数据库连接：

   * 主机
   * 端口
   * 用户名
     * 如果使用捆绑版本，此值为 `postgres`
   * 密码
     * 如果使用捆绑版本，此值为 `postgres`
   * 数据库名称
     * 如果使用捆绑版本，此值为 `postgres`

4. Clickhouse 数据库凭据

   * 主机
   * 端口
   * 用户名
     * 如果使用捆绑版本，此值为 `default`
   * 密码
     * 如果使用捆绑版本，此值为 `password`
   * 数据库名称
     * 如果使用捆绑版本，此值为 `default`

5. 从您将运行迁移脚本的机器连接到 PostgreSQL 数据库。

   * 如果您使用的是捆绑版本，可能需要将 postgresql 服务端口转发到您的本地机器。
   * 运行 `kubectl port-forward svc/langsmith-postgres 5432:5432` 将 postgresql 服务端口转发到您的本地机器。

6. 从您将运行迁移脚本的机器连接到 Clickhouse 数据库。

   * 如果您使用的是捆绑版本，可能需要将 clickhouse 服务端口转发到您的本地机器。
     * 运行 `kubectl port-forward svc/langsmith-clickhouse 8123:8123` 将 clickhouse 服务端口转发到您的本地机器。
   * 如果您使用的是 Clickhouse Cloud，则需要指定 --ssl 标志并使用端口 `8443`

7. 删除组织的脚本

   * 下载 [删除组织脚本](https://github.com/langchain-ai/helm/blob/main/charts/langsmith/scripts/delete_organization_sh)

### 运行单个组织的删除脚本

运行以下命令来执行组织移除脚本：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
sh delete_organization.sh <postgres_url> <clickhouse_url> --organization_id <organization_id>
```

例如，如果您使用的是捆绑版本并进行了端口转发，命令将如下所示：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
sh delete_organization.sh "postgres://postgres:postgres@localhost:5432/postgres" "clickhouse://default:password@localhost:8123/default" --organization_id 4ec70ec7-0808-416a-b836-7100aeec934b
```

如果您访问 LangSmith UI，现在应该看到该组织已不再存在。

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/langsmith/script-delete-an-organization.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
