Skip to content

Commit

Permalink
Merge branch 'main' into boryst/OPIK-622-dataset-items-include-a-colu…
Browse files Browse the repository at this point in the history
…mn-named-input-with-non-dictionary-type-values
  • Loading branch information
andrescrz authored Jan 9, 2025
2 parents 8fb386a + 9ae31b9 commit 42e8d03
Show file tree
Hide file tree
Showing 44 changed files with 1,272 additions and 161 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/backend_formatting_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Backend Formatting Check"
run-name: "Backend Formatting Check on ${{ github.ref_name }} by @${{ github.actor }}"

on:
pull_request:
paths:
- "apps/opik-backend/**/*.java"
push:
branches:
- "main"
paths:
- "apps/opik-backend/**/*.java"

workflow_dispatch:

jobs:
run-backend-formatting-check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/opik-backend/
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 1

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
cache: maven

- name: Run Formatting Check for backend
run: mvn clean spotless:check
5 changes: 5 additions & 0 deletions .github/workflows/documentation_codeblock_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ jobs:
test:
needs: collect_test_paths
runs-on: ubuntu-latest
env:
OPENAI_API_KEY: ${{ secrets.DOCS_OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPIK_WORKSPACE: ${{ secrets.COMET_WORKSPACE }}
OPIK_API_KEY: ${{ secrets.COMET_API_KEY }}
strategy:
matrix:
path: ${{ fromJson(needs.collect_test_paths.outputs.test_paths) }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/documentation_cookbook_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- apps/opik-documentation/documentation/docs/cookbook/openai.ipynb
- apps/opik-documentation/documentation/docs/cookbook/litellm.ipynb
- apps/opik-documentation/documentation/docs/cookbook/ragas.ipynb
- apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb
env:
NOTEBOOK_TO_TEST: ${{ matrix.notebooks }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
target/
**/dependency-reduced-pom.xml

# BE related
/apps/opik-backend/redoc/openapi.yaml

# FE related
/apps/opik-frontend/dist
/apps/opik-frontend/build
Expand Down
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,23 @@ Replace `{project.pom.version}` with the version of the project in the pom file.

Once the backend is running, you can access the Opik API at `http://localhost:8080`.

#### Formatting the code

Before submitting a PR, please ensure that your code is formatted correctly.
Run the following command to automatically format your code:

```bash
mvn spotless:apply
```

Our CI will check that the code is formatted correctly and will fail if it is not by running the following command:

```bash
mvn spotless:check
```

#### Testing the backend

Before submitting a PR, please ensure that your code passes the test suite:

```bash
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ The easiest way to get started is to use one of our integrations. Opik supports:
| OpenAI | Log traces for all OpenAI LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/openai/?utm_source=opik&utm_medium=github&utm_content=openai_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/openai.ipynb) |
| LiteLLM | Call any LLM model using the OpenAI format | [Documentation](/tracing/integrations/litellm.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/litellm.ipynb) |
| LangChain | Log traces for all LangChain LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/langchain/?utm_source=opik&utm_medium=github&utm_content=langchain_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/langchain.ipynb) |
| Haystack | Log traces for all Haystack calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/haystack/?utm_source=opik&utm_medium=github&utm_content=haystack_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/haystack.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) |
| Haystack | Log traces for all Haystack calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/haystack/?utm_source=opik&utm_medium=github&utm_content=haystack_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/haystack.ipynb) |
| 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) |
| 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) |
| LangGraph | Log traces for all LangGraph executions | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/langgraph/?utm_source=opik&utm_medium=github&utm_content=langchain_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/langgraph.ipynb) |
Expand Down
6 changes: 6 additions & 0 deletions apps/opik-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<redisson.version>3.41.0</redisson.version>
<opentelmetry.version>2.10.0</opentelmetry.version>
<aws.java.sdk.version>2.29.9</aws.java.sdk.version>
<json-path.version>2.9.0</json-path.version>
<mainClass>com.comet.opik.OpikApplication</mainClass>
</properties>

Expand Down Expand Up @@ -207,6 +208,11 @@
<artifactId>java-uuid-generator</artifactId>
<version>${uuid.java.generator.version}</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>${json-path.version}</version>
</dependency>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.media.DiscriminatorMapping;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

import java.beans.ConstructorProperties;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
Expand All @@ -24,38 +20,16 @@
@SuperBuilder(toBuilder = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = AutomationRuleEvaluator.AutomationRuleEvaluatorLlmAsJudge.class, name = "llm_as_judge")
@JsonSubTypes.Type(value = AutomationRuleEvaluatorLlmAsJudge.class, name = "llm_as_judge")
})
@Schema(name = "AutomationRuleEvaluator", discriminatorProperty = "type", discriminatorMapping = {
@DiscriminatorMapping(value = "llm_as_judge", schema = AutomationRuleEvaluator.AutomationRuleEvaluatorLlmAsJudge.class)
@DiscriminatorMapping(value = "llm_as_judge", schema = AutomationRuleEvaluatorLlmAsJudge.class)
})
@AllArgsConstructor
public abstract sealed class AutomationRuleEvaluator<T> implements AutomationRule<T> {

@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder(toBuilder = true)
@ToString(callSuper = true)
public static final class AutomationRuleEvaluatorLlmAsJudge extends AutomationRuleEvaluator<JsonNode> {

@NotNull @JsonView({View.Public.class, View.Write.class})
@Schema(accessMode = Schema.AccessMode.READ_WRITE)
JsonNode code;

@ConstructorProperties({"id", "projectId", "name", "samplingRate", "code", "createdAt", "createdBy",
"lastUpdatedAt", "lastUpdatedBy"})
public AutomationRuleEvaluatorLlmAsJudge(UUID id, UUID projectId, @NotBlank String name, float samplingRate,
@NotNull JsonNode code,
Instant createdAt, String createdBy, Instant lastUpdatedAt, String lastUpdatedBy) {
super(id, projectId, name, samplingRate, createdAt, createdBy, lastUpdatedAt, lastUpdatedBy);
this.code = code;
}

@Override
public AutomationRuleEvaluatorType type() {
return AutomationRuleEvaluatorType.LLM_AS_JUDGE;
}
}
public abstract sealed class AutomationRuleEvaluator<T>
implements
AutomationRule<T>
permits AutomationRuleEvaluatorLlmAsJudge {

@JsonView({View.Public.class})
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.comet.opik.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Builder;

import java.util.Set;
import java.util.UUID;

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public record AutomationRuleEvaluatorCriteria(
AutomationRuleEvaluatorType type,
String name,
Set<UUID> ids) {

public AutomationRule.AutomationRuleAction action() {
return AutomationRule.AutomationRuleAction.EVALUATOR;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.comet.opik.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;
import dev.langchain4j.data.message.ChatMessageType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

import java.beans.ConstructorProperties;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder(toBuilder = true)
@ToString(callSuper = true)
public final class AutomationRuleEvaluatorLlmAsJudge
extends
AutomationRuleEvaluator<AutomationRuleEvaluatorLlmAsJudge.LlmAsJudgeCode> {

@NotNull @JsonView({View.Public.class, View.Write.class})
@Schema(accessMode = Schema.AccessMode.READ_WRITE)
private LlmAsJudgeCode code;

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public record LlmAsJudgeCode(
@JsonView( {
View.Public.class, View.Write.class}) @NotNull LlmAsJudgeModelParameters model,
@JsonView({View.Public.class, View.Write.class}) @NotNull List<LlmAsJudgeMessage> messages,
@JsonView({View.Public.class, View.Write.class}) @NotNull Map<String, String> variables,
@JsonView({View.Public.class, View.Write.class}) @NotNull List<LlmAsJudgeOutputSchema> schema){
}

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public record LlmAsJudgeMessage(
@JsonView( {
View.Public.class, View.Write.class}) @NotNull ChatMessageType role,
@JsonView({View.Public.class, View.Write.class}) @NotNull String content){
}

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public record LlmAsJudgeOutputSchema(
@JsonView( {
View.Public.class, View.Write.class}) @NotNull String name,
@JsonView({View.Public.class, View.Write.class}) @NotNull LlmAsJudgeOutputSchemaType type,
@JsonView({View.Public.class, View.Write.class}) @NotNull String description){
}

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public record LlmAsJudgeModelParameters(
@JsonView( {
View.Public.class, View.Write.class}) @NotNull String name,
@JsonView({View.Public.class, View.Write.class}) @NotNull Double temperature){
}

@ConstructorProperties({"id", "projectId", "name", "samplingRate", "code", "createdAt", "createdBy",
"lastUpdatedAt", "lastUpdatedBy"})
public AutomationRuleEvaluatorLlmAsJudge(UUID id, UUID projectId, @NotBlank String name, Float samplingRate,
@NotNull LlmAsJudgeCode code,
Instant createdAt, String createdBy, Instant lastUpdatedAt, String lastUpdatedBy) {
super(id, projectId, name, samplingRate, createdAt, createdBy, lastUpdatedAt, lastUpdatedBy);
this.code = code;
}

@Override
public AutomationRuleEvaluatorType type() {
return AutomationRuleEvaluatorType.LLM_AS_JUDGE;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.comet.opik.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import jakarta.validation.constraints.NotNull;
Expand All @@ -12,6 +11,6 @@
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record AutomationRuleEvaluatorUpdate(
@NotNull String name,
@NotNull JsonNode code,
@NotNull AutomationRuleEvaluatorLlmAsJudge.LlmAsJudgeCode code,
@NotNull Float samplingRate) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.comet.opik.api;

public enum LlmAsJudgeOutputSchemaType {
BOOLEAN,
INTEGER,
DOUBLE
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.comet.opik.api.events;

import com.comet.opik.api.Trace;
import com.comet.opik.infrastructure.events.BaseEvent;
import lombok.Getter;
import lombok.NonNull;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

@Getter
@Accessors(fluent = true)
public class TracesCreated extends BaseEvent {
private final @NonNull Set<UUID> projectIds;
private final @NonNull List<Trace> traces;

public TracesCreated(@NonNull Set<UUID> projectIds, @NonNull String workspaceId, @NonNull String userName) {
public TracesCreated(@NonNull List<Trace> traces, @NonNull String workspaceId, @NonNull String userName) {
super(workspaceId, userName);
this.projectIds = projectIds;
this.traces = traces;
}

public Set<UUID> projectIds() {
return traces.stream()
.map(Trace::projectId)
.collect(Collectors.toSet());
}
}
Loading

0 comments on commit 42e8d03

Please sign in to comment.