Skip to content

Commit

Permalink
hold
Browse files Browse the repository at this point in the history
  • Loading branch information
tcollins2011 committed Oct 23, 2024
1 parent fc3928e commit 0abbf63
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ export interface paths {
patch?: never;
trace?: never;
};

"/api/chat": {
/**
* Query
* @description We're off to ask the wizard
*/
post: operations["query_api_chat_post"];
post: ["query_api_chat_post"];
};
"/api/configuration": {
parameters: {
Expand Down
3 changes: 1 addition & 2 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5369,8 +5369,7 @@
~~~~~~~~~~~~~~~~~~

:Description:
API key for OpenAI (https://openai.com/) to enable the wizard (or
more?)
API key for OpenAI (https://openai.com/) to enable the chat wizard
:Default: ``None``
:Type: str

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3927,7 +3927,7 @@ mapping:
type: str
required: false
desc: |
OpenAI API key to enable the wizard.
OpenAI API key to enable the wizard.
enable_tool_recommendations:
type: bool
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3715,7 +3715,7 @@ class ChatPayload(Model):
description="The query to be sent to the chatbot.",
)
context: Optional[str] = Field(
default=""
default="",
title="Context",
description="The context for the chatbot.",
)
Expand Down
19 changes: 9 additions & 10 deletions lib/galaxy/webapps/galaxy/api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
router = Router(tags=["chat"])

PROMPT = """
You are a highly intelligent question answering agent, expert on the Galaxy analysis platform and in the fields of computer science, bioinformatics, and genomics.
You will try to answer questions about Galaxy, and if you don't know the answer, you will ask the user to rephrase the question.
Adopt the persona of an galaxy project expert who is able to easily explain complex terminal error messages to users.
Focus on providing clear and concise explanations that are easy to understand.
You will be provided with a standard error output and should attempt to explain how this error happened and how to fix it using Galaxy.
If you are unsure about the error, please direct the user https://help.galaxyproject.org/ to ask a human for help.
"""


@router.cbv
class ChatAPI:
config: GalaxyAppConfiguration = depends(GalaxyAppConfiguration)
Expand All @@ -57,16 +57,15 @@ def query(self, query: ChatPayload, trans: ProvidesUserContext = DependsOnTrans)
else:
msg = f"You will address the user as Anonymous User"
messages.append({"role": "system", "content": msg})
elif query.context == "tool_error":
msg = "The user will provide you a Galaxy tool error, and you will try to debug and explain what happened"
messages.append({"role": "system", "content": msg})
# elif query.context == "tool_error":
# msg = "The user will provide you a Galaxy tool error, and you will try to debug and explain what happened"
# messages.append({"role": "system", "content": msg})

log.debug(f"CHATGPTmessages: {messages}")

response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
response = openai.chat.completions.create(
model="gpt-4o",
messages=messages,
temperature=0,
)

answer = response["choices"][0]["message"]["content"]
Expand Down

0 comments on commit 0abbf63

Please sign in to comment.