Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into OPIK-444
Browse files Browse the repository at this point in the history
  • Loading branch information
japdubengsub committed Nov 29, 2024
2 parents 14ab7a2 + 8c352ac commit 8545d22
Show file tree
Hide file tree
Showing 33 changed files with 217 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,13 @@ AND id IN (
FROM (
SELECT
trace_id,
sumMap(usage) as usage
sumMap(usage) as usage,
sum(total_estimated_cost) as total_estimated_cost
FROM (
SELECT
trace_id,
usage
usage,
total_estimated_cost
FROM spans
WHERE workspace_id = :workspace_id
AND project_id = :project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6562,7 +6562,12 @@ void getTraceStats__whenFilterUsageEqual__thenReturnTracesFiltered(String usageK
.field(field)
.operator(Operator.EQUAL)
.value(traces.getFirst().usage().get(usageKey).toString())
.build());
.build(),
TraceFilter.builder()
.field(TraceField.TOTAL_ESTIMATED_COST)
.operator(Operator.GREATER_THAN_EQUAL)
.value("0.000")
.build());

List<ProjectStatItem<?>> stats = getProjectTraceStatItems(expectedTraces);

Expand Down
4 changes: 4 additions & 0 deletions apps/opik-documentation/documentation/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ sidebar_label: Changelog
**Opik Dashboard**:

- Feedback scores are now displayed as separate columns in the traces and spans table
- Introduce a new project dashboard to see trace count, feedback scores and token count over time.
![project dashboard](/img/changelog/2024-11-25/project_dashboard.png)
- Project statistics are now displayed in the traces and spans table header, this is especially useful for tracking the average feedback scores
![project statistics](/img/changelog/2024-11-25/project_statistics.png)
- Redesigned the experiment item sidebar to make it easier to review experiment results
![experiment item sidebar](/img/changelog/2024-11-25/experiment_item_sidebar.png)
- Annotating feedback scores in the UI now feels much faster
- Support exporting traces as JSON file in addition to CSV
- Sidebars now close when clicking outside of them
- Dataset groups in the experiment page are now sorted by last updated date
- Updated scrollbar styles for Windows users

**SDK**:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import opik
ITERATION_SUMMARY_PROMPT = opik.Prompt(
name="Iteration Summary Prompt",
prompt="""
Document: {document}
Current summary: {current_summary}
Instruction to focus on: {instruction}
Document: {{document}}
Current summary: {{current_summary}}
Instruction to focus on: {{instruction}}
Generate a concise, entity-dense, and highly technical summary from the provided Document that specifically addresses the given Instruction.
Expand All @@ -58,8 +58,8 @@ Guidelines:
FINAL_SUMMARY_PROMPT = opik.Prompt(
name="Final Summary Prompt",
prompt="""
Given this summary: {current_summary}
And this instruction to focus on: {instruction}
Given this summary: {{current_summary}}
And this instruction to focus on: {{instruction}}
Create an extremely dense, final summary that captures all key technical information in the most concise form possible, while specifically addressing the given instruction.
""".rstrip().lstrip(),
)
Expand Down Expand Up @@ -128,7 +128,7 @@ def final_summary(instruction: str, current_summary: str, model: str = "gpt-4o-m
)


@opik.track
@opik.track(project_name="Chain of Density Summarization")
def chain_of_density_summarization(
document: str,
instruction: str,
Expand All @@ -149,8 +149,6 @@ Let's call the summarization chain with a sample document:
```python
import textwrap

os.environ["OPIK_PROJECT_NAME"] = "Chain of Density Summarization"

document = """
Artificial intelligence (AI) is transforming industries, revolutionizing healthcare, finance, education, and even creative fields. AI systems
today are capable of performing tasks that previously required human intelligence, such as language processing, visual perception, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "Find datasets"
sidebar_label: "Find datasets"
hide_title: true
hide_table_of_contents: true
api: eJy1V21v2zYQ/is3Yh+2QLaTdC+AMGzI2q4LVmxFkmIYqsw5i2eLM0Wq5Cmu6/m/D0fJb02yBuj2xUrI43Nvz92RK8U4iyp/o54hYySO6jpTmmIZTMPGO5Wrn4zToDfbmfINBZS9c61yNTVOP9ttNhiwJqYgoCvlsCaVqwZnpDJlBO5tS2GpMhXLimpU+UrVxpm6rVV+kileNnLAOKYZBZWpqQ81crf05FSJcVNsLav8ZL3Othqief8/aDjeV7EwXI3pXUPB1OQ4jr2zy4d19nom3ltC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mb0DbWJjcUkaFhU5qPw9yUQC+fbmSE28vXp9tyfbAwUhMFSpgxlNm8z0hOgvf1imgdffO1+l5gNX1Pho2KdL52Frfqo9yTSypiQXaQ/vosGyIjgfnh4A9S0e0+7Qh9moPxpHry+fv/zl+uXgfHg6rLi2gitjpmvaZ8PT4aksNT5yjW5P1acvoU9uf9sb6gPBfnQyfeBRY9E4wU+2rvoJ+E7dn6XbaZqBanuzSe8xqVYRWa0mGOltsOu1LHdXdpmN2kScWLn4TtFGytSclrtnV6KaylWagk+I9u+nY0Sfegcdc3b/5XOMfP+4OcqD7XtmJ30r/wQj4ip/d7vOVFd9KWjdsYuypIb3Tj14owjK9tby6uWNWq//BBVDONg=
sidebar_class_name: "get api-method"
info_path: reference/rest_api/opik-rest-api
custom_edit_url: null
Expand Down Expand Up @@ -48,7 +48,7 @@ Find datasets
</Heading>

<ParamsDetails
parameters={[{"name":"page","in":"query","schema":{"minimum":1,"type":"integer","format":"int32","default":1}},{"name":"size","in":"query","schema":{"minimum":1,"type":"integer","format":"int32","default":10}},{"name":"with_experiments_only","in":"query","schema":{"type":"boolean"}},{"name":"prompt_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"name","in":"query","schema":{"type":"string"}}]}
parameters={[{"name":"page","in":"query","schema":{"minimum":1,"type":"integer","format":"int32","default":1}},{"name":"size","in":"query","schema":{"minimum":1,"type":"integer","format":"int32","default":10}},{"name":"with_experiments_only","in":"query","schema":{"type":"boolean"}},{"name":"prompt_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"name","in":"query","schema":{"type":"string"}},{"name":"sorting","in":"query","schema":{"type":"string"}}]}
>

</ParamsDetails>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "Gets specified metrics for a project"
sidebar_label: "Get Project Metrics"
hide_title: true
hide_table_of_contents: true
api: eJzNV1tvG7cS/itz+HQarC72SZCeRVFAsdXUsGsbso0itQx7tBxpWXPJLcmVogr678WQK0uyEzcPfagft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J0Z539A2iOyTQ+UJEC5H/+KARTeUKXQjyUNYWKhQGZBUa7vkOEW7OW9RcTua2Fyv1bxkJEg1mxGjIoKk4UrPWXQH3ry5Ij3rcD2ShFaVD2gKyt+8gU+2gYXSGryqar0EQyQ52GklXabwj84APdx/tb57P5CRNQ+MO24gP96zk15VSqPrwphTrnwUJWmGjd44tMkCA8J3k7Xbot4z70t2RVL295SWsQbiwa/WPfgaC0pwIygJJUU7CNJI3MAzfQFf2kZLmKaQAdzf3/NjxT8AEzGIEH+SOxE5TMTSNq6z2Jx1eNxPRLZhwSaU1qk/I8J3GLBWnQdaTgQTrp+U8cuxhYAPxKBiyxylbLOde9I2Vsc5DtJSwmGLn0h//4HQkYN7qB3N1OcujC34hQpFyTFsPCP6KYIx2Jtg7ZVmFsugwGhfoVXxwDhmMpIqwLQJwRqQytcalyRhUZKB0j4SzyDgZ2sO18T16Ox+h7YV5BjAUMYOpiRtMtMCoh2gWITtSiU+xuYDI6qtV8E6HoP78+Nr7YkbsFYFGU878vo1FiXBUfdgT1A7hzB+7Vo377Wsvnd2MhieXw07R92DbhkqHdcqcj417cPuQfeAj3imVmh2TacAL1fxvZ6/c6361sthO9cCfQ69WqMyrDw6smoH+o14PIw7RRzpabtIF9JM5PGOuJnrt5ng0maW1WqKnq6dXq/5+I+G3FLkN7e8QjqFU55fNyshled3KfIZak+vuPPvUbvafgdfs3qz3RhOarupCpGJB1qm2+yal/NUAVF7+jBIOjpjZt8yvti4eNVIHP2ioDq8Snu7sx5d8r0iE9P25ltZyTwOF3ylxkUysu3ScYnns5XQaOYNzpk2yeS//wEzh32E
sidebar_class_name: "post api-method"
info_path: reference/rest_api/opik-rest-api
custom_edit_url: null
Expand Down Expand Up @@ -55,15 +55,15 @@ Gets specified metrics for a project

<RequestSchema
title={"Body"}
body={{"content":{"application/json":{"schema":{"type":"object","properties":{"metric_type":{"type":"string","enum":["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE"]},"interval":{"type":"string","enum":["HOURLY","DAILY","WEEKLY"]},"interval_start":{"type":"string","format":"date-time"},"interval_end":{"type":"string","format":"date-time"}},"title":"ProjectMetricRequest_Public"}}}}}
body={{"content":{"application/json":{"schema":{"type":"object","properties":{"metric_type":{"type":"string","enum":["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST"]},"interval":{"type":"string","enum":["HOURLY","DAILY","WEEKLY"]},"interval_start":{"type":"string","format":"date-time"},"interval_end":{"type":"string","format":"date-time"}},"title":"ProjectMetricRequest_Public"}}}}}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Project Metrics","content":{"application/json":{"schema":{"type":"object","properties":{"project_id":{"type":"string","format":"uuid"},"metric_type":{"type":"string","enum":["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE"]},"interval":{"type":"string","enum":["HOURLY","DAILY","WEEKLY"]},"results":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"data":{"type":"array","items":{"required":["time"],"type":"object","properties":{"time":{"type":"string","format":"date-time"},"value":{"type":"number"}},"title":"DataPointNumber_Public"}}},"title":"ResultsNumber_Public"}}},"title":"ProjectMetricResponse_Public"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"string"}}},"title":"ErrorMessage_Public"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"string"}}},"title":"ErrorMessage_Public"}}}}}}
responses={{"200":{"description":"Project Metrics","content":{"application/json":{"schema":{"type":"object","properties":{"project_id":{"type":"string","format":"uuid"},"metric_type":{"type":"string","enum":["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST"]},"interval":{"type":"string","enum":["HOURLY","DAILY","WEEKLY"]},"results":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"data":{"type":"array","items":{"required":["time"],"type":"object","properties":{"time":{"type":"string","format":"date-time"},"value":{"type":"number"}},"title":"DataPointNumber_Public"}}},"title":"ResultsNumber_Public"}}},"title":"ProjectMetricResponse_Public"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"string"}}},"title":"ErrorMessage_Public"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"string"}}},"title":"ErrorMessage_Public"}}}}}}
>

</StatusCodes>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
sidebar_position: 1
sidebar_label: Production Monitoring
toc_min_heading_level: 2
toc_max_heading_level: 4
---

# Production Monitoring

Opik has been designed from the ground up to support high volumes of traces making it the ideal tool for monitoring your production LLM applications.

You can use the Opik dashboard to review your feedback scores, trace count and tokens over time at both a daily and hourly granularity.

![Opik monitoring dashboard](/img/tracing/opik_monitoring_dashboard.png)

In addition to viewing scores over time, you can also view the average feedback scores for all the traces in your project from the traces table.

## Logging feedback scores

To monitor the performance of your LLM application, you can log feedback scores using the [Python SDK and through the UI](/tracing/annotate_traces.md).

### Logging feedback scores alongside traces

Feedback scores can be logged while you are logging traces:

```python
from opik import track, opik_context

@track
def llm_chain(input_text):
# LLM chain code
# ...

# Update the trace
opik_context.update_current_trace(
feedback_scores=[
{"name": "user_feedback", "value": 1.0, "reason": "The response was helpful and accurate."}
]
)
```

### Updating traces with feedback scores

You can also update traces with feedback scores after they have been logged. For this we are first going to fetch all the traces using the search API and then update the feedback scores for the traces we want to annotate.

#### Fetching traces using the search API

You can use the [`Opik.search_traces`](https://www.comet.com/docs/opik/python-sdk-reference/Opik.html#opik.Opik.search_traces) method to fetch all the traces you want to annotate.

```python
import opik

opik_client = opik.Opik()

traces = opik_client.search_traces(
project_name="Default Project",
start_time="2024-01-01",
end_time="2025-01-01",
)
```

:::tip

The `search_traces` method allows you to fetch traces based on any of trace attributes, you can learn more about the different search parameters in the [search traces documentation](/tracing/export_data.md).

:::

#### Updating feedback scores

Once you have fetched the traces you want to annotate, you can update the feedback scores using the [`Opik.log_traces_feedback_scores`](https://www.comet.com/docs/opik/python-sdk-reference/Opik.html#opik.Opik.log_traces_feedback_scores) method.

```python
for trace in traces:
opik_client.log_traces_feedback_scores(
project_name="Default Project",
trace_ids=[i.id],
feedback_scores=[{"name": "user_feedback", "value": 1.0, "reason": "The response was helpful and accurate."}],
)
```

You will now be able to see the feedback scores in the Opik dashboard and track the changes over time.
1 change: 1 addition & 0 deletions apps/opik-documentation/documentation/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const sidebars: SidebarsConfig = {
"tracing/log_multimodal_traces",
"tracing/log_distributed_traces",
"tracing/annotate_traces",
"tracing/production_monitoring",
"tracing/sdk_configuration",
"tracing/export_data",
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8545d22

Please sign in to comment.