Skip to content

Commit

Permalink
Merge pull request #204 from jmartisk/dev-ui-images
Browse files Browse the repository at this point in the history
Image model Dev UI page + docs
  • Loading branch information
geoand authored Jan 5, 2024
2 parents 4a56204 + 2b489de commit 59cf4cf
Show file tree
Hide file tree
Showing 7 changed files with 420 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
** xref:in-process-embedding.adoc[In-Process Embeddings]
** xref:csv.adoc[Loading CSV files]
* Additional tools
** xref:dev-ui.adoc[Dev UI]
* Advanced topics
** xref:fault-tolerance.adoc[Fault Tolerance]
19 changes: 19 additions & 0 deletions docs/modules/ROOT/pages/dev-ui.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
= Dev UI

include::./includes/attributes.adoc[]

If you use the Dev mode, the `quarkus-langchain4j` project provides several pages
in the Dev UI to facilitate development:

* *AI Services* page: provides a table of all AI Services detected in the application along
with a list of tools that they are declared to use.
* *Tools* page: provides a list of tools detected in the application.
* *Chat* page: allows you to manually hold a conversation with a chat model. This
page is only available if the application contains a chat model.
* *Images* page: allows you to test the outputs of image models and tune its parameters.
This page is provided specifically by the `openai-vanilla` extension and is currently specific
to OpenAI's image models. It appears if the application uses the `openai-vanilla` extension
and doesn't have image models explicitly disabled.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,40 @@ endif::add-copy-button-to-env-var[]
|


a| [[quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.chat-model.log-requests]]`link:#quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.chat-model.log-requests[quarkus.langchain4j.huggingface.chat-model.log-requests]`


[.description]
--
Whether chat model requests should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_HUGGINGFACE_CHAT_MODEL_LOG_REQUESTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_HUGGINGFACE_CHAT_MODEL_LOG_REQUESTS+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.chat-model.log-responses]]`link:#quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.chat-model.log-responses[quarkus.langchain4j.huggingface.chat-model.log-responses]`


[.description]
--
Whether chat model responses should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_HUGGINGFACE_CHAT_MODEL_LOG_RESPONSES+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_HUGGINGFACE_CHAT_MODEL_LOG_RESPONSES+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.embedding-model.inference-endpoint-url]]`link:#quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.embedding-model.inference-endpoint-url[quarkus.langchain4j.huggingface.embedding-model.inference-endpoint-url]`


Expand Down Expand Up @@ -298,7 +332,7 @@ a| [[quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.log-request

[.description]
--
Whether the OpenAI client should log requests
Whether the HuggingFace client should log requests

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_HUGGINGFACE_LOG_REQUESTS+++[]
Expand All @@ -315,7 +349,7 @@ a| [[quarkus-langchain4j-huggingface_quarkus.langchain4j.huggingface.log-respons

[.description]
--
Whether the OpenAI client should log responses
Whether the HuggingFace client should log responses

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_HUGGINGFACE_LOG_RESPONSES+++[]
Expand Down
136 changes: 136 additions & 0 deletions docs/modules/ROOT/pages/includes/quarkus-langchain4j-openai.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,40 @@ endif::add-copy-button-to-env-var[]
|`0`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.chat-model.log-requests]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.chat-model.log-requests[quarkus.langchain4j.openai.chat-model.log-requests]`


[.description]
--
Whether chat model requests should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_CHAT_MODEL_LOG_REQUESTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_CHAT_MODEL_LOG_REQUESTS+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.chat-model.log-responses]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.chat-model.log-responses[quarkus.langchain4j.openai.chat-model.log-responses]`


[.description]
--
Whether chat model responses should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_CHAT_MODEL_LOG_RESPONSES+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_CHAT_MODEL_LOG_RESPONSES+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.embedding-model.model-name]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.embedding-model.model-name[quarkus.langchain4j.openai.embedding-model.model-name]`


Expand All @@ -317,6 +351,40 @@ endif::add-copy-button-to-env-var[]
|`text-embedding-ada-002`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.embedding-model.log-requests]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.embedding-model.log-requests[quarkus.langchain4j.openai.embedding-model.log-requests]`


[.description]
--
Whether embedding model requests should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_EMBEDDING_MODEL_LOG_REQUESTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_EMBEDDING_MODEL_LOG_REQUESTS+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.embedding-model.log-responses]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.embedding-model.log-responses[quarkus.langchain4j.openai.embedding-model.log-responses]`


[.description]
--
Whether embedding model responses should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_EMBEDDING_MODEL_LOG_RESPONSES+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_EMBEDDING_MODEL_LOG_RESPONSES+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.moderation-model.model-name]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.moderation-model.model-name[quarkus.langchain4j.openai.moderation-model.model-name]`


Expand All @@ -334,6 +402,40 @@ endif::add-copy-button-to-env-var[]
|`text-moderation-latest`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.moderation-model.log-requests]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.moderation-model.log-requests[quarkus.langchain4j.openai.moderation-model.log-requests]`


[.description]
--
Whether moderation model requests should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_MODERATION_MODEL_LOG_REQUESTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_MODERATION_MODEL_LOG_REQUESTS+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.moderation-model.log-responses]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.moderation-model.log-responses[quarkus.langchain4j.openai.moderation-model.log-responses]`


[.description]
--
Whether moderation model responses should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_MODERATION_MODEL_LOG_RESPONSES+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_MODERATION_MODEL_LOG_RESPONSES+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.image-model.model-name]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.image-model.model-name[quarkus.langchain4j.openai.image-model.model-name]`


Expand Down Expand Up @@ -504,6 +606,40 @@ endif::add-copy-button-to-env-var[]
--|string
|


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.image-model.log-requests]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.image-model.log-requests[quarkus.langchain4j.openai.image-model.log-requests]`


[.description]
--
Whether image model requests should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_IMAGE_MODEL_LOG_REQUESTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_IMAGE_MODEL_LOG_REQUESTS+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a| [[quarkus-langchain4j-openai_quarkus.langchain4j.openai.image-model.log-responses]]`link:#quarkus-langchain4j-openai_quarkus.langchain4j.openai.image-model.log-responses[quarkus.langchain4j.openai.image-model.log-responses]`


[.description]
--
Whether image model responses should be logged

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LANGCHAIN4J_OPENAI_IMAGE_MODEL_LOG_RESPONSES+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LANGCHAIN4J_OPENAI_IMAGE_MODEL_LOG_RESPONSES+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`

|===
ifndef::no-duration-note[]
[NOTE]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkiverse.langchain4j.openai.deployment.devui;

import io.quarkiverse.langchain4j.openai.deployment.Langchain4jOpenAiBuildConfig;
import io.quarkiverse.langchain4j.openai.runtime.devui.OpenAiImagesJsonRPCService;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.devui.spi.JsonRPCProvidersBuildItem;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;

public class OpenAiDevUIImagePageProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
CardPageBuildItem cardPage(
BuildProducer<JsonRPCProvidersBuildItem> producers,
Langchain4jOpenAiBuildConfig config) {
if (config.imageModel().enabled().orElse(true)) {
CardPageBuildItem card = new CardPageBuildItem();
card.addPage(Page.webComponentPageBuilder().title("Images")
.componentLink("qwc-images.js")
.icon("font-awesome-solid:palette"));
producers.produce(new JsonRPCProvidersBuildItem(OpenAiImagesJsonRPCService.class));
return card;
} else {
return null;
}
}

}
Loading

0 comments on commit 59cf4cf

Please sign in to comment.