From 547eeb51d168a285ce4d8997e3514a1938d52766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacques=20Verr=C3=A9?= Date: Sun, 2 Feb 2025 15:28:49 +0000 Subject: [PATCH] DeepSeek documentation (#1190) --- README.md | 1 + .../docs/tracing/integrations/deepseek.mdx | 141 ++++++++++++++++++ .../docs/tracing/integrations/overview.md | 1 + .../documentation/sidebars.ts | 1 + 4 files changed, 144 insertions(+) create mode 100644 apps/opik-documentation/documentation/docs/tracing/integrations/deepseek.mdx diff --git a/README.md b/README.md index 0b13c8633e..7d98ca7e52 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ The easiest way to get started is to use one of our integrations. Opik supports: | Anthropic | Log traces for all Anthropic LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/anthropic?utm_source=opik&utm_medium=github&utm_content=anthropic_link&utm_campaign=opik) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/anthropic.ipynb) | | Bedrock | Log traces for all Bedrock LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/bedrock?utm_source=opik&utm_medium=github&utm_content=bedrock_link&utm_campaign=opik) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/bedrock.ipynb) | | CrewAI | Log traces for all CrewAI calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/crewai?utm_source=opik&utm_medium=github&utm_content=crewai_link&utm_campaign=opik) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/crewai.ipynb) | +| DeepSeek | Log traces for all DeepSeek LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/deepseek?utm_source=opik&utm_medium=github&utm_content=deepseek_link&utm_campaign=opik) | | | DSPy | Log traces for all DSPy runs | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/dspy?utm_source=opik&utm_medium=github&utm_content=dspy_link&utm_campaign=opik) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb) | | Gemini | Log traces for all Gemini LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/gemini?utm_source=opik&utm_medium=github&utm_content=gemini_link&utm_campaign=opik) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/gemini.ipynb) | | Groq | Log traces for all Groq LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/groq?utm_source=opik&utm_medium=github&utm_content=groq_link&utm_campaign=opik) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/groq.ipynb) | diff --git a/apps/opik-documentation/documentation/docs/tracing/integrations/deepseek.mdx b/apps/opik-documentation/documentation/docs/tracing/integrations/deepseek.mdx new file mode 100644 index 0000000000..5fccfd8203 --- /dev/null +++ b/apps/opik-documentation/documentation/docs/tracing/integrations/deepseek.mdx @@ -0,0 +1,141 @@ +--- +sidebar_label: DeepSeek +description: Describes how to track DeepSeek LLM calls using Opik +pytest_codeblocks_skip: false +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +# Deepseek + +Deepseek is an Open-Source LLM model that rivals o1 from OpenAI. You can learn more about DeepSeek on [Github](https://github.com/deepseek-ai/DeepSeek-R1) or +on [deepseek.com](https://www.deepseek.com/). + +In this guide, we will showcase how to track DeepSeek calls using Opik. As DeepSeek is open-source, there are many way to run and call the model. We will focus on how to integrate Opik with the following hosting options: + +1. DeepSeek API +2. Fireworks AI API +3. Together AI API + +## Getting started + +### Configuring your hosting provider + +Before you can start tracking DeepSeek calls, you need to get the API key from your hosting provider. + + + + +In order to use the DeepSeek API, you will need to have an API key. You can register for an account on [DeepSeek.com](https://chat.deepseek.com/sign_up). +Once you have signed up, you can register for an API key. + + + + +You can log into Fireworks AI on [fireworks.ai](https://fireworks.ai/). You can then access your API key on the [API keys](https://fireworks.ai/account/api-keys) page. + + + + +You can log into Together AI on [together.ai](https://together.ai/). You can then access your API key on the [API keys](https://api.together.ai/settings/api-keys) page. + + + + +### Configuring Opik + +```bash +pip install --upgrade --quiet opik + +opik configure +``` + +:::tip +Opik is fully open-source and can be run locally or through the Opik Cloud platform. You can learn more about hosting Opik on your own infrastructure in the [self-hosting guide](/docs/self-host/overview.md). +::: + +## Tracking DeepSeek calls + +The easiest way to call DeepSeek with Opik is to use the OpenAI Python SDK and the `track_openai` decorator. This approach is compatible with the DeepSeek API, Fireworks AI API and Together AI API: + + + + +```python +from opik.integrations.openai import track_openai +from openai import OpenAI + +# Create the OpenAI client that points to DeepSeek API +client = OpenAI(api_key="", base_url="https://api.deepseek.com") + +# Wrap your OpenAI client to track all calls to Opik +client = track_openai(client) + +# Call the API +response = client.chat.completions.create( + model="deepseek-chat", + messages=[ + {"role": "system", "content": "You are a helpful assistant"}, + {"role": "user", "content": "Hello"}, + ], + stream=False +) + +print(response.choices[0].message.content) +``` + + + + +```python +from opik.integrations.openai import track_openai +from openai import OpenAI + +# Create the OpenAI client that points to DeepSeek API +client = OpenAI(api_key="", base_url="https://api.fireworks.ai/inference/v1") + +# Wrap your OpenAI client to track all calls to Opik +client = track_openai(client) + +# Call the API +response = client.chat.completions.create( + model="accounts/fireworks/models/deepseek-v3", + messages=[ + {"role": "system", "content": "You are a helpful assistant"}, + {"role": "user", "content": "Hello"}, + ], + stream=False +) + +print(response.choices[0].message.content) +``` + + + + +```python +from opik.integrations.openai import track_openai +from openai import OpenAI + +# Create the OpenAI client that points to Together AI API +client = OpenAI(api_key="", base_url="https://api.together.xyz/v1") + +# Wrap your OpenAI client to track all calls to Opik +client = track_openai(client) + +# Call the API +response = client.chat.completions.create( + model="deepseek-ai/DeepSeek-R1", + messages=[ + {"role": "system", "content": "You are a helpful assistant"}, + {"role": "user", "content": "Hello"}, + ], + stream=False +) + +print(response.choices[0].message.content) +``` + + + diff --git a/apps/opik-documentation/documentation/docs/tracing/integrations/overview.md b/apps/opik-documentation/documentation/docs/tracing/integrations/overview.md index c0248c6de0..3858931938 100644 --- a/apps/opik-documentation/documentation/docs/tracing/integrations/overview.md +++ b/apps/opik-documentation/documentation/docs/tracing/integrations/overview.md @@ -17,6 +17,7 @@ Opik aims to make it as easy as possible to log, view and evaluate your LLM trac | Anthropic | Log traces for all Anthropic LLM calls | [Documentation](/tracing/integrations/anthropic.md) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/anthropic.ipynb) | | Bedrock | Log traces for all AWS Bedrock LLM calls | [Documentation](/tracing/integrations/bedrock.md) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/bedrock.ipynb) | | CrewAI | Log traces for all CrewAI LLM calls | [Documentation](/tracing/integrations/crewai.md) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/crewai.ipynb) | +| DeepSeek | Log traces for all LLM calls made with DeepSeek | [Documentation](/tracing/integrations/deepseek.mdx) | | | Dify | Log traces and LLM calls for your Dify Apps | [Documentation](/tracing/integrations/dify.mdx) | | | DSPy | Log traces for all DSPy runs | [Documentation](/tracing/integrations/dspy.md) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb) | | Guardrails | Log traces for all Guardrails validations | [Documentation](/tracing/integrations/guardrails-ai.md) | [![Open Quickstart In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/guardrails-ai.ipynb) | diff --git a/apps/opik-documentation/documentation/sidebars.ts b/apps/opik-documentation/documentation/sidebars.ts index ba74d2d3d5..db02296eba 100644 --- a/apps/opik-documentation/documentation/sidebars.ts +++ b/apps/opik-documentation/documentation/sidebars.ts @@ -57,6 +57,7 @@ const sidebars: SidebarsConfig = { "tracing/integrations/anthropic", "tracing/integrations/bedrock", "tracing/integrations/crewai", + "tracing/integrations/deepseek", "tracing/integrations/dify", "tracing/integrations/dspy", "tracing/integrations/gemini",