Skip to content

Commit

Permalink
Documentation updates (#356)
Browse files Browse the repository at this point in the history
* Documentation updates

* Fix typo in docs
  • Loading branch information
jverre authored Oct 7, 2024
1 parent 92f7857 commit 9d0190a
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ For this guide we will be evaluating the Hallucination metric included in the LL

## Creating an account on Comet.com

[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_hall) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_hall) and grab you API Key.
[Comet](https://www.comet.com/site/?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_hall&utm_campaign=opik) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_hall&utm_campaign=opik) and grab you API Key.

> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_hall) for more information.
> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_hall&utm_campaign=opik) for more information.

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ For this guide we will be evaluating the Moderation metric included in the LLM E

## Creating an account on Comet.com

[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_mod) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_mod) and grab you API Key.
[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_mod&utm_campaign=opik) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup/?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_mod&utm_campaign=opik) and grab you API Key.

> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_mod) for more information.
> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=eval_mod&utm_campaign=opik) for more information.

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Automatting the evaluation\n",
"## Automating the evaluation\n",
"\n",
"In order to ensure our LLM application is working correctly, we will test it on our synthetic dataset.\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ We will highlight three different parts of the workflow:

## Creating an account on Comet.com

[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=langchain) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=langchain) and grab you API Key.
[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=langchain&utm_campaign=opik) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=langchain&utm_campaign=opik) and grab you API Key.

> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=langchain) for more information.
> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=langchain&utm_campaign=opik) for more information.

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ For this guide we will be downloading the essays from Paul Graham and use them a

## Creating an account on Comet.com

[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=llamaindex) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=llamaindex) and grab you API Key.
[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=llamaindex&utm_campaign=opik) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&=opik&utm_medium=colab&utm_content=llamaindex&utm_campaign=opik) and grab you API Key.

> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=llamaindex) for more information.
> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=llamaindex&utm_campaign=opik) for more information.

```python
Expand Down
4 changes: 2 additions & 2 deletions apps/opik-documentation/documentation/docs/cookbook/openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Opik integrates with OpenAI to provide a simple way to log traces for all OpenAI

## Creating an account on Comet.com

[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai) and grab you API Key.
[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai&utm_campaign=opik) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai&utm_campaign=opik) and grab you API Key.

> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai) for more information.
> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai&utm_campaign=opik) for more information.

```python
Expand Down
4 changes: 2 additions & 2 deletions apps/opik-documentation/documentation/docs/cookbook/ragas.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ There are two main ways to use Opik with Ragas:

## Creating an account on Comet.com

[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=openai) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=ragas) and grab you API Key.
[Comet](https://www.comet.com/site?from=llm&utm_source=opik&utm_medium=colab&utm_content=ragas&utm_campaign=opik) provides a hosted version of the Opik platform, [simply create an account](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=colab&utm_content=ragas&utm_campaign=opik) and grab you API Key.

> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=ragas) for more information.
> You can also run the Opik platform locally, see the [installation guide](https://www.comet.com/docs/opik/self-host/overview/?from=llm&utm_source=opik&utm_medium=colab&utm_content=ragas&utm_campaign=opik) for more information.

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ You can score an LLM response by first initializing the metrics and then calling
```python
from opik.evaluation.metrics import Contains

metric = Contains("hello", case_sensitive=True)
metric = Contains(name="contains_hello", case_sensitive=True)

score = metric.score("Hello world !")
score = metric.score(output="Hello world !", reference="Hello")

print(score)
```
Expand All @@ -41,12 +41,9 @@ The `Equals` metric can be used to check if the output of an LLM exactly matches
```python
from opik.evaluation.metrics import Equals

metric = Equals(
name="checks_equals_hello",
searched_value="hello",
)
metric = Equals()

score = metric.score("Hello world !")
score = metric.score(output="Hello world !", reference="Hello, world !")
print(score)
```

Expand All @@ -57,13 +54,9 @@ The `Contains` metric can be used to check if the output of an LLM contains a sp
```python
from opik.evaluation.metrics import Contains

metric = Contains(
name="checks_contains_hello",
searched_value="hello",
case_sensitive=False,
)
metric = Contains(case_sensitive=False)

score = metric.score("Hello world !")
score = metric.score(output="Hello world !", reference="Hello")
print(score)
```

Expand All @@ -74,10 +67,7 @@ The `RegexMatch` metric can be used to check if the output of an LLM matches a s
```python
from opik.evaluation.metrics import RegexMatch

metric = RegexMatch(
name="checks_regex_match",
regex_pattern="^[a-zA-Z0-9]+$",
)
metric = RegexMatch(regex="^[a-zA-Z0-9]+$")

score = metric.score("Hello world !")
print(score)
Expand All @@ -92,7 +82,7 @@ from opik.evaluation.metrics import IsJson

metric = IsJson(name="is_json_metric")

score = metric.score('{"key": "some_valid_sql"}')
score = metric.score(output='{"key": "some_valid_sql"}')
print(score)
```

Expand All @@ -103,8 +93,8 @@ The `LevenshteinRatio` metric can be used to check if the output of an LLM is va
```python
from opik.evaluation.metrics import LevenshteinRatio

metric = LevenshteinRatio(name="levenshtein_ratio_metric", searched_value="hello")
metric = LevenshteinRatio()

score = metric.score("Hello world !")
score = metric.score(output="Hello world !", reference="hello")
print(score)
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 4
sidebar_label: Annotate Traces
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"label": "Integrations",
"position": 6,
"position": 5,
"link": {
"type": "generated-index"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 3
sidebar_label: Log Distributed Traces
---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
sidebar_position: 2
sidebar_label: Log Multimodal Traces
toc_min_heading_level: 2
toc_max_heading_level: 4
---

# Log Multimodal Traces

Opik supports multimodal traces allowing you to track not just the text input and output of your LLM, but also images.

![Traces with OpenAI](/img/tracing/image_trace.png)

## Log a trace with an image using OpenAI SDK

As long as your trace input or output follows the OpenAI format, images will automatically be detected and rendered in the Opik UI.

We recommend that you use the [`track_openai`](/python-sdk-reference/integrations/openai/track_openai.html) wrapper to ensure the OpenAI API call is traced correctly:

```python
from opik.integrations.openai import track_openai
from openai import OpenAI

# Create the OpenAI client and enable Opik tracing
client = track_openai(OpenAI())

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
},
],
}
],
max_tokens=300,
)

print(response.choices[0])
```

## Manually logging images

If you are not using the OpenAI SDK, you can still log images to the platform. The UI will automatically detect the image and display it if the input field has a `message` attribute that follows the OpenAI format:

```json
{
"messages": [
...,
{
"type": "image_url",
"image_url": {
"url": "<url or base64 encoded image>"
}
}
],
...
}
```

:::tip
Let's us know on [Github](https://github.com/comet-ml/opik/issues/new/choose) if you would like to us to support additional image formats or models.
:::
2 changes: 1 addition & 1 deletion apps/opik-documentation/documentation/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const sidebars: SidebarsConfig = {
type: 'category',
label: 'Tracing',
collapsed: false,
items: ['tracing/log_traces', 'tracing/log_distributed_traces', 'tracing/annotate_traces', {
items: ['tracing/log_traces', 'tracing/log_multimodal_traces', 'tracing/log_distributed_traces', 'tracing/annotate_traces', {
type: 'category',
label: 'Integrations',
collapsed: true,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9d0190a

Please sign in to comment.