Skip to content

Commit

Permalink
openai library update, model swap
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Oct 24, 2024
1 parent 6f90756 commit 64a9530
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/galaxy/webapps/galaxy/api/chat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
API Controller providing Chat functionality
"""

import logging

try:
Expand Down Expand Up @@ -38,8 +39,9 @@ def query(self, query: ChatPayload, trans: ProvidesUserContext = DependsOnTrans)

if openai is None or self.config.openai_api_key is None:
raise ConfigurationError("OpenAI is not configured for this instance.")
else:
openai.api_key = self.config.openai_api_key
client = openai.OpenAI(
api_key=self.config.openai_api_key,
)

messages = [
{"role": "system", "content": PROMPT},
Expand All @@ -50,16 +52,10 @@ def query(self, query: ChatPayload, trans: ProvidesUserContext = DependsOnTrans)
msg = "The user will provide you a Galaxy tool error, and you will try to explain the error and provide a solution."
messages.append({"role": "system", "content": msg})

client = OpenAI(
organization='org-gO14XNCI5fwciPOYeic5Kq14',
project='$PROJECT_ID',
)


response = client.create_chat(
completion = client.chat.completions.create(
model="gpt-4o",
messages=messages,
temperature=0,
)
answer = response["choices"][0]["message"]["content"]
answer = completion.choices[0].message.content
return answer

0 comments on commit 64a9530

Please sign in to comment.