Skip to content

Commit

Permalink
chore: Update Orchestration Spec (#38)
Browse files Browse the repository at this point in the history
* Update Orchestration Spec

* Formatting

* Update docs

* Update unit test
  • Loading branch information
MatKuhr authored Sep 4, 2024
1 parent 6799b17 commit faa62af
Show file tree
Hide file tree
Showing 25 changed files with 1,497 additions and 1,353 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,21 @@ final var template =
"Create a rental posting for subletting my apartment in the downtown area. Keep it short. Make sure to add the following disclaimer to the end. Do not change it! {{?disclaimer}}");
final var templatingConfig = TemplatingModuleConfig.create().template(template);

final var filterStrict =
Filter.create()
.type(ProviderType.AZURE_CONTENT_SAFETY)
final var filterStrict =
FilterConfig.create()
.type(FilterConfig.TypeEnum.AZURE_CONTENT_SAFETY)
.config(
FilterConfig.create()
AzureContentSafety.create()
.hate(NUMBER_0)
.selfHarm(NUMBER_0)
.sexual(NUMBER_0)
.violence(NUMBER_0));

final var filterLoose =
Filter.create()
.type(ProviderType.AZURE_CONTENT_SAFETY)
FilterConfig.create()
.type(FilterConfig.TypeEnum.AZURE_CONTENT_SAFETY)
.config(
FilterConfig.create()
AzureContentSafety.create()
.hate(NUMBER_4)
.selfHarm(NUMBER_4)
.sexual(NUMBER_4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import static com.sap.ai.sdk.core.Core.getOrchestrationClient;

import com.sap.ai.sdk.orchestration.client.OrchestrationCompletionApi;
import com.sap.ai.sdk.orchestration.client.model.AzureContentSafety;
import com.sap.ai.sdk.orchestration.client.model.AzureThreshold;
import com.sap.ai.sdk.orchestration.client.model.ChatMessage;
import com.sap.ai.sdk.orchestration.client.model.CompletionPostRequest;
import com.sap.ai.sdk.orchestration.client.model.CompletionPostResponse;
import com.sap.ai.sdk.orchestration.client.model.Filter;
import com.sap.ai.sdk.orchestration.client.model.FilterConfig;
import com.sap.ai.sdk.orchestration.client.model.FilteringConfig;
import com.sap.ai.sdk.orchestration.client.model.FilteringModuleConfig;
import com.sap.ai.sdk.orchestration.client.model.LLMModuleConfig;
import com.sap.ai.sdk.orchestration.client.model.ModuleConfigs;
import com.sap.ai.sdk.orchestration.client.model.OrchestrationConfig;
import com.sap.ai.sdk.orchestration.client.model.ProviderType;
import com.sap.ai.sdk.orchestration.client.model.TemplatingModuleConfig;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -68,10 +67,10 @@ class OrchestrationController {
final var templatingConfig = TemplatingModuleConfig.create().template(template);

final var filter =
Filter.create()
.type(ProviderType.AZURE_CONTENT_SAFETY)
FilterConfig.create()
.type(FilterConfig.TypeEnum.AZURE_CONTENT_SAFETY)
.config(
FilterConfig.create()
AzureContentSafety.create()
.hate(filterThreshold)
.selfHarm(filterThreshold)
.sexual(filterThreshold)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/** AzureContentSafety */
/** Filter configuration for Azure Content Safety */
// CHECKSTYLE:OFF
public class AzureContentSafety
// CHECKSTYLE:ON
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
/*
* Internal Orchestration Service API
* SAP AI Core - Orchestration Service API
*
* The version of the OpenAPI document: 0.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

package com.sap.ai.sdk.orchestration.client.model;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/** AzureContentSafetyFilterConfig */
// CHECKSTYLE:OFF
public class AzureContentSafetyFilterConfig
// CHECKSTYLE:ON
{
/** String represents name of the filter provider */
public enum TypeEnum {
/** The AZURE_CONTENT_SAFETY option of this AzureContentSafetyFilterConfig */
AZURE_CONTENT_SAFETY("azure_content_safety");

private String value;

TypeEnum(String value) {
this.value = value;
}

/**
* Get the value of the enum
*
* @return The enum value
*/
@JsonValue
@Nonnull
public String getValue() {
return value;
}

/**
* Get the String value of the enum value.
*
* @return The enum value as String
*/
@Override
@Nonnull
public String toString() {
return String.valueOf(value);
}

/**
* Get the enum value from a String value
*
* @param value The String value
* @return The enum value of type AzureContentSafetyFilterConfig
*/
@JsonCreator
@Nonnull
public static TypeEnum fromValue(@Nonnull final String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("type")
private TypeEnum type;

@JsonProperty("config")
private AzureContentSafety config;

@JsonAnySetter @JsonAnyGetter
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();

protected AzureContentSafetyFilterConfig() {}

/**
* Set the type of this {@link AzureContentSafetyFilterConfig} instance and return the same
* instance.
*
* @param type String represents name of the filter provider
* @return The same instance of this {@link AzureContentSafetyFilterConfig} class
*/
@Nonnull
public AzureContentSafetyFilterConfig type(@Nonnull final TypeEnum type) {
this.type = type;
return this;
}

/**
* String represents name of the filter provider
*
* @return type The type of this {@link AzureContentSafetyFilterConfig} instance.
*/
@Nonnull
public TypeEnum getType() {
return type;
}

/**
* Set the type of this {@link AzureContentSafetyFilterConfig} instance.
*
* @param type String represents name of the filter provider
*/
public void setType(@Nonnull final TypeEnum type) {
this.type = type;
}

/**
* Set the config of this {@link AzureContentSafetyFilterConfig} instance and return the same
* instance.
*
* @param config The config of this {@link AzureContentSafetyFilterConfig}
* @return The same instance of this {@link AzureContentSafetyFilterConfig} class
*/
@Nonnull
public AzureContentSafetyFilterConfig config(@Nonnull final AzureContentSafety config) {
this.config = config;
return this;
}

/**
* Get config
*
* @return config The config of this {@link AzureContentSafetyFilterConfig} instance.
*/
@Nonnull
public AzureContentSafety getConfig() {
return config;
}

/**
* Set the config of this {@link AzureContentSafetyFilterConfig} instance.
*
* @param config The config of this {@link AzureContentSafetyFilterConfig}
*/
public void setConfig(@Nonnull final AzureContentSafety config) {
this.config = config;
}

/**
* Get the names of the unrecognizable properties of the {@link AzureContentSafetyFilterConfig}.
*
* @return The set of properties names
*/
@JsonIgnore
@Nonnull
public Set<String> getCustomFieldNames() {
return cloudSdkCustomFields.keySet();
}

/**
* Get the value of an unrecognizable property of this {@link AzureContentSafetyFilterConfig}
* instance.
*
* @param name The name of the property
* @return The value of the property
* @throws NoSuchElementException If no property with the given name could be found.
*/
@Nullable
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
if (!cloudSdkCustomFields.containsKey(name)) {
throw new NoSuchElementException(
"AzureContentSafetyFilterConfig has no field with name '" + name + "'.");
}
return cloudSdkCustomFields.get(name);
}

/**
* Set an unrecognizable property of this {@link AzureContentSafetyFilterConfig} instance. If the
* map previously contained a mapping for the key, the old value is replaced by the specified
* value.
*
* @param customFieldName The name of the property
* @param customFieldValue The value of the property
*/
@JsonIgnore
public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) {
cloudSdkCustomFields.put(customFieldName, customFieldValue);
}

@Override
public boolean equals(@Nullable final java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final AzureContentSafetyFilterConfig azureContentSafetyFilterConfig =
(AzureContentSafetyFilterConfig) o;
return Objects.equals(
this.cloudSdkCustomFields, azureContentSafetyFilterConfig.cloudSdkCustomFields)
&& Objects.equals(this.type, azureContentSafetyFilterConfig.type)
&& Objects.equals(this.config, azureContentSafetyFilterConfig.config);
}

@Override
public int hashCode() {
return Objects.hash(type, config, cloudSdkCustomFields);
}

@Override
@Nonnull
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("class AzureContentSafetyFilterConfig {\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" config: ").append(toIndentedString(config)).append("\n");
cloudSdkCustomFields.forEach(
(k, v) ->
sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(final java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

/**
* Create a type-safe, fluent-api builder object to construct a new {@link
* AzureContentSafetyFilterConfig} instance with all required arguments.
*/
public static Builder create() {
return (type) -> new AzureContentSafetyFilterConfig().type(type);
}

/** Builder helper class. */
public interface Builder {
/**
* Set the type of this {@link AzureContentSafetyFilterConfig} instance.
*
* @param type String represents name of the filter provider
* @return The AzureContentSafetyFilterConfig instance.
*/
AzureContentSafetyFilterConfig type(@Nonnull final TypeEnum type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,7 @@ private String toIndentedString(final java.lang.Object o) {
*/
public static Builder create() {
return (orchestrationConfig) ->
(inputParams) ->
new CompletionPostRequest()
.orchestrationConfig(orchestrationConfig)
.inputParams(inputParams);
new CompletionPostRequest().orchestrationConfig(orchestrationConfig);
}

/** Builder helper class. */
Expand All @@ -282,19 +279,9 @@ public interface Builder {
* Set the orchestrationConfig of this {@link CompletionPostRequest} instance.
*
* @param orchestrationConfig The orchestrationConfig of this {@link CompletionPostRequest}
* @return The CompletionPostRequest builder.
*/
Builder1 orchestrationConfig(@Nonnull final OrchestrationConfig orchestrationConfig);
}

/** Builder helper class. */
public interface Builder1 {
/**
* Set the inputParams of this {@link CompletionPostRequest} instance.
*
* @param inputParams The inputParams of this {@link CompletionPostRequest}
* @return The CompletionPostRequest instance.
*/
CompletionPostRequest inputParams(@Nonnull final Map<String, String> inputParams);
CompletionPostRequest orchestrationConfig(
@Nonnull final OrchestrationConfig orchestrationConfig);
}
}
Loading

0 comments on commit faa62af

Please sign in to comment.