-
Notifications
You must be signed in to change notification settings - Fork 3
Feat: Add Theming with config.yml #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DeepanshKhurana
wants to merge
30
commits into
main
Choose a base branch
from
feat/add-config-theming
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8089895
feat: add theming with config.yml
DeepanshKhurana ac42cd1
chore: add onClick = "select" to both app list and job list tables
DeepanshKhurana df18d7e
chore: revert config color to Appsilon Blue
DeepanshKhurana 2250cfa
docs: update README with new FAQs about branding
DeepanshKhurana b33ef11
feat: add handling for logo in config.yml theming
DeepanshKhurana 5543096
refactor: untangle main.R server
TymekAppsilon d6eb5ff
refactor: replace reactiveValues with plain reactives
TymekAppsilon c583c89
refactor: update checks
TymekAppsilon cc4ba3a
refactor: unnest renderUI
TymekAppsilon 1bd9d78
test: add unit tests for general_utils.R
DeepanshKhurana d8cb1c0
feat: move branding outside ui/server
DeepanshKhurana f2d48df
chore: remove nolint
DeepanshKhurana d12bdcc
fix: add working default value + docstring improvement for generate_e…
DeepanshKhurana 9e1a293
chore: move primary to the top in config.yml
DeepanshKhurana 9937baa
chore: remove redundant default variable from generate_css_variables
DeepanshKhurana 3a226a7
docs: add context for what the colors do in README.md
DeepanshKhurana 8f88ddd
Merge remote-tracking branch 'upstream/feat/add-config-theming' into …
TymekAppsilon 937c239
chore: enable box.linters
DeepanshKhurana 70d1163
feat: add config for llm mode in config.yml
DeepanshKhurana 7ff93c2
chore: update dependencies
DeepanshKhurana 56a3dba
feat: add llm system prompt
DeepanshKhurana 1b22202
fix: independent linting fixes
DeepanshKhurana ebe6d6b
feat: add llm utils using ellmer
DeepanshKhurana 54a06fa
feat: integrate llm functionality
DeepanshKhurana 86b1d69
feat: add llm styling
DeepanshKhurana 3de3d6b
chore: disable llm mode by default
DeepanshKhurana b634e10
feat: add logic to validate llm providers
DeepanshKhurana 687c311
chore: update R version + rebase
DeepanshKhurana 12348ee
fix: handle edge case where phrases like "no errors" would still trig…
DeepanshKhurana 7e8ec3c
Merge pull request #23 from DeepanshKhurana/fix/edge-case-check-error…
DeepanshKhurana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| linters: | ||
| linters_with_defaults( | ||
| line_length_linter = line_length_linter(100), | ||
| object_usage_linter = NULL # Does not work with `box::use()`. | ||
| defaults = box.linters::rhino_default_linters, | ||
| line_length_linter = line_length_linter(100) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,64 @@ | ||
| box::use( | ||
| base64enc[ | ||
| base64encode | ||
| ], | ||
| shiny[ | ||
| div, | ||
| img, | ||
| p, | ||
| renderUI | ||
| ], | ||
| ) | ||
|
|
||
| #' @description Function to generate an empty state UI | ||
| #' @param text Text to display in the empty state | ||
| #' @param image_path Path to the image to display in the empty state | ||
| #' @param color Color to use for the image | ||
| #' @export | ||
| generate_empty_state_ui <- function( | ||
| text = "Select an application and a job to view logs", | ||
| image_path = "static/illustrations/empty_state.svg" | ||
| image_path = "static/illustrations/empty_state.svg", | ||
| color = "#0099f9" | ||
| ) { | ||
| div( | ||
| class = "empty-state-container", | ||
| p( | ||
| class = "empty-state-text", | ||
| text | ||
| ), | ||
| img( | ||
| src = image_path, | ||
| class = "empty-state-image", | ||
| replace_svg_fill( | ||
| color = color, | ||
| svg_path = image_path, | ||
| alt = text | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| #' Function to replace fill color in SVG | ||
| #' @param color Character. The color to replace | ||
| #' @param svg_path Character. The path to the SVG file | ||
| #' @param placeholder Character. The placeholder. Default is "PRIMARY" | ||
| #' @param alt Character. The alt text for the image | ||
| #' @return an image tag with the SVG content | ||
| replace_svg_fill <- function( | ||
| color, | ||
| svg_path = "", | ||
| placeholder = "PRIMARY", | ||
| alt = "", | ||
| class = "empty-state-image" | ||
| ) { | ||
| svg_content <- readLines(svg_path) | ||
| svg_content <- paste(svg_content, collapse = "\n") | ||
| svg_content <- gsub( | ||
| placeholder, | ||
| color, | ||
| svg_content | ||
| ) | ||
| img( | ||
| class = class, | ||
| src = paste0( | ||
| "data:image/svg+xml;base64,", | ||
| base64encode(charToRaw(svg_content)) | ||
| ), | ||
| alt = alt | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| box::use( | ||
| config[ | ||
| get | ||
| ], | ||
| ellmer, #nolint: we do use this package just in a separate notation [[ ]] | ||
| glue[ | ||
| glue | ||
| ], | ||
| ) | ||
|
|
||
| #' Check if LLM is enabled | ||
| #' | ||
| #' This function checks the LLM configuration and returns TRUE if enabled, FALSE otherwise. | ||
| #' @return Logical indicating if LLM is enabled | ||
| #' @export | ||
| is_llm_enabled <- function() { | ||
| get("llm")$enabled %||% FALSE | ||
| } | ||
|
|
||
| #' Get valid LLM providers | ||
| #' @return A character vector of valid LLM providers | ||
| get_valid_providers <- function( | ||
| ) { | ||
| ellmer_functions <- ls(ellmer)[ | ||
| grepl( | ||
| pattern = "^chat_", | ||
| x = ls(ellmer) | ||
| ) | ||
| ] | ||
| sub( | ||
| pattern = "^chat_", | ||
| replacement = "", | ||
| x = ellmer_functions | ||
| ) | ||
| } | ||
|
|
||
| #' Check if the provider is valid | ||
| #' @param provider The LLM provider to check | ||
| #' @param valid_providers A character vector of valid LLM providers | ||
| #' @return Logical indicating if the provider is valid | ||
| verify_provider <- function( | ||
| provider, | ||
| valid_providers = get_valid_providers() | ||
| ) { | ||
| if (!provider %in% valid_providers) { | ||
| stop( | ||
| glue( | ||
| "Invalid LLM provider '{provider}'. ", | ||
| "Valid providers are: {paste(valid_providers, collapse = ', ')}" | ||
| ) | ||
| ) | ||
| } | ||
| TRUE | ||
| } | ||
|
|
||
| #' Get LLM configuration | ||
| #' | ||
| #' Returns the LLM configuration if LLM is enabled. Otherwise, throws an error. | ||
| #' @return A list containing the LLM configuration | ||
| get_llm_config <- function() { | ||
| if (!is_llm_enabled()) { | ||
| stop("Oops! LLM is not enabled in config.yml!") | ||
| } | ||
| verify_provider( | ||
| get("llm")$provider, | ||
| get_valid_providers() | ||
| ) | ||
| get("llm") | ||
| } | ||
|
|
||
| #' Get the LLM function based on the provider | ||
| #' | ||
| #' Extracts the chat function dynamically from the `ellmer` module. | ||
| #' @param llm_config Optional configuration for the LLM | ||
| #' @return A function to create a chat object | ||
| get_llm_function <- function( | ||
| llm_config = get_llm_config() | ||
| ) { | ||
| ellmer[[glue("chat_{llm_config$provider}")]] | ||
| } | ||
|
|
||
| #' Create a chat object | ||
| #' | ||
| #' Uses the configured LLM provider and model to create a chat object. | ||
| #' @param llm_config Optional configuration for the LLM | ||
| #' @return A chat object | ||
| #' @export | ||
| create_chat_object <- function( | ||
| llm_config = get_llm_config() | ||
| ) { | ||
| fun <- get_llm_function(llm_config) | ||
| fun( | ||
| api_key = llm_config$api_key, | ||
| model = llm_config$model, | ||
| system_prompt = llm_config$system_prompt, | ||
| seed = 42, | ||
| api_args = list( | ||
| temperature = 0 | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| #' Invoke LLM help with the logs data.frame | ||
| #' @param logs_data A data frame containing log data | ||
| #' @return A response from the LLM | ||
| #' @export | ||
| get_llm_help <- function( | ||
| logs_data | ||
| ) { | ||
| chat <- create_chat_object() | ||
| chat$chat( | ||
| concatenate_logs( | ||
| logs_data | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| #' Concatenate logs | ||
| #' @param processed_logs A data frame containing log data | ||
| #' @return A string with concatenated log entries | ||
| concatenate_logs <- function( | ||
| processed_logs | ||
| ) { | ||
| paste( | ||
| processed_logs$entries.data, | ||
| collapse = "\n" | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.