Skip to content

Commit 762cd8b

Browse files
Merge pull request #438 from skyflowapi/flowvault-release/26.10.1
SK-3222 Flowvault release/26.10.1
2 parents eecd06a + 932676d commit 762cd8b

190 files changed

Lines changed: 22336 additions & 276 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎common/pom.xml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,13 @@
2121
<maven.compiler.target>8</maven.compiler.target>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>com.squareup.okhttp3</groupId>
28+
<artifactId>mockwebserver</artifactId>
29+
<version>${okhttp-version}</version>
30+
<scope>test</scope>
31+
</dependency>
32+
</dependencies>
2433
</project>

‎common/src/main/java/com/skyflow/BaseSkyflow.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.skyflow.config.Credentials;
55
import com.skyflow.enums.LogLevel;
66
import com.skyflow.errors.ErrorCode;
7-
import com.skyflow.errors.ErrorMessage;
7+
import com.skyflow.errors.BaseErrorMessage;
88
import com.skyflow.errors.SkyflowException;
99
import com.skyflow.logs.ErrorLogs;
1010
import com.skyflow.logs.InfoLogs;
@@ -66,7 +66,7 @@ public LogLevel getLogLevel() {
6666
}
6767

6868
protected static <T> T resolveOrThrow(Map<String, T> map, String key,
69-
ErrorLogs errorLog, ErrorMessage errorMessage) throws SkyflowException {
69+
ErrorLogs errorLog, BaseErrorMessage errorMessage) throws SkyflowException {
7070
T value = key != null ? map.get(key) : map.values().stream().findFirst().orElse(null);
7171
if (value == null) {
7272
// The log line carries a %s1 placeholder for the id. Callers that resolve the single
@@ -125,7 +125,7 @@ protected final void addVaultConfigTemplate(V vaultConfig) throws SkyflowExcepti
125125
ErrorLogs.VAULT_CONFIG_EXISTS.getLog(), vaultId
126126
));
127127
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(),
128-
ErrorMessage.VaultIdAlreadyInConfigList.getMessage());
128+
BaseErrorMessage.VaultIdAlreadyInConfigList.getMessage());
129129
}
130130
onVaultConfigAdded(vaultConfigCopy);
131131
this.vaultConfigMap.put(vaultId, vaultConfigCopy);
@@ -139,7 +139,7 @@ protected final void updateVaultConfigTemplate(V vaultConfig) throws SkyflowExce
139139
LogUtil.printErrorLog(BaseUtils.parameterizedString(
140140
ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultId
141141
));
142-
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage());
142+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseErrorMessage.VaultIdNotInConfigList.getMessage());
143143
}
144144
V previousConfig = this.vaultConfigMap.get(vaultId);
145145
V merged = mergeVaultConfig(vaultConfig, cloneVaultConfig(previousConfig));
@@ -150,7 +150,7 @@ protected final void updateVaultConfigTemplate(V vaultConfig) throws SkyflowExce
150150
protected final void removeVaultConfigTemplate(String vaultId) throws SkyflowException {
151151
if (!hasVaultClient(vaultId)) {
152152
LogUtil.printErrorLog(BaseUtils.parameterizedString(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultId));
153-
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage());
153+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseErrorMessage.VaultIdNotInConfigList.getMessage());
154154
}
155155
onVaultConfigRemoved(vaultId);
156156
this.vaultConfigMap.remove(vaultId);

‎common/src/main/java/com/skyflow/BaseVaultClient.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.skyflow.config.BaseCredentials;
66
import com.skyflow.config.BaseVaultConfig;
77
import com.skyflow.errors.ErrorCode;
8-
import com.skyflow.errors.ErrorMessage;
8+
import com.skyflow.errors.BaseErrorMessage;
99
import com.skyflow.errors.SkyflowException;
1010
import com.skyflow.logs.ErrorLogs;
1111
import com.skyflow.logs.InfoLogs;
@@ -25,7 +25,7 @@
2525
import java.util.concurrent.TimeUnit;
2626
import java.util.function.Supplier;
2727

28-
class BaseVaultClient<V extends BaseVaultConfig> {
28+
public class BaseVaultClient<V extends BaseVaultConfig> {
2929
protected V vaultConfig;
3030
protected OkHttpClient sharedHttpClient;
3131
protected String currentVaultURL;
@@ -69,7 +69,7 @@ protected synchronized void prioritiseCredentials(BaseCredentials vaultSpecificC
6969
sysCredentials = dotenv.get(BaseConstants.ENV_CREDENTIALS_KEY_NAME);
7070
}
7171
if (sysCredentials == null) {
72-
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentials.getMessage());
72+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseErrorMessage.EmptyCredentials.getMessage());
7373
} else {
7474
this.finalCredentials = new BaseCredentials();
7575
this.finalCredentials.setCredentialsString(sysCredentials);
@@ -80,7 +80,7 @@ protected synchronized void prioritiseCredentials(BaseCredentials vaultSpecificC
8080
apiKey = null;
8181
}
8282
} catch (DotenvException e) {
83-
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentials.getMessage());
83+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseErrorMessage.EmptyCredentials.getMessage());
8484
} catch (SkyflowException e) {
8585
throw e;
8686
} catch (Exception e) {
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package com.skyflow.detect;
2+
3+
/**
4+
* Audio processing options.
5+
*/
6+
public final class Audio {
7+
private final Boolean outputProcessedAudio;
8+
private final OutputTranscriptionType outputTranscription;
9+
private final Bleep bleep;
10+
11+
private Audio(AudioBuilder builder) {
12+
this.outputProcessedAudio = builder.outputProcessedAudio;
13+
this.outputTranscription = builder.outputTranscription;
14+
this.bleep = builder.bleep;
15+
}
16+
17+
/**
18+
* @return a new builder
19+
*/
20+
public static AudioBuilder builder() {
21+
return new AudioBuilder();
22+
}
23+
24+
/**
25+
* @return Whether to return the processed audio file.
26+
*/
27+
public Boolean getOutputProcessedAudio() {
28+
return outputProcessedAudio;
29+
}
30+
31+
/**
32+
* @return Transcription output to produce.
33+
*/
34+
public OutputTranscriptionType getOutputTranscription() {
35+
return outputTranscription;
36+
}
37+
38+
/**
39+
* @return Bleep configuration.
40+
*/
41+
public Bleep getBleep() {
42+
return bleep;
43+
}
44+
45+
@Override
46+
public String toString() {
47+
return "Audio{" +
48+
"outputProcessedAudio=" + outputProcessedAudio +
49+
", outputTranscription=" + outputTranscription +
50+
", bleep=" + bleep +
51+
'}';
52+
}
53+
54+
public static final class AudioBuilder {
55+
private Boolean outputProcessedAudio;
56+
private OutputTranscriptionType outputTranscription;
57+
private Bleep bleep;
58+
59+
private AudioBuilder() {
60+
}
61+
62+
/**
63+
* @param outputProcessedAudio Whether to return the processed audio file.
64+
* @return this builder
65+
*/
66+
public AudioBuilder outputProcessedAudio(Boolean outputProcessedAudio) {
67+
this.outputProcessedAudio = outputProcessedAudio;
68+
return this;
69+
}
70+
71+
/**
72+
* @param outputTranscription Transcription output to produce.
73+
* @return this builder
74+
*/
75+
public AudioBuilder outputTranscription(OutputTranscriptionType outputTranscription) {
76+
this.outputTranscription = outputTranscription;
77+
return this;
78+
}
79+
80+
/**
81+
* @param bleep Bleep configuration.
82+
* @return this builder
83+
*/
84+
public AudioBuilder bleep(Bleep bleep) {
85+
this.bleep = bleep;
86+
return this;
87+
}
88+
89+
public Audio build() {
90+
return new Audio(this);
91+
}
92+
}
93+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package com.skyflow.detect;
2+
3+
/**
4+
* Bleep tone applied over detected speech in audio.
5+
*/
6+
public final class Bleep {
7+
private final Float startPadding;
8+
private final Float stopPadding;
9+
private final Integer frequency;
10+
private final Integer gain;
11+
12+
private Bleep(BleepBuilder builder) {
13+
this.startPadding = builder.startPadding;
14+
this.stopPadding = builder.stopPadding;
15+
this.frequency = builder.frequency;
16+
this.gain = builder.gain;
17+
}
18+
19+
/**
20+
* @return a new builder
21+
*/
22+
public static BleepBuilder builder() {
23+
return new BleepBuilder();
24+
}
25+
26+
/**
27+
* @return Seconds of bleep added before the detected span.
28+
*/
29+
public Float getStartPadding() {
30+
return startPadding;
31+
}
32+
33+
/**
34+
* @return Seconds of bleep added after the detected span.
35+
*/
36+
public Float getStopPadding() {
37+
return stopPadding;
38+
}
39+
40+
/**
41+
* @return Bleep frequency in Hz.
42+
*/
43+
public Integer getFrequency() {
44+
return frequency;
45+
}
46+
47+
/**
48+
* @return Bleep gain.
49+
*/
50+
public Integer getGain() {
51+
return gain;
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return "Bleep{" +
57+
"startPadding=" + startPadding +
58+
", stopPadding=" + stopPadding +
59+
", frequency=" + frequency +
60+
", gain=" + gain +
61+
'}';
62+
}
63+
64+
public static final class BleepBuilder {
65+
private Float startPadding;
66+
private Float stopPadding;
67+
private Integer frequency;
68+
private Integer gain;
69+
70+
private BleepBuilder() {
71+
}
72+
73+
/**
74+
* @param startPadding Seconds of bleep added before the detected span.
75+
* @return this builder
76+
*/
77+
public BleepBuilder startPadding(Float startPadding) {
78+
this.startPadding = startPadding;
79+
return this;
80+
}
81+
82+
/**
83+
* @param stopPadding Seconds of bleep added after the detected span.
84+
* @return this builder
85+
*/
86+
public BleepBuilder stopPadding(Float stopPadding) {
87+
this.stopPadding = stopPadding;
88+
return this;
89+
}
90+
91+
/**
92+
* @param frequency Bleep frequency in Hz.
93+
* @return this builder
94+
*/
95+
public BleepBuilder frequency(Integer frequency) {
96+
this.frequency = frequency;
97+
return this;
98+
}
99+
100+
/**
101+
* @param gain Bleep gain.
102+
* @return this builder
103+
*/
104+
public BleepBuilder gain(Integer gain) {
105+
this.gain = gain;
106+
return this;
107+
}
108+
109+
public Bleep build() {
110+
return new Bleep(this);
111+
}
112+
}
113+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.skyflow.detect;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Request for {@code checkGuardrails}: screens text for toxicity and denied topics.
7+
*/
8+
public final class CheckGuardrailsRequest {
9+
private final String text;
10+
private final Boolean checkToxicity;
11+
private final List<String> denyTopics;
12+
13+
private CheckGuardrailsRequest(CheckGuardrailsRequestBuilder builder) {
14+
this.text = builder.text;
15+
this.checkToxicity = builder.checkToxicity;
16+
this.denyTopics = builder.denyTopics;
17+
}
18+
19+
/**
20+
* @return a new builder
21+
*/
22+
public static CheckGuardrailsRequestBuilder builder() {
23+
return new CheckGuardrailsRequestBuilder();
24+
}
25+
26+
/**
27+
* @return Text to screen. Required.
28+
*/
29+
public String getText() {
30+
return text;
31+
}
32+
33+
/**
34+
* @return Whether to check the text for toxicity.
35+
*/
36+
public Boolean getCheckToxicity() {
37+
return checkToxicity;
38+
}
39+
40+
/**
41+
* @return Topics the text must not discuss.
42+
*/
43+
public List<String> getDenyTopics() {
44+
return denyTopics;
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "CheckGuardrailsRequest{" +
50+
"text=" + text +
51+
", checkToxicity=" + checkToxicity +
52+
", denyTopics=" + denyTopics +
53+
'}';
54+
}
55+
56+
public static final class CheckGuardrailsRequestBuilder {
57+
private String text;
58+
private Boolean checkToxicity;
59+
private List<String> denyTopics;
60+
61+
private CheckGuardrailsRequestBuilder() {
62+
}
63+
64+
/**
65+
* @param text Text to screen. Required.
66+
* @return this builder
67+
*/
68+
public CheckGuardrailsRequestBuilder text(String text) {
69+
this.text = text;
70+
return this;
71+
}
72+
73+
/**
74+
* @param checkToxicity Whether to check the text for toxicity.
75+
* @return this builder
76+
*/
77+
public CheckGuardrailsRequestBuilder checkToxicity(Boolean checkToxicity) {
78+
this.checkToxicity = checkToxicity;
79+
return this;
80+
}
81+
82+
/**
83+
* @param denyTopics Topics the text must not discuss.
84+
* @return this builder
85+
*/
86+
public CheckGuardrailsRequestBuilder denyTopics(List<String> denyTopics) {
87+
this.denyTopics = denyTopics;
88+
return this;
89+
}
90+
91+
public CheckGuardrailsRequest build() {
92+
return new CheckGuardrailsRequest(this);
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)