Skip to content

Commit

Permalink
Moved auth key and freva config to local environment used by proxyview
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Dec 16, 2024
1 parent a2e1486 commit 1ea7b93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 1 addition & 8 deletions assets/js/Containers/FrevaGPT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ class FrevaGPT extends React.Component {
};

const getBotModels = async () => {
const queryObject = {
auth_key: process.env.BOT_AUTH_KEY,
};
const response = await fetch(
`/api/chatbot/availablechatbots?` + objectToQueryString(queryObject)
`/api/chatbot/availablechatbots?`
);
this.setState({ botModelList: await response.json() });
};
Expand Down Expand Up @@ -161,10 +158,8 @@ class FrevaGPT extends React.Component {
async fetchData(input) {
const queryObject = {
input,
auth_key: process.env.BOT_AUTH_KEY,
thread_id: this.props.frevaGPT.thread,
chatbot: this.state.botModel,
freva_config: "/work/ch1187/clint/freva-dev/freva/evaluation_system.conf",
};

// response of a new bot request is streamed
Expand Down Expand Up @@ -280,7 +275,6 @@ class FrevaGPT extends React.Component {
const response = await fetch(
`/api/chatbot/getthread?` +
new URLSearchParams({
auth_key: process.env.BOT_AUTH_KEY,
thread_id: thread,
}).toString()
);
Expand All @@ -295,7 +289,6 @@ class FrevaGPT extends React.Component {
await fetch(
`/api/chatbot/stop?` +
new URLSearchParams({
auth_key: process.env.BOT_AUTH_KEY,
thread_id: this.props.frevaGPT.thread,
}).toString()
);
Expand Down
4 changes: 4 additions & 0 deletions bot/proxyviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def get(self, request, *args, **kwargs):
base_url = urljoin(settings.CHAT_BOT_URL, path)
params = request.GET.dict()

# adding bot auth key and freva conf
params["auth_key"] = settings.CHAT_BOT_AUTH_KEY
params["freva_config"] = settings.CHAT_BOT_FREVA_CONFIG

try:
upstream_response = requests.get(base_url[:-1], params=params, stream=True)
upstream_response.raise_for_status()
Expand Down
3 changes: 3 additions & 0 deletions django_evaluation/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
"variable",
]
MENU_ENTRIES = []

CHAT_BOT_URL = "http://vader5-icpub.lvt.dkrz.de:8502"
CHAT_BOT_AUTH_KEY = os.environ.get("CHAT_BOT_AUTH_KEY")
CHAT_BOT_FREVA_CONFIG = os.environ.get("CHAT_BOT_AUTH_KEY")

if os.getenv("CHAT_BOT", "0").isdigit():
ACTIVATE_CHAT_BOT = bool(int(os.getenv("CHAT_BOT", "0")))
Expand Down

0 comments on commit 1ea7b93

Please sign in to comment.