diff --git a/.github/workflows/reporting.yaml b/.github/workflows/reporting.yaml
new file mode 100644
index 0000000..16550b9
--- /dev/null
+++ b/.github/workflows/reporting.yaml
@@ -0,0 +1,34 @@
+name: Publish Report
+
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - main
+
+jobs:
+ publish_report:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Set up JDK 21
+ uses: actions/setup-java@v2
+ with:
+ java-version: '21'
+ distribution: 'adopt'
+
+ - name: Build and generate report
+ run: |
+ mvn clean install
+ mvn site
+
+ - name: Publish report
+ uses: actions/upload-artifact@v2
+ with:
+ name: Report
+ path: target/site
diff --git a/README.md b/README.md
index c550ff2..1a6766f 100644
--- a/README.md
+++ b/README.md
@@ -107,6 +107,8 @@ We need to figure out a better way to handel this in the future (or put this on
Linting is does using checkstyle and a slightly modified version of the [Google Java Style guide](https://google.github.io/styleguide/javaguide.html).
+Run `mvn checkstyle:check -Dcheckstyle.config.location=checkstyle.xml`
+
### OWasp Security Scanning
The [OWASP Dependency-Check Plugin](https://owasp.org/www-project-dependency-check/) can be run using the following command:
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index c07d53e..cbdf916 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -1,7 +1,9 @@
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/checkstyle.xml b/checkstyle.xml
index 1374c49..d00b19a 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -14,12 +14,15 @@
To suppress certain violations please review suppression filters.
Authors: Max Vetrenko, Mauryan Kansara, Ruslan Diachenko, Roman Ivanov.
+
+ See: https://github.com/checkstyle/checkstyle/blob/checkstyle-10.20.1/src/main/resources/google_checks.xml
-->
+
-
+
@@ -309,6 +312,11 @@
+
getLlms() {
- return assistantService.getLLMConnections();
+ return assistantService.getLlmConnections();
}
/**
diff --git a/src/main/java/com/redhat/composer/api/EmbeddingApi.java b/src/main/java/com/redhat/composer/api/EmbeddingApi.java
index 6b6752e..cfe844c 100644
--- a/src/main/java/com/redhat/composer/api/EmbeddingApi.java
+++ b/src/main/java/com/redhat/composer/api/EmbeddingApi.java
@@ -32,6 +32,6 @@ public class EmbeddingApi {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String embeddString(String text, @PathParam("embeddingType") String embeddingType) {
- return embeddingService.embedding(text,embeddingType).toString();
+ return embeddingService.embedding(text, embeddingType).toString();
}
}
diff --git a/src/main/java/com/redhat/composer/api/VectorRetriverAPI.java b/src/main/java/com/redhat/composer/api/VectorRetriverApi.java
similarity index 93%
rename from src/main/java/com/redhat/composer/api/VectorRetriverAPI.java
rename to src/main/java/com/redhat/composer/api/VectorRetriverApi.java
index da87717..2a23191 100644
--- a/src/main/java/com/redhat/composer/api/VectorRetriverAPI.java
+++ b/src/main/java/com/redhat/composer/api/VectorRetriverApi.java
@@ -20,7 +20,7 @@
*/
@Path("/retriver")
@Authenticated
-public class VectorRetriverAPI {
+public class VectorRetriverApi {
@Inject
RetrieveService retrieveService;
@@ -39,7 +39,7 @@ public class VectorRetriverAPI {
public List retrieveSources(RetrieverRequest request,
@QueryParam("message") String message) {
return retrieveService.retrieveContent(request, message).stream()
- .map(VectorRetriverAPI::toSourceResponse).toList();
+ .map(VectorRetriverApi::toSourceResponse).toList();
}
/**
diff --git a/src/main/java/com/redhat/composer/api/validation/OIDCValidationAPI.java b/src/main/java/com/redhat/composer/api/validation/OidcValidationApi.java
similarity index 84%
rename from src/main/java/com/redhat/composer/api/validation/OIDCValidationAPI.java
rename to src/main/java/com/redhat/composer/api/validation/OidcValidationApi.java
index cdf2b91..7cdce56 100644
--- a/src/main/java/com/redhat/composer/api/validation/OIDCValidationAPI.java
+++ b/src/main/java/com/redhat/composer/api/validation/OidcValidationApi.java
@@ -1,6 +1,5 @@
package com.redhat.composer.api.validation;
-import java.util.Map;
import java.util.Set;
import io.quarkus.security.Authenticated;
@@ -9,9 +8,12 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
+/**
+ * OIDCValidationAPI.
+ */
@Path("/auth")
@Authenticated
-public class OIDCValidationAPI {
+public class OidcValidationApi {
@Inject
SecurityIdentity securityIdentity;
@@ -26,7 +28,7 @@ public String getPrincipal() {
@GET
@Path("roles")
- public Set getRoles() {
+ public Set getRoles() {
return securityIdentity.getRoles();
}
diff --git a/src/main/java/com/redhat/composer/api/validation/SteramingValidationAPI.java b/src/main/java/com/redhat/composer/api/validation/SteramingValidationAPI.java
deleted file mode 100644
index 343478c..0000000
--- a/src/main/java/com/redhat/composer/api/validation/SteramingValidationAPI.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.redhat.composer.api.validation;
-
-import java.util.Random;
-
-import org.jboss.resteasy.reactive.RestStreamElementType;
-
-import io.quarkus.security.Authenticated;
-import io.smallrye.mutiny.Multi;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-
-@Path("/streaming")
-@Authenticated
-public class SteramingValidationAPI {
-
-
- @Path("basic")
- public Multi streamBasic() {
- return Multi.createFrom().ticks().every(java.time.Duration.ofSeconds(1))
- .onItem().transform(n -> getRandomLetter());
- }
-
-
- @GET
- @Path("basic")
- public String getBasic() {
- return "Hello";
- }
-
- private String getRandomLetter() {
- Random r = new Random();
- return String.valueOf((char) (r.nextInt(26) + 'a'));
- }
-
-}
diff --git a/src/main/java/com/redhat/composer/config/llm/aiservices/BaseAiService.java b/src/main/java/com/redhat/composer/config/llm/aiservices/BaseAiService.java
index 9bc21e5..40e7f20 100644
--- a/src/main/java/com/redhat/composer/config/llm/aiservices/BaseAiService.java
+++ b/src/main/java/com/redhat/composer/config/llm/aiservices/BaseAiService.java
@@ -6,7 +6,7 @@
/**
* Base AI Service Interface.
*/
-public interface BaseAiService{
+public interface BaseAiService {
/**
* Returns TokenStream given input.
diff --git a/src/main/java/com/redhat/composer/config/llm/aiservices/HealthCareService.java b/src/main/java/com/redhat/composer/config/llm/aiservices/HealthCareService.java
index db77697..b15ea11 100644
--- a/src/main/java/com/redhat/composer/config/llm/aiservices/HealthCareService.java
+++ b/src/main/java/com/redhat/composer/config/llm/aiservices/HealthCareService.java
@@ -6,9 +6,8 @@
import io.smallrye.mutiny.Multi;
/**
- * Mistral7BAiService
+ * Mistral7BAiService.
*/
-
public interface HealthCareService extends BaseAiService {
static final String systemMessage = """
diff --git a/src/main/java/com/redhat/composer/config/llm/models/streaming/OpenAiStreamingModel.java b/src/main/java/com/redhat/composer/config/llm/models/streaming/OpenAiStreamingModel.java
index 019d598..b9eb6f8 100644
--- a/src/main/java/com/redhat/composer/config/llm/models/streaming/OpenAiStreamingModel.java
+++ b/src/main/java/com/redhat/composer/config/llm/models/streaming/OpenAiStreamingModel.java
@@ -19,7 +19,7 @@ public class OpenAiStreamingModel extends StreamingBaseModel {
Logger log = Logger.getLogger(WeaviateContentRetrieverClient.class);
- @ConfigProperty( name = "openai.default.url")
+ @ConfigProperty(name = "openai.default.url")
private String mistralDefaultUrl;
@ConfigProperty(name = "openai.default.apiKey")
@@ -31,28 +31,35 @@ public class OpenAiStreamingModel extends StreamingBaseModel {
@ConfigProperty(name = "openai.default.temp")
private double openaiDefaultTemp;
-
+ /**
+ * Get the Chat Model.
+ * @param request the LLMRequest
+ * @return the StreamingChatLanguageModel
+ */
public StreamingChatLanguageModel getChatModel(LLMRequest request) {
- log.info("Attempting to create OpenAI Streaming Chat Model at: " + request.getUrl() + " with model name: " + request.getModelName());
+
+ log.info("Attempting to create OpenAI Streaming Chat Model at: " + request.getUrl()
+ + " with model name: " + request.getModelName());
+
OpenAiStreamingChatModelBuilder builder = OpenAiStreamingChatModel.builder();
- builder.baseUrl(request.getUrl() == null ? mistralDefaultUrl : request.getUrl());
- builder.apiKey(request.getApiKey() == null ? mistralDefaultApiKey : request.getApiKey());
-
- builder.modelName(request.getModelName() == null ? mistralDefaultModelName : request.getModelName());
-
- // TODO: Add all the following to the request
- builder.temperature(openaiDefaultTemp);
-
- // TODO: Fill all this out
- // if (modelName != null) {
- // builder.modelName(modelName);
- // }
- // if (maxTokens != null) {
- // builder.maxTokens(maxTokens);
- // }
- // if (safePrompt != null) {
- // builder.safePrompt(safePrompt);
- // }
+ builder.baseUrl(request.getUrl() == null ? mistralDefaultUrl : request.getUrl());
+ builder.apiKey(request.getApiKey() == null ? mistralDefaultApiKey : request.getApiKey());
+
+ builder.modelName(request.getModelName() == null ? mistralDefaultModelName : request.getModelName());
+
+ // TODO: Add all the following to the request
+ builder.temperature(openaiDefaultTemp);
+
+ // TODO: Fill all this out
+ // if (modelName != null) {
+ // builder.modelName(modelName);
+ // }
+ // if (maxTokens != null) {
+ // builder.maxTokens(maxTokens);
+ // }
+ // if (safePrompt != null) {
+ // builder.safePrompt(safePrompt);
+ // }
return builder.build();
}
diff --git a/src/main/java/com/redhat/composer/config/llm/models/synchronous/OpenAiModel.java b/src/main/java/com/redhat/composer/config/llm/models/synchronous/OpenAiModel.java
index 0e792e2..8444d5b 100644
--- a/src/main/java/com/redhat/composer/config/llm/models/synchronous/OpenAiModel.java
+++ b/src/main/java/com/redhat/composer/config/llm/models/synchronous/OpenAiModel.java
@@ -15,7 +15,7 @@
@ApplicationScoped
public class OpenAiModel extends SynchronousBaseModel {
- @ConfigProperty( name = "openai.default.url")
+ @ConfigProperty(name = "openai.default.url")
private String mistralDefaultUrl;
@ConfigProperty(name = "openai.default.apiKey")
@@ -28,6 +28,11 @@ public class OpenAiModel extends SynchronousBaseModel {
private double openaiDefaultTemp;
+ /**
+ * Get the Chat Model.
+ * @param request the LLMRequest
+ * @return the ChatLanguageModel
+ */
public ChatLanguageModel getChatModel(LLMRequest request) {
OpenAiChatModelBuilder builder = OpenAiChatModel.builder();
builder.baseUrl(request.getUrl() == null ? mistralDefaultUrl : request.getUrl());
@@ -38,16 +43,16 @@ public ChatLanguageModel getChatModel(LLMRequest request) {
// TODO: Add all the following to the request
builder.temperature(openaiDefaultTemp);
- // Model names can be derived from MistralAiChatModelName enum
- // if (modelName != null) {
- // builder.modelName(modelName);
- // }
- // if (maxTokens != null) {
- // builder.maxTokens(maxTokens);
- // }
- // if (safePrompt != null) {
- // builder.safePrompt(safePrompt);
- // }
+ // Model names can be derived from MistralAiChatModelName enum
+ // if (modelName != null) {
+ // builder.modelName(modelName);
+ // }
+ // if (maxTokens != null) {
+ // builder.maxTokens(maxTokens);
+ // }
+ // if (safePrompt != null) {
+ // builder.safePrompt(safePrompt);
+ // }
return builder.build();
}
diff --git a/src/main/java/com/redhat/composer/config/retriever/contentretriever/BaseContentRetrieverClient.java b/src/main/java/com/redhat/composer/config/retriever/contentretriever/BaseContentRetrieverClient.java
index 8204c5f..815b181 100644
--- a/src/main/java/com/redhat/composer/config/retriever/contentretriever/BaseContentRetrieverClient.java
+++ b/src/main/java/com/redhat/composer/config/retriever/contentretriever/BaseContentRetrieverClient.java
@@ -20,7 +20,7 @@ public class BaseContentRetrieverClient {
* @param request the RetrieverRequest
* @return ContentRetriever
*/
- public ContentRetriever getContentRetriever(RetrieverRequest request){
+ public ContentRetriever getContentRetriever(RetrieverRequest request) {
throw new UnsupportedOperationException("Unimplemented method 'getContentRetriever'");
}
@@ -29,7 +29,7 @@ public ContentRetriever getContentRetriever(RetrieverRequest request){
* @param embeddingType the String
* @return EmbeddingModel
*/
- protected EmbeddingModel getEmbeddingModel(String embeddingType){
+ protected EmbeddingModel getEmbeddingModel(String embeddingType) {
return embeddingModelFactory.getEmbeddingModel(embeddingType);
}
diff --git a/src/main/java/com/redhat/composer/services/AssistantInfoService.java b/src/main/java/com/redhat/composer/services/AssistantInfoService.java
index d9ac1ea..b4b08fa 100644
--- a/src/main/java/com/redhat/composer/services/AssistantInfoService.java
+++ b/src/main/java/com/redhat/composer/services/AssistantInfoService.java
@@ -91,7 +91,7 @@ public List getRetrieverConnections() {
* @param request the LLMRequest
* @return the LLMConnectionEntity
*/
- public LlmConnectionEntity createLLMConnection(LLMRequest request) {
+ public LlmConnectionEntity createLlmConnection(LLMRequest request) {
LlmConnectionEntity entity = new LlmConnectionEntity();
entity.setName(request.getName());
entity.setDescription(request.getDescription());
@@ -102,7 +102,11 @@ public LlmConnectionEntity createLLMConnection(LLMRequest request) {
return entity;
}
- public List getLLMConnections() {
+ /**
+ * Get all LLMConnections.
+ * @return a list of LlmConnectionEntity
+ */
+ public List getLlmConnections() {
return LlmConnectionEntity.listAll();
}
diff --git a/src/main/java/com/redhat/composer/services/EmbeddingService.java b/src/main/java/com/redhat/composer/services/EmbeddingService.java
index e4b4186..b81fd68 100644
--- a/src/main/java/com/redhat/composer/services/EmbeddingService.java
+++ b/src/main/java/com/redhat/composer/services/EmbeddingService.java
@@ -31,4 +31,4 @@ public Embedding embedding(String text, String embeddingType) {
return response.content();
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/redhat/composer/services/RetrieveService.java b/src/main/java/com/redhat/composer/services/RetrieveService.java
index 5d63ce6..5a1482a 100644
--- a/src/main/java/com/redhat/composer/services/RetrieveService.java
+++ b/src/main/java/com/redhat/composer/services/RetrieveService.java
@@ -13,19 +13,35 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
+/**
+ * Service for retrieving content.
+ */
@ApplicationScoped
public class RetrieveService {
@Inject
ContentRetrieverClientFactory contentRetrieverClientFactory;
+ /**
+ * Retrieves content from a given message.
+ * @param request the request to retrieve content
+ * @return the retrieved content
+ */
public ContentRetriever getContentRetriever(RetrieverRequest request) {
- ContentRetrieverType contentRetrieverType = ContentRetrieverType.fromString(request.getBaseRetrieverRequest().getContentRetrieverType());
- BaseContentRetrieverClient client = contentRetrieverClientFactory.getContentRetrieverClient(contentRetrieverType); //TODO: Fix this
+ ContentRetrieverType contentRetrieverType = ContentRetrieverType.fromString(
+ request.getBaseRetrieverRequest().getContentRetrieverType());
+ BaseContentRetrieverClient client = contentRetrieverClientFactory
+ .getContentRetrieverClient(contentRetrieverType);
return client.getContentRetriever(request);
}
+ /**
+ * Retrieves content from a given message.
+ * @param request the request to retrieve content
+ * @param message the message to retrieve content from
+ * @return the retrieved content
+ */
public List retrieveContent(RetrieverRequest request, String message) {
ContentRetriever contentRetriever = getContentRetriever(request);
Query query = Query.from(message);
diff --git a/src/main/java/com/redhat/composer/util/mappers/MapperUtil.java b/src/main/java/com/redhat/composer/util/mappers/MapperUtil.java
index c8c7535..85c08cf 100644
--- a/src/main/java/com/redhat/composer/util/mappers/MapperUtil.java
+++ b/src/main/java/com/redhat/composer/util/mappers/MapperUtil.java
@@ -2,6 +2,7 @@
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import com.redhat.composer.model.enums.ContentRetrieverType;
@@ -30,9 +31,20 @@ public interface MapperUtil {
/**
* Maps a RetrieverRequest to a RetrieverConnectionEntity.
*/
- @Mapping(target = "connectionEntity", source = "baseRetrieverRequest")
+ @Mappings({
+ @Mapping(target = "connectionEntity", source = "baseRetrieverRequest"),
+ @Mapping(target = "id", ignore = true)
+ })
RetrieverConnectionEntity toEntity(RetrieverRequest request);
+ /**
+ * Maps a LLMRequest to a LLMConnectionEntity.
+ * @param request the LLMRequest to map
+ * @return the LLMConnectionEntity
+ */
+ @Mapping(target = "id", ignore = true)
+ LlmConnectionEntity toEntity(LLMRequest request);
+
/**
* Maps a RetrieverConnectionEntity to a RetrieverRequest.
@@ -41,14 +53,7 @@ public interface MapperUtil {
*/
@Mapping(source = "connectionEntity", target = "baseRetrieverRequest")
RetrieverRequest toRequest(RetrieverConnectionEntity entity);
-
- /**
- * Maps a LLMRequest to a LLMConnectionEntity.
- * @param request the LLMRequest to map
- * @return the LLMConnectionEntity
- */
- @Mapping(target = "id", ignore = true)
- LlmConnectionEntity toEntity(LLMRequest request);
+
/**
* Maps a LLMConnectionEntity to a LLMRequest.
* @param entity the LLMConnectionEntity to map
@@ -83,7 +88,7 @@ default BaseRetrieverConnectionEntity mapToBaseEntity(BaseRetrieverRequest reque
* @param entity the BaseRetrieverConnectionEntity to map
* @return the BaseRetrieverRequest
*/
- default BaseRetrieverRequest mapToBaseRequest(BaseRetrieverConnectionEntity entity){
+ default BaseRetrieverRequest mapToBaseRequest(BaseRetrieverConnectionEntity entity) {
if (entity == null || entity.getContentRetrieverType() == null) {
return null;
@@ -99,5 +104,5 @@ default BaseRetrieverRequest mapToBaseRequest(BaseRetrieverConnectionEntity enti
}
}
-
+
}
diff --git a/src/main/java/com/redhat/composer/util/mappers/QuarkusMapperConfig.java b/src/main/java/com/redhat/composer/util/mappers/QuarkusMapperConfig.java
index 6658893..91a110e 100644
--- a/src/main/java/com/redhat/composer/util/mappers/QuarkusMapperConfig.java
+++ b/src/main/java/com/redhat/composer/util/mappers/QuarkusMapperConfig.java
@@ -3,8 +3,8 @@
import org.mapstruct.MapperConfig;
/**
- * QuarkusMapperConfig interface.
+ * Quarkus Mapper Config.
*/
@MapperConfig(componentModel = "cdi")
public interface QuarkusMapperConfig {
-}
\ No newline at end of file
+}