> ## Content Index
> Fetch the complete content index at: https://www.hubwiz.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Opik：端到端LLM应用监测平台
- URL: https://www.hubwiz.com/blog/opik-end-to-end-llm-apps-monitoring-platform/
- Published: 2024-11-10T12:54:04.000Z
- Updated: 2024-11-10T14:59:55.000Z
- Description: Opik 是一个用于评估、测试和监控 LLM 应用程序的开源平台，由 Comet 构建。
- Author: admin
- Tags: TOOL, LIBRARY, OPIK, LLM APP MONITORING, COMET.COM, LLM AS A JUDGE, PYTEST, OPENAI, LITELLM, LANGCHAIN, BEDROCK, GEMINI, GROQ, LANGGRAPH, LLAMAINDEX, OLLAMA, PREDIBASE, RAGAS, WATSONX, #Import 2026-10-14 14:41

[Opik](https://github.com/comet-ml/opik?ref=hubwiz.com) 是一个用于评估、测试和监控 LLM 应用程序的开源平台。由 [Comet ](https://www.comet.com/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=what%5Fis%5Fopik%5Flink&utm%5Fcampaign=opik)构建。

你可以将 Opik 用于：

a) 开发：

- 跟踪：在开发和生产过程中跟踪所有 LLM 调用和跟踪（快速入门、集成
- 标注：通过使用 Python SDK 或 UI 记录反馈分数来标注你的 LLM 调用。

b) 评估：自动化你的 LLM 应用程序的评估过程：

- 数据集和实验：存储测试用例并运行实验（数据集、评估您的 LLM 应用程序）
- LLM 作为评判指标：使用 Opik 的 LLM 作为复杂问题的评判指标，例如幻觉检测、审核和 RAG 评估（答案相关性、上下文精度）
- CI/CD 集成：使用我们的 PyTest 集成作为 CI/CD 管道的一部分运行评估

c) 生产监控：在生产中监控你的 LLM 应用程序并通过向评估数据集添加错误跟踪来轻松关闭反馈循环。

## 1、Opik安装

Opik 可作为完全开源的本地安装或使用 Comet.com 作为托管解决方案。开始使用 Opik 的最简单方法是在[ comet.com ](https://www.comet.com/signup?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=install&utm%5Fcampaign=opik)上创建一个免费的 Comet 帐户。

如果你想自行托管 Opik，可以通过克隆存储库并使用 Docker Compose 启动平台来实现：

```
# Clone the Opik repository
git clone https://github.com/comet-ml/opik.git

# Navigate to the opik/deployment/docker-compose directory
cd opik/deployment/docker-compose

# Start the Opik platform
docker compose up --detach

# You can now visit http://localhost:5173 on your browser!
```

有关不同部署选项的更多信息，请参阅官方部署指南：

- 本地实例： [本地部署文档](https://www.comet.com/docs/opik/self-host/local%5Fdeployment?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=self%5Fhost%5Flink&utm%5Fcampaign=opik)
- Kubernetes：[ Kubernetes部署文档](https://www.comet.com/docs/opik/self-host/kubernetes/?ref=hubwiz.com#kubernetes-installation?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=kubernetes%5Flink&utm%5Fcampaign=opik)

## 2、开始使用Opik

要开始使用Opik，你需要先安装 Python SDK：

```
pip install opik
```

安装 SDK 后，你可以通过运行 `opik configure` 命令对其进行配置：

```
opik configure
```

这将允许你通过设置正确的本地服务器地址在本地配置 Opik，或者如果你使用云平台，则通过设置 API 密钥

> 提示：你还可以从 Python 代码中调用 `opik.configure(use_local=True)` 方法来配置 SDK 在本地安装上运行。

现在可以开始使用 [Python SDK](https://www.comet.com/docs/opik/python-sdk-reference/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=sdk%5Flink2&utm%5Fcampaign=opik) 记录跟踪。

## 3、记录跟踪

最简单的入门方法是使用我们的集成之一。 Opik 支持：

| 集成         | 描述                        | 文档                                                                                                                                                                    | 在 Colab 中尝试                                                                                                                                                            |
| ---------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OpenAI     | 记录所有 OpenAI LLM 调用的跟踪     | [文档](https://www.comet.com/docs/opik/tracing/integrations/openai/?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=openai%5Flink&utm%5Fcampaign=opik)              | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/openai.ipynb?ref=hubwiz.com)      |
| LiteLLM    | 使用 OpenAI 格式调用任何 LLM 模型   | [文档](https://github.com/comet-ml/opik/blob/main/tracing/integrations/litellm.md?ref=hubwiz.com)                                                                       | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/litellm.ipynb?ref=hubwiz.com)     |
| LangChain  | 记录所有 LangChain LLM 调用的跟踪  | [文档](https://www.comet.com/docs/opik/tracing/integrations/langchain/?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=langchain%5Flink&utm%5Fcampaign=opik)        | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/bedrock.ipynb?ref=hubwiz.com)     |
| Bedrock    | 记录所有 Bedrock LLM 调用的跟踪    | [文档](https://www.comet.com/docs/opik/tracing/integrations/bedrock?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=bedrock%5Flink&utm%5Fcampaign=opik)             | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/bedrock.ipynb?ref=hubwiz.com)     |
| Gemini     | 记录所有 Gemini LLM 调用的跟踪     | [文档](https://www.comet.com/docs/opik/tracing/integrations/gemini?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=gemini%5Flink&utm%5Fcampaign=opik)               | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/gemini.ipynb?ref=hubwiz.com)      |
| Groq       | 记录所有 Groq LLM 调用的跟踪       | [文档](https://www.comet.com/docs/opik/tracing/integrations/gemini?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=gemini%5Flink&utm%5Fcampaign=opik)               | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/groq.ipynb?ref=hubwiz.com)        |
| LangGraph  | 记录所有 LangGraph 执行的跟踪      | [文档](https://www.comet.com/docs/opik/tracing/integrations/langgraph/?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=langchain%5Flink&utm%5Fcampaign=opik)        | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/langgraph.ipynb?ref=hubwiz.com)   |
| LlamaIndex | 记录所有 LlamaIndex LLM 调用的跟踪 | [文档](https://www.comet.com/docs/opik/tracing/integrations/llama%5Findex?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=llama%5Findex%5Flink&utm%5Fcampaign=opik) | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/llama-index.ipynb?ref=hubwiz.com) |
| Ollama     | 记录所有 Ollama LLM 调用的跟踪     | [文档](https://www.comet.com/docs/opik/tracing/integrations/ollama?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=ollama%5Flink&utm%5Fcampaign=opik)               | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/ollama.ipynb?ref=hubwiz.com)      |
| Predibase  | 微调并提供开源大型语言模型             | [文档](https://www.comet.com/docs/opik/tracing/integrations/predibase?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=predibase%5Flink&utm%5Fcampaign=opik)         | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/predibase.ipynb?ref=hubwiz.com)   |
| Ragas      | 评估框架，用于您的检索增强生成 (RAG) 管道  | [文档](https://www.comet.com/docs/opik/tracing/integrations/ragas?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=ragas%5Flink&utm%5Fcampaign=opik)                 | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/ragas.ipynb?ref=hubwiz.com)       |
| watsonx    | 记录所有 watsonx LLM 调用的跟踪    | [文档](https://www.comet.com/docs/opik/tracing/integrations/watsonx?utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=watsonx%5Flink&utm%5Fcampaign=opik)             | [在 Colab 中打开](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/watsonx.ipynb?ref=hubwiz.com)     |

如果你不使用上述任何框架，还可以使用 `track`函数装饰器来[记录跟踪](https://www.comet.com/docs/opik/tracing/log%5Ftraces/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=traces%5Flink&utm%5Fcampaign=opik)：

```
import opik

opik.configure(use_local=True) # Run locally

@opik.track
def my_llm_function(user_question: str) -> str:
    # Your LLM code here

    return "Hello"
```

> 提示： `track`装饰器可以与我们的任何集成结合使用，也可用于跟踪嵌套函数调用。

## ‍4、LLM as a judge指标

Python Opik SDK 包含许多 LLM as a judge指标，可帮助你评估你的 LLM 应用程序。在[指标文档](https://www.comet.com/docs/opik/evaluation/metrics/overview/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=metrics%5F2%5Flink&utm%5Fcampaign=opik)中了解更多信息。

要使用它们，只需导入相关指标并使用评分函数：

```
from opik.evaluation.metrics import Hallucination

metric = Hallucination()
score = metric.score(
    input="What is the capital of France?",
    output="Paris",
    context=["France is a country in Europe."]
)
print(score)
```

Opik 还包括许多预构建的启发式指标以及创建自己的指标的能力。在[指标文档](https://www.comet.com/docs/opik/evaluation/metrics/overview?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=metrics%5F3%5Flink&utm%5Fcampaign=opik)中了解更多信息。

## 5、评估 LLM 应用程序

Opik 允许你在开发过程中通过[数据集](https://www.comet.com/docs/opik/evaluation/manage%5Fdatasets/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=datasets%5F2%5Flink&utm%5Fcampaign=opik)和[实验](https://www.comet.com/docs/opik/evaluation/evaluate%5Fyour%5Fllm/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=experiments%5Flink&utm%5Fcampaign=opik)评估你的 LLM 应用程序。

你还可以在 CI/CD 过程中使用我们的 [PyTest 集成](https://www.comet.com/docs/opik/testing/pytest%5Fintegration/?from=llm&utm%5Fsource=opik&utm%5Fmedium=github&utm%5Fcontent=pytest%5F2%5Flink&utm%5Fcampaign=opik) 运行评估。

---

原文链接：[Opik: Open-source end-to-end LLM Development Platform](https://github.com/comet-ml/opik?ref=hubwiz.com)

汇智网翻译整理，转载请标明出处