Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 5, 2023
1 parent 73ad6b5 commit 7bfdc23
Show file tree
Hide file tree
Showing 61 changed files with 991 additions and 1,013 deletions.
849 changes: 463 additions & 386 deletions Examples/EdgeChainApplication.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public PineconeRetrieval(PineconeEndpoint pineconeEndpoint, Doc2VecEndpoint doc2
logger.info("Using Doc2Vec Embedding Service");
}


@Override
public void upsert(String input) {

Expand All @@ -47,7 +46,7 @@ public void upsert(String input) {
}
// For Doc2Vec ===>

if(Objects.nonNull(doc2VecEndpoint)) {
if (Objects.nonNull(doc2VecEndpoint)) {
new EdgeChain<>(
this.doc2VecEndpoint
.getEmbeddings(input)
Expand All @@ -57,6 +56,5 @@ public void upsert(String input) {
.await()
.blockingAwait();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public RedisRetrieval(
logger.info("Using OpenAI Embedding Service");
}

public RedisRetrieval(RedisEndpoint redisEndpoint, Doc2VecEndpoint doc2VecEndpoint, int dimension, RedisDistanceMetric metric) {
public RedisRetrieval(
RedisEndpoint redisEndpoint,
Doc2VecEndpoint doc2VecEndpoint,
int dimension,
RedisDistanceMetric metric) {
this.redisEndpoint = redisEndpoint;
this.doc2VecEndpoint = doc2VecEndpoint;
this.dimension = dimension;
Expand All @@ -57,17 +61,15 @@ public void upsert(String input) {
}
// For Doc2Vec ===>

if(Objects.nonNull(doc2VecEndpoint)){
if (Objects.nonNull(doc2VecEndpoint)) {
new EdgeChain<>(
this.doc2VecEndpoint
.getEmbeddings(input)
.map(embeddings -> this.redisEndpoint.upsert(embeddings, dimension, metric))
.firstOrError()
.blockingGet())
.await()
.blockingAwait();
.getEmbeddings(input)
.map(embeddings -> this.redisEndpoint.upsert(embeddings, dimension, metric))
.firstOrError()
.blockingGet())
.await()
.blockingAwait();
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public abstract class Retrieval {

public abstract void upsert(String input);
public abstract void upsert(String input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,26 @@ public String[] bySentence(LangType langType) {
SentenceModel model = null;
try {

if(langType.equals(LangType.EN))
model = new SentenceModel(Objects.requireNonNull(getClass().getResourceAsStream("/en-sent.zip")));

else if(langType.equals(LangType.FR))
model = new SentenceModel(Objects.requireNonNull(getClass().getResourceAsStream("/fr-sent.zip")));

else if(langType.equals(LangType.DE))
model = new SentenceModel(Objects.requireNonNull(getClass().getResourceAsStream("/de-sent.zip")));

else if(langType.equals(LangType.IT))
model = new SentenceModel(Objects.requireNonNull(getClass().getResourceAsStream("/it-sent.zip")));

if (langType.equals(LangType.EN))
model =
new SentenceModel(
Objects.requireNonNull(getClass().getResourceAsStream("/en-sent.zip")));
else if (langType.equals(LangType.FR))
model =
new SentenceModel(
Objects.requireNonNull(getClass().getResourceAsStream("/fr-sent.zip")));
else if (langType.equals(LangType.DE))
model =
new SentenceModel(
Objects.requireNonNull(getClass().getResourceAsStream("/de-sent.zip")));
else if (langType.equals(LangType.IT))
model =
new SentenceModel(
Objects.requireNonNull(getClass().getResourceAsStream("/it-sent.zip")));
else
model = new SentenceModel(Objects.requireNonNull(getClass().getResourceAsStream("/nl-sent.zip")));
model =
new SentenceModel(
Objects.requireNonNull(getClass().getResourceAsStream("/nl-sent.zip")));

} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.edgechain.lib.chunk.enums;

public enum LangType {
EN,
FR,
DE,
IT,
NL

EN,
FR,
DE,
IT,
NL
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages = {"com.edgechain.lib", "com.edgechain.lib.configuration"})
public class EdgeChainAutoConfiguration {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.edgechain.lib.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
Expand All @@ -18,13 +17,12 @@
@EnableRedisRepositories
public class RedisConfiguration {

@Autowired
@Lazy
private RedisEnv redisEnv;
@Autowired @Lazy private RedisEnv redisEnv;

@Bean
public JedisPooled jedisPooled() {
return new JedisPooled(redisEnv.getUrl(), redisEnv.getPort(), redisEnv.getUsername(), redisEnv.getPassword());
return new JedisPooled(
redisEnv.getUrl(), redisEnv.getPort(), redisEnv.getUsername(), redisEnv.getPassword());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
package com.edgechain.lib.configuration;


public class RedisEnv {

private String url;
private int port;
private String username;
private String password;
private long ttl;

public String getUrl() {
return url;
}
private String url;
private int port;
private String username;
private String password;
private long ttl;

public void setUrl(String url) {
this.url = url;
}
public String getUrl() {
return url;
}

public int getPort() {
return port;
}
public void setUrl(String url) {
this.url = url;
}

public void setPort(int port) {
this.port = port;
}
public int getPort() {
return port;
}

public String getUsername() {
return username;
}
public void setPort(int port) {
this.port = port;
}

public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
}

public String getPassword() {
return password;
}
public void setUsername(String username) {
this.username = username;
}

public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public long getTtl() {
return ttl;
}
public long getTtl() {
return ttl;
}

public void setTtl(long ttl) {
this.ttl = ttl;
}
public void setTtl(long ttl) {
this.ttl = ttl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
@Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration("WebConfiguration")
@Import(EdgeChainAutoConfiguration.class)
public class WebConfiguration {

}
public class WebConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

public class EndpointConstants {


public static final String OPENAI_CHAT_COMPLETION_API = "https://api.openai.com/v1/chat/completions";
public static final String OPENAI_EMBEDDINGS_API = "https://api.openai.com/v1/embeddings";


public static final String OPENAI_CHAT_COMPLETION_API =
"https://api.openai.com/v1/chat/completions";
public static final String OPENAI_EMBEDDINGS_API = "https://api.openai.com/v1/embeddings";
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.edgechain.lib.context.client;

import com.edgechain.lib.context.domain.HistoryContext;
import com.edgechain.lib.response.StringResponse;
import com.edgechain.lib.rxjava.transformer.observable.EdgeChain;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Observable;

public interface HistoryContextClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
import com.edgechain.lib.configuration.RedisEnv;
import com.edgechain.lib.context.domain.HistoryContext;
import com.edgechain.lib.context.client.HistoryContextClient;
import com.edgechain.lib.response.StringResponse;
import com.edgechain.lib.rxjava.transformer.observable.EdgeChain;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Observable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@Repository
Expand Down Expand Up @@ -101,7 +97,8 @@ public EdgeChain<HistoryContext> get(String key) {
} else {
emitter.onError(
new RuntimeException(
"Redis HistoryContextController key isn't found. You may have incorrectly defined"));
"Redis HistoryContextController key isn't found. You may have incorrectly"
+ " defined"));
}

} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,39 @@

public class ContextPutRequest {

private String id;
private String response;
private Endpoint endpoint;

public ContextPutRequest() {
}

public ContextPutRequest(String id, String response, Endpoint endpoint) {
this.id = id;
this.response = response;
this.endpoint = endpoint;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public Endpoint getEndpoint() {
return endpoint;
}

public void setEndpoint(Endpoint endpoint) {
this.endpoint = endpoint;
}
private String id;
private String response;
private Endpoint endpoint;

public ContextPutRequest() {}

public ContextPutRequest(String id, String response, Endpoint endpoint) {
this.id = id;
this.response = response;
this.endpoint = endpoint;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public Endpoint getEndpoint() {
return endpoint;
}

public void setEndpoint(Endpoint endpoint) {
this.endpoint = endpoint;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public class HistoryContext implements Serializable {
private String id;
private String response;

public HistoryContext() {
}
public HistoryContext() {}

public HistoryContext(String id, String response) {
this.id = id;
Expand Down
Loading

0 comments on commit 7bfdc23

Please sign in to comment.