Skip to content
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

[24.2] Fix to only show ChatGXY when available. #19389

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions client/src/components/DatasetInformation/DatasetError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { computed, onMounted, ref } from "vue";
import { GalaxyApi, type HDADetailed } from "@/api";
import { fetchDatasetDetails } from "@/api/datasets";
import { type JobDetails, type JobInputSummary } from "@/api/jobs";
import { useConfig } from "@/composables/config";
import { useMarkdown } from "@/composables/markdown";
import { useUserStore } from "@/stores/userStore";
import localize from "@/utils/localization";
Expand All @@ -30,6 +31,7 @@ const userStore = useUserStore();
const { currentUser } = storeToRefs(userStore);

const { renderMarkdown } = useMarkdown({ openLinksInNewPage: true });
const { config, isConfigLoaded } = useConfig();

const message = ref("");
const jobLoading = ref(true);
Expand All @@ -47,6 +49,8 @@ const showForm = computed(() => {
return noResult || hasError;
});

const showWizard = computed(() => isConfigLoaded && config.value?.llm_api_configured);

async function getDatasetDetails() {
datasetLoading.value = true;
try {
Expand Down Expand Up @@ -154,21 +158,22 @@ onMounted(async () => {
<b id="dataset-error-tool-id" class="text-break">{{ jobDetails.tool_id }}</b
>.
</p>

<h4 class="mb-3 h-md">Possible Causes</h4>
<p>
<span>
We can use AI to analyze the issue and suggest possible fixes. Please note that the diagnosis may
not always be accurate.
</span>
</p>
<BCard class="mb-2">
<GalaxyWizard
view="error"
:query="jobDetails.tool_stderr"
context="tool_error"
:job-id="jobDetails.id" />
</BCard>
<template v-if="showWizard">
<h4 class="mb-3 h-md">Possible Causes</h4>
<p>
<span>
We can use AI to analyze the issue and suggest possible fixes. Please note that the diagnosis
may not always be accurate.
</span>
</p>
<BCard class="mb-2">
<GalaxyWizard
view="error"
:query="jobDetails.tool_stderr"
context="tool_error"
:job-id="jobDetails.id" />
</BCard>
</template>

<DatasetErrorDetails
:tool-stderr="jobDetails.tool_stderr"
Expand Down
32 changes: 16 additions & 16 deletions lib/galaxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,9 @@ def _process_config(self, kwargs: Dict[str, Any]) -> None:

self._process_celery_config()

# load in the chat_prompts if openai is enabled
self._load_chat_prompts()
# load in the chat_prompts if openai api key is configured
if self.openai_api_key:
self._load_chat_prompts()

self.pretty_datetime_format = expand_pretty_datetime_format(self.pretty_datetime_format)
try:
Expand Down Expand Up @@ -1257,21 +1258,20 @@ def _load_theme(path: str, theme_dict: dict):
self.file_source_temp_dir = os.path.abspath(self.file_source_temp_dir)

def _load_chat_prompts(self):
if self.openai_api_key:
current_dir = os.path.dirname(os.path.abspath(__file__))
chat_prompts_path = os.path.join(current_dir, "chat_prompts.json")
current_dir = os.path.dirname(os.path.abspath(__file__))
chat_prompts_path = os.path.join(current_dir, "chat_prompts.json")

if os.path.exists(chat_prompts_path):
try:
with open(chat_prompts_path, encoding="utf-8") as file:
data = json.load(file)
self.chat_prompts = data.get("prompts", {})
except json.JSONDecodeError as e:
log.error(f"JSON decoding error in chat prompts file: {e}")
except Exception as e:
log.error(f"An error occurred while reading chat prompts file: {e}")
else:
log.warning(f"Chat prompts file not found at {chat_prompts_path}")
if os.path.exists(chat_prompts_path):
try:
with open(chat_prompts_path, encoding="utf-8") as file:
data = json.load(file)
self.chat_prompts = data.get("prompts", {})
except json.JSONDecodeError as e:
log.error(f"JSON decoding error in chat prompts file: {e}")
except Exception as e:
log.error(f"An error occurred while reading chat prompts file: {e}")
else:
log.warning(f"Chat prompts file not found at {chat_prompts_path}")

def _process_celery_config(self):
if self.celery_conf and self.celery_conf.get("result_backend") is None:
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/managers/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def _config_is_truthy(item, key, **context):
"fixed_delegated_auth": _defaults_to(False),
"help_forum_api_url": _use_config,
"enable_help_forum_tool_panel_integration": _use_config,
"llm_api_configured": lambda item, key, **context: bool(item.openai_api_key),
}


Expand Down
Loading