Skip to content

Commit

Permalink
feat : adds swagger-ui for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Mar 27, 2024
1 parent ad74cba commit 558b55f
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
"projectName": "pgvector-springai",
"args": "--spring.profiles.active=local",
"envFile": "${workspaceFolder}/.env"
},
{
"type": "java",
"name": "Spring Boot-PgVectorEmbeddingStoreExample<pgvector-langchain4j>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.learning.ai.PgVectorEmbeddingStoreExample",
"projectName": "pgvector-langchain4j",
"args": "--spring.profiles.active=local",
"envFile": "${workspaceFolder}/.env"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.learning.ai.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@OpenAPIDefinition(info = @Info(title = "llm-rag-with-langchain4j", version = "v1.0.0"), servers = @Server(url = "/"))
public class SwaggerConfig {}
6 changes: 6 additions & 0 deletions pgvector-langchain4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<version>${langchain4j.version}</version>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.4.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.learning.ai.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@OpenAPIDefinition(
info = @Info(title = "pgvector-langchain4j", version = "v1.0.0"),
servers = @Server(url = "/"))
public class SwaggerConfig {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ spring.application.name=pgvector-langchain4j

spring.datasource.password=secret
spring.datasource.username=appuser
spring.datasource.url=jdbc:postgresql://localhost/appdb
spring.datasource.url=jdbc:postgresql://localhost:5432/appdb
6 changes: 6 additions & 0 deletions pgvector-springai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.4.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@Component
public class Initializer implements CommandLineRunner {

final PgVectorStoreService pgVectorStoreService;
private final PgVectorStoreService pgVectorStoreService;

public Initializer(PgVectorStoreService pgVectorStoreService) {
this.pgVectorStoreService = pgVectorStoreService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RestClient.Builder restClientBuilder() {
});
}

private class CustomClientHttpResponse implements ClientHttpResponse {
private static class CustomClientHttpResponse implements ClientHttpResponse {

private final ClientHttpResponse originalResponse;
private final HttpHeaders headers;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.learning.ai.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@OpenAPIDefinition(
info = @Info(title = "pgvector-springai", version = "v1.0.0"),
servers = @Server(url = "/"))
public class SwaggerConfig {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Service
public class PgVectorStoreService {

private final Logger log = LoggerFactory.getLogger(PgVectorStoreService.class);
private static final Logger LOGGER = LoggerFactory.getLogger(PgVectorStoreService.class);

private final VectorStore vectorStore;

Expand All @@ -35,7 +35,7 @@ public AIChatResponse queryEmbeddingStore(String question) {
String relevantData =
similarDocuments.stream().map(Document::getContent).collect(Collectors.joining(System.lineSeparator()));

log.info("response from vectorStore :{} ", relevantData);
LOGGER.info("response from vectorStore : {} ", relevantData);
return new AIChatResponse(relevantData);
}
}

0 comments on commit 558b55f

Please sign in to comment.