Skip to content

Commit

Permalink
fixing config and prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
tcollins2011 committed Oct 23, 2024
1 parent 0abbf63 commit c33c806
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion client/src/components/GalaxyWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from "axios";
import { ref } from "vue";
import Heading from "./Common/Heading.vue";
import LoadingSpan from "./LoadingSpan.vue";
import { useMarkdown } from "@/composables/markdown";
const props = defineProps({
view: {
type: String,
Expand All @@ -20,6 +21,7 @@ const props = defineProps({
const query = ref(props.query);
const queryResponse = ref("");
const busy = ref(false);
const { renderMarkdown } = useMarkdown({ openLinksInNewPage: true });
// on submit, query the server and put response in display box
function submitQuery() {
busy.value = true;
Expand Down Expand Up @@ -72,7 +74,7 @@ function submitQuery() {
<b-skeleton animation="wave" width="55%"></b-skeleton>
<b-skeleton animation="wave" width="70%"></b-skeleton>
</div>
<div v-else class="chatResponse">{{ queryResponse }}</div>
<div v-else class="chatResponse" v-html="renderMarkdown(queryResponse)" />
</div>
</div>
</template>
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 @@ -129,6 +129,7 @@ def _config_is_truthy(item, key, **context):
"logo_src_secondary": _use_config,
"terms_url": _use_config,
"wiki_url": _use_config,
"openai_api_key": _use_config,
"screencasts_url": _use_config,
"citation_url": _use_config,
"citations_export_message_html": _use_config,
Expand Down
13 changes: 9 additions & 4 deletions lib/galaxy/webapps/galaxy/api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
router = Router(tags=["chat"])

PROMPT = """
Adopt the persona of an galaxy project expert who is able to easily explain complex terminal error messages to users.
Adopt the persona of an galaxy project expert who is able to easily explain complex terminal error messages to users, but do so in a dry and serious manner.
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.
You will be provided with a standard error output and should attempt to explain how this error happened and how to fix it within Galaxy.
If you are unsure totally sure of how to fix the error, please direct the user https://help.galaxyproject.org/ to ask a human for help.
Please ensure your response is in well formated markdown.
"""
@router.cbv
class ChatAPI:
Expand All @@ -39,6 +40,8 @@ class ChatAPI:
def query(self, query: ChatPayload, trans: ProvidesUserContext = DependsOnTrans) -> str:
"""We're off to ask the wizard"""

if openai is None:
raise ConfigurationError("OpenAI is not installed. Please install openai to use this feature.")
if openai is None or self.config.openai_api_key is None:
raise ConfigurationError("OpenAI is not configured for this instance.")
else:
Expand Down Expand Up @@ -67,6 +70,8 @@ def query(self, query: ChatPayload, trans: ProvidesUserContext = DependsOnTrans)
model="gpt-4o",
messages=messages,
)
print(response)

answer = response["choices"][0]["message"]["content"]
answer = response.choices[0].message.content
print(answer)
return answer

0 comments on commit c33c806

Please sign in to comment.