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 Aug 4, 2023
1 parent 53895b0 commit 701a5c3
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class PineconeRetrieval extends Retrieval {

private final Logger logger = LoggerFactory.getLogger(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class RedisRetrieval extends Retrieval {

private final Logger logger = LoggerFactory.getLogger(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
Expand All @@ -11,7 +10,6 @@
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import redis.clients.jedis.JedisPooled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Repository
public class PostgresClientRepository {
Expand Down Expand Up @@ -65,8 +64,8 @@ public List<Map<String, Object>> query(

return jdbcTemplate.queryForList(
String.format(
"SELECT id, raw_text, namespace, filename, timestamp FROM %s WHERE namespace='%s' ORDER BY"
+ " embedding %s '%s' LIMIT %s;",
"SELECT id, raw_text, namespace, filename, timestamp FROM %s WHERE namespace='%s' ORDER"
+ " BY embedding %s '%s' LIMIT %s;",
tableName,
namespace,
PostgresDistanceMetric.getDistanceMetric(metric),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class JwtFilter extends OncePerRequestFilter {

@Autowired private SecurityUUID securityUUID;


@Override
protected void doFilterInternal(
HttpServletRequest request, HttpServletResponse response, FilterChain filter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public Jws<Claims> parseToken(String accessToken) {
new SecretKeySpec(
env.getProperty("jwt.secret").getBytes(), SignatureAlgorithm.HS256.getJcaName());


return Jwts.parser().setSigningKey(hmacKey).parseClaimsJws(accessToken);

} catch (MalformedJwtException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ public class AuthUtils {

public static String extractToken(HttpServletRequest request) {
String header = request.getHeader("Authorization");
if (header != null && header.startsWith("Bearer"))
return header.replace("Bearer ", "");
if (header != null && header.startsWith("Bearer")) return header.replace("Bearer ", "");

return null;
}


public static String extractToken(ArkRequest request) {
String header = request.getHeader("Authorization");
if (header != null && header.startsWith("Bearer")) return header.replace("Bearer ", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
@RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/index/pinecone")
public class PineconeController {

@Autowired
private PineconeClient pineconeClient;
@Autowired private PineconeClient pineconeClient;

@PostMapping("/upsert")
public Single<StringResponse> upsert(@RequestBody PineconeEndpoint pineconeEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
@RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/index/postgres")
public class PostgresController {

@Autowired
@Lazy
private PostgresClient postgresClient;
@Autowired @Lazy private PostgresClient postgresClient;

@PostMapping("/upsert")
public Single<StringResponse> upsert(@RequestBody PostgresEndpoint postgresEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,40 @@
@RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/index/redis")
public class RedisController {

@Autowired
@Lazy
private RedisClient redisClient;
@Autowired @Lazy private RedisClient redisClient;

@PostMapping("/upsert")
public Single<StringResponse> upsert(@RequestBody RedisEndpoint redisEndpoint) {
@PostMapping("/upsert")
public Single<StringResponse> upsert(@RequestBody RedisEndpoint redisEndpoint) {

this.redisClient.setEndpoint(redisEndpoint);
this.redisClient.setEndpoint(redisEndpoint);

EdgeChain<StringResponse> edgeChain =
this.redisClient.upsert(
redisEndpoint.getWordEmbeddings(),
redisEndpoint.getDimensions(),
redisEndpoint.getMetric());
EdgeChain<StringResponse> edgeChain =
this.redisClient.upsert(
redisEndpoint.getWordEmbeddings(),
redisEndpoint.getDimensions(),
redisEndpoint.getMetric());

return edgeChain.toSingle();
}
return edgeChain.toSingle();
}

@PostMapping("/query")
public Single<List<WordEmbeddings>> query(@RequestBody RedisEndpoint redisEndpoint) {
@PostMapping("/query")
public Single<List<WordEmbeddings>> query(@RequestBody RedisEndpoint redisEndpoint) {

this.redisClient.setEndpoint(redisEndpoint);
this.redisClient.setEndpoint(redisEndpoint);

EdgeChain<List<WordEmbeddings>> edgeChain =
this.redisClient.query(redisEndpoint.getWordEmbeddings(), redisEndpoint.getTopK());
EdgeChain<List<WordEmbeddings>> edgeChain =
this.redisClient.query(redisEndpoint.getWordEmbeddings(), redisEndpoint.getTopK());

return edgeChain.toSingle();
}
return edgeChain.toSingle();
}

@DeleteMapping("/delete")
public Completable deleteByPattern(
@RequestParam("pattern") String pattern, @RequestBody RedisEndpoint redisEndpoint) {
@DeleteMapping("/delete")
public Completable deleteByPattern(
@RequestParam("pattern") String pattern, @RequestBody RedisEndpoint redisEndpoint) {

this.redisClient.setEndpoint(redisEndpoint);
this.redisClient.setEndpoint(redisEndpoint);

EdgeChain<StringResponse> edgeChain = this.redisClient.deleteByPattern(pattern);
return edgeChain.await();
}
EdgeChain<StringResponse> edgeChain = this.redisClient.deleteByPattern(pattern);
return edgeChain.await();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Single<ChatCompletionResponse> chatCompletion(@RequestBody OpenAiEndpoint
EdgeChain<ChatCompletionResponse> edgeChain =
openAiClient.createChatCompletion(chatCompletionRequest);

if (Objects.nonNull(env.getProperty("postgres.db.host"))) {
if (Objects.nonNull(env.getProperty("postgres.db.host"))) {

ChatCompletionLog chatCompletionLog = new ChatCompletionLog();
chatCompletionLog.setName(openAiEndpoint.getChainName());
Expand Down Expand Up @@ -119,7 +119,7 @@ public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoin

AtomInteger chunks = AtomInteger.of(0);

if (Objects.nonNull(env.getProperty("postgres.db.host"))) {
if (Objects.nonNull(env.getProperty("postgres.db.host"))) {

ChatCompletionLog chatCompletionLog = new ChatCompletionLog();
chatCompletionLog.setName(openAiEndpoint.getChainName());
Expand Down Expand Up @@ -224,7 +224,7 @@ public Single<OpenAiEmbeddingResponse> embeddings(@RequestBody OpenAiEndpoint op
openAiClient.createEmbeddings(
new OpenAiEmbeddingRequest(openAiEndpoint.getModel(), openAiEndpoint.getInput()));

if (Objects.nonNull(env.getProperty("postgres.db.host"))) {
if (Objects.nonNull(env.getProperty("postgres.db.host"))) {

EmbeddingLog embeddingLog = new EmbeddingLog();
embeddingLog.setCreatedAt(LocalDateTime.now());
Expand Down

0 comments on commit 701a5c3

Please sign in to comment.