-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
147 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...c/test/java/com/comet/opik/podam/manufacturer/anthropic/AnthropicContentManufacturer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.comet.opik.podam.manufacturer.anthropic; | ||
|
||
import dev.langchain4j.model.anthropic.internal.api.AnthropicContent; | ||
import uk.co.jemos.podam.api.AttributeMetadata; | ||
import uk.co.jemos.podam.api.DataProviderStrategy; | ||
import uk.co.jemos.podam.common.ManufacturingContext; | ||
import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; | ||
|
||
public class AnthropicContentManufacturer extends AbstractTypeManufacturer<AnthropicContent> { | ||
public static final AnthropicContentManufacturer INSTANCE = new AnthropicContentManufacturer(); | ||
|
||
@Override | ||
public AnthropicContent getType(DataProviderStrategy strategy, AttributeMetadata metadata, | ||
ManufacturingContext context) { | ||
var content = new AnthropicContent(); | ||
content.name = strategy.getTypeValue(metadata, context, String.class); | ||
content.text = strategy.getTypeValue(metadata, context, String.class); | ||
content.id = strategy.getTypeValue(metadata, context, String.class); | ||
|
||
return content; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...m/comet/opik/podam/manufacturer/anthropic/AnthropicCreateMessageResponseManufacturer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.comet.opik.podam.manufacturer.anthropic; | ||
|
||
import dev.langchain4j.model.anthropic.internal.api.AnthropicContent; | ||
import dev.langchain4j.model.anthropic.internal.api.AnthropicCreateMessageResponse; | ||
import dev.langchain4j.model.anthropic.internal.api.AnthropicUsage; | ||
import uk.co.jemos.podam.api.AttributeMetadata; | ||
import uk.co.jemos.podam.api.DataProviderStrategy; | ||
import uk.co.jemos.podam.common.ManufacturingContext; | ||
import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; | ||
|
||
import java.util.List; | ||
|
||
public class AnthropicCreateMessageResponseManufacturer | ||
extends | ||
AbstractTypeManufacturer<AnthropicCreateMessageResponse> { | ||
public static final AnthropicCreateMessageResponseManufacturer INSTANCE = new AnthropicCreateMessageResponseManufacturer(); | ||
|
||
@Override | ||
public AnthropicCreateMessageResponse getType(DataProviderStrategy strategy, AttributeMetadata metadata, | ||
ManufacturingContext context) { | ||
var response = new AnthropicCreateMessageResponse(); | ||
response.id = strategy.getTypeValue(metadata, context, String.class); | ||
response.model = strategy.getTypeValue(metadata, context, String.class); | ||
response.stopReason = strategy.getTypeValue(metadata, context, String.class); | ||
response.content = List.of(strategy.getTypeValue(metadata, context, AnthropicContent.class)); | ||
response.usage = strategy.getTypeValue(metadata, context, AnthropicUsage.class); | ||
|
||
return response; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...src/test/java/com/comet/opik/podam/manufacturer/anthropic/AnthropicUsageManufacturer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.comet.opik.podam.manufacturer.anthropic; | ||
|
||
import dev.langchain4j.model.anthropic.internal.api.AnthropicUsage; | ||
import uk.co.jemos.podam.api.AttributeMetadata; | ||
import uk.co.jemos.podam.api.DataProviderStrategy; | ||
import uk.co.jemos.podam.common.ManufacturingContext; | ||
import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; | ||
|
||
public class AnthropicUsageManufacturer extends AbstractTypeManufacturer<AnthropicUsage> { | ||
public static final AnthropicUsageManufacturer INSTANCE = new AnthropicUsageManufacturer(); | ||
|
||
@Override | ||
public AnthropicUsage getType(DataProviderStrategy strategy, AttributeMetadata metadata, | ||
ManufacturingContext context) { | ||
var usage = new AnthropicUsage(); | ||
usage.inputTokens = strategy.getTypeValue(metadata, context, Integer.class); | ||
usage.outputTokens = strategy.getTypeValue(metadata, context, Integer.class); | ||
|
||
return usage; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...t/java/com/comet/opik/podam/manufacturer/anthropic/ChatCompletionRequestManufacturer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.comet.opik.podam.manufacturer.anthropic; | ||
|
||
import dev.ai4j.openai4j.chat.ChatCompletionRequest; | ||
import uk.co.jemos.podam.api.AttributeMetadata; | ||
import uk.co.jemos.podam.api.DataProviderStrategy; | ||
import uk.co.jemos.podam.common.ManufacturingContext; | ||
import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; | ||
|
||
public class ChatCompletionRequestManufacturer extends AbstractTypeManufacturer<ChatCompletionRequest> { | ||
public static final ChatCompletionRequestManufacturer INSTANCE = new ChatCompletionRequestManufacturer(); | ||
|
||
@Override | ||
public ChatCompletionRequest getType(DataProviderStrategy strategy, AttributeMetadata metadata, | ||
ManufacturingContext context) { | ||
var userMessageContent = strategy.getTypeValue(metadata, context, String.class); | ||
var assistantMessageContent = strategy.getTypeValue(metadata, context, String.class); | ||
var systemMessageContent = strategy.getTypeValue(metadata, context, String.class); | ||
|
||
return ChatCompletionRequest.builder() | ||
.model(strategy.getTypeValue(metadata, context, String.class)) | ||
.stream(strategy.getTypeValue(metadata, context, Boolean.class)) | ||
.temperature(strategy.getTypeValue(metadata, context, Double.class)) | ||
.topP(strategy.getTypeValue(metadata, context, Double.class)) | ||
.stop(strategy.getTypeValue(metadata, context, String.class)) | ||
.addUserMessage(userMessageContent) | ||
.addAssistantMessage(assistantMessageContent) | ||
.addSystemMessage(systemMessageContent) | ||
.maxCompletionTokens(strategy.getTypeValue(metadata, context, Integer.class)) | ||
.build(); | ||
} | ||
} |