Skip to content

Commit

Permalink
added chat prompts json and a function to load them in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
tcollins2011 authored and dannon committed Nov 18, 2024
1 parent a79009b commit 14480cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/galaxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,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()

self.pretty_datetime_format = expand_pretty_datetime_format(self.pretty_datetime_format)
try:
with open(self.user_preferences_extra_conf_path) as stream:
Expand Down Expand Up @@ -1251,6 +1254,23 @@ def _load_theme(path: str, theme_dict: dict):
if self.file_source_temp_dir:
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")

if os.path.exists(chat_prompts_path):
try:
with open(chat_prompts_path, "r", 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:
# If the result_backend is not set, use a SQLite database in the data directory
Expand Down
8 changes: 8 additions & 0 deletions lib/galaxy/config/chat_prompts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"prompts": {
"tool_error": "Adopt the persona of a galaxy project expert who is able to easily explain complex error messages to novice users in a serious manner.\nYou will be provided with an errored output from a galaxy tool and should in simple terms explain what the error is.\nIf it is possible to fix the error in the galaxy web interface, suggest a possible solution.\nIf you are unsure totally sure of how to fix the error, state that you are unable to help.\nPlease ensure your response is in well-formatted markdown."
}
}



0 comments on commit 14480cf

Please sign in to comment.