Skip to content

Commit

Permalink
Ui & classname refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Dec 19, 2024
1 parent a5630b5 commit 47edb3d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.open4goods.commons.services.IcecatService;
import org.open4goods.commons.services.SerialisationService;
import org.open4goods.commons.services.VerticalsConfigService;
import org.open4goods.commons.services.ai.GenAiResponse;
import org.open4goods.commons.services.ai.PromptResponse;
import org.open4goods.commons.services.ai.GenAiService;
import org.open4goods.commons.services.ai.LegacyAiService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -630,7 +630,7 @@ public String generateEcoscoreYamlConfig (VerticalConfig vConf) {
context.put("VERTICAL_NAME", vConf.getI18n().get("fr").getVerticalHomeTitle());

// Prompt
GenAiResponse<Map<String, Object>> response = genAiService.jsonPrompt("impactscore-generation", context);
PromptResponse<Map<String, Object>> response = genAiService.jsonPrompt("impactscore-generation", context);

// TODO(p2, safety) : To strictYaml
String rawRet = serialisationService.toYaml(response.getBody());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public GenAiService(GenAiConfig genAiConfig, OpenAiApi perplexityApi, OpenAiApi
* @throws JsonMappingException
* @throws JsonParseException
*/
public GenAiResponse<CallResponseSpec> prompt(String promptKey, Map<String, Object> variables) throws ResourceNotFoundException, JsonParseException, JsonMappingException, IOException {
public PromptResponse<CallResponseSpec> prompt(String promptKey, Map<String, Object> variables) throws ResourceNotFoundException, JsonParseException, JsonMappingException, IOException {

// TODO : Enable only if genaiconfig.enabled
PromptConfig pConf = getPromptConfig(promptKey);
GenAiResponse<CallResponseSpec> ret = new GenAiResponse<ChatClient.CallResponseSpec>();
PromptResponse<CallResponseSpec> ret = new PromptResponse<ChatClient.CallResponseSpec>();

if (null == pConf) {
logger.error("PromptConfig {} does not exists", promptKey);
Expand Down Expand Up @@ -133,11 +133,11 @@ public GenAiResponse<CallResponseSpec> prompt(String promptKey, Map<String, Obje
* @throws JsonMappingException
* @throws JsonParseException
*/
public GenAiResponse<Map<String, Object>> jsonPrompt(String promptKey, Map<String, Object> variables) throws ResourceNotFoundException, JsonParseException, JsonMappingException, IOException {
public PromptResponse<Map<String, Object>> jsonPrompt(String promptKey, Map<String, Object> variables) throws ResourceNotFoundException, JsonParseException, JsonMappingException, IOException {

GenAiResponse<Map<String, Object>> ret = new GenAiResponse<Map<String, Object>>();
PromptResponse<Map<String, Object>> ret = new PromptResponse<Map<String, Object>>();

GenAiResponse<CallResponseSpec> internal = prompt(promptKey, variables);
PromptResponse<CallResponseSpec> internal = prompt(promptKey, variables);
// Copy
ret.setDuration(internal.getDuration());
ret.setStart(internal.getStart());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.open4goods.commons.config.yml.PromptConfig;

public class GenAiResponse<T> {
public class PromptResponse<T> {

/**
* The body of the response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.open4goods.commons.services.SearchService;
import org.open4goods.commons.services.SerialisationService;
import org.open4goods.commons.services.VerticalsConfigService;
import org.open4goods.commons.services.ai.GenAiResponse;
import org.open4goods.commons.services.ai.PromptResponse;
import org.open4goods.commons.services.ai.GenAiService;
import org.open4goods.ui.controllers.ui.UiService;
import org.open4goods.ui.services.BlogService;
Expand Down
152 changes: 24 additions & 128 deletions ui/src/main/resources/templates/themes/v2/ecoscore-vertical.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,138 +315,44 @@ <h2 class="text-center h4 mb-2">En discuter</h2>



<div class="p-6">
<div class="card">
<div class="card-header">Audit de génération IA de l'impact score</div>
<div class="card-body">



<h3>Système d'IA utilisé</h3>

<p>Informations sur le service et le modèle d'IA utilisé pour générer cet ImpactScore</p>
<ul class="ps-3">
<li class="small">Service IA : <span th:text="${prompt.aiService}"></span></li>
<li class="small">Modèle : <span th:text="${prompt.options.model}"></span></li>
</ul>



<h3>User Prompt</h3>
<p>Ceci est l'instruction envoyée au modèle d'IA. A noter que nous utilisons un des modèles les plus performants (o1-preview), qui ne prend pas en compte le prompt système, ni la
température.</p>


<pre class="bg-gray-200 mb-4">
<code th:utext="${prompt.userPrompt}"></code>
</pre>

<h3>Réponse</h3>
<p>Ceci est la réponse du sysème d'IA, au format JSON</p>
<pre class="bg-gray-200">
<code class="json" th:utext="${impactscore.aiJsonResponse}"></code>
</pre>

</div>


</div>
</div>









<div class="p-6">
<div class="card">
<div class="card-header">Pistes d'audit</div>
<div class="card-body">







<!-- Tab Nav -->
<div class="nav-wrapper position-relative mb-2">
<ul class="nav nav-pills nav-fill flex-column flex-md-row"
id="tabs-icons-text" role="tablist">
<li class="nav-item"><a
class="nav-link mb-sm-3 mb-md-0 active"
id="tabs-icons-text-1-tab" data-bs-toggle="tab"
href="#tabs-icons-text-1" role="tab"
aria-controls="tabs-icons-text-1" aria-selected="true"><span
class="fas fa-palette me-2"></span>Audit de génération de l'impact score</a></li>
<li class="nav-item"><a class="nav-link mb-sm-3 mb-md-0"
id="tabs-icons-text-2-tab" data-bs-toggle="tab"
href="#tabs-icons-text-2" role="tab"
aria-controls="tabs-icons-text-2" aria-selected="false"><span
class="fas fa-laptop-code me-2"></span>Prompt IA utilisé</a></li>
<li class="nav-item"><a class="nav-link mb-sm-3 mb-md-0"
id="tabs-icons-text-3-tab" data-bs-toggle="tab"
href="#tabs-icons-text-3" role="tab"
aria-controls="tabs-icons-text-3" aria-selected="false"><span
class="far fa-user me-2"></span>Réponse IA </a></li>
</ul>
</div>
<!-- End of Tab Nav -->
<!-- Tab Content -->
<div class="card border-0">
<div class="card-body p-0">
<div class="tab-content" id="tabcontent2">
<div class="tab-pane fade show active" id="tabs-icons-text-1"
role="tabpanel" aria-labelledby="tabs-icons-text-1-tab">
<p>Exercitation photo booth stumptown tote bag Banksy, elit
small batch freegan sed. Craft beer elit seitan exercitation,
photo booth et 8-bit kale chips proident chillwave deep v
laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do
umami readymade swag.</p>
<p>Day handsome addition horrible sensible goodness two
contempt. Evening for married his account removal. Estimable me
disposing of be moonlight cordially curiosity.</p>
</div>
<div class="tab-pane fade" id="tabs-icons-text-2" role="tabpanel" aria-labelledby="tabs-icons-text-2-tab">



<div class="card shadow p-4 mb-5">
<div class="row align-items-center">
<div class="col-4">
<a href="#"><img src="../../assets/img/shop/item-2.png" alt="big speakers"></a>
</div>
<div class="d-flex mb-2 fw-bold">
<a class="h5" href="#">Prompt IA</a>
</div>
<div class="col-4">
<ul class="ps-3">
<li class="small">Service IA : <span
th:text="${prompt.aiService}"></span></li>
<li class="small">Modèle : <span
th:text="${prompt.options.model}"></span></li>
<li class="small">Température : <span
th:text="${prompt.options.temperature}"></span></li>
</ul>
</div>
</div>
</div>



<pre>
<code class="json" th:utext="${impactscore.aiJsonResponse}"></code>
</pre>
</div>
<div class="tab-pane fade" id="tabs-icons-text-3" role="tabpanel"
aria-labelledby="tabs-icons-text-3-tab">
<pre>
<code class="yaml" th:utext="${impactscore.yamlPrompt}"></code>
</pre>
</div>
</div>
</div>
</div>
<!-- End of Tab Content -->


</div>











</div>
</div>




</section>


Expand All @@ -470,13 +376,7 @@ <h2 class="text-center h4 mb-2">En discuter</h2>
<script src="/vendor/jarallax/dist/jarallax.min.js"></script>
<script src="/vendor/smooth-scroll/dist/smooth-scroll.polyfills.min.js"></script>
<script src="/vendor/vivus/dist/vivus.min.js"></script>
<script src="/vendor/chartist/dist/chartist.min.js"></script>
<script src="/vendor/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.min.js"></script>
<script src="/vendor/@glidejs/glide/dist/glide.min.js"></script>
<script src="/vendor/countup.js/dist/countUp.umd.js"></script>
<script src="/vendor/vanillajs-datepicker/dist/js/datepicker.min.js"></script>

<script async defer src="https://buttons.github.io/buttons.js"></script>

<script src="/webjars/jquery/jquery.min.js"></script>

Expand All @@ -485,10 +385,6 @@ <h2 class="text-center h4 mb-2">En discuter</h2>
<!-- custom sources -->
<script src="../../assets/js/pixel-custom.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>


</body>

</html>
2 changes: 1 addition & 1 deletion verticals/src/main/resources/verticals/_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ attributesConfig:


- key: "DATA_QUALITY"
faIcon: "fa-data"
faIcon: "fa-file-shield"
# attributePath: attributes.features
name:
default: "Data quality"
Expand Down

0 comments on commit 47edb3d

Please sign in to comment.