Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Oct 2, 2024
2 parents 122adb9 + 8c12c01 commit 38e66ef
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
18 changes: 18 additions & 0 deletions assets/js/Containers/FrevaGPT/SidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ function SidePanel() {
})}
</div>
</Card>

<Card className="mb-3 shadow-sm">
<div className="btn btn-outline-secondary border-0 p-3 rounded-top text-start card-header shadow-sm button-div">
Freva requests
</div>
<div className="p-3 py-2 collapse show">
{botRequests.freva.map((element, index) => {
return(
<div key={index}>
<a className="text-wrap" href="" onClick={() => changeToThread(element.thread)}>
{element.title}
</a>
</div>

);
})}
</div>
</Card>
</div>


Expand Down
2 changes: 1 addition & 1 deletion assets/js/Containers/FrevaGPT/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export const addElement = (element) => (dispatch) => {
type: constants.ADD_ELEMENT,
payload: element,
})
}
}
2 changes: 1 addition & 1 deletion assets/js/Containers/FrevaGPT/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

export const ADD_ELEMENT = "ADD_ELEMENT";
export const SET_CONVERSATION = "SET_CONVERSATION";
export const SET_THREAD = "SET_THREAD";
export const SET_THREAD = "SET_THREAD";
13 changes: 8 additions & 5 deletions assets/js/Containers/FrevaGPT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Spinner from "../../Components/Spinner";
import CodeBlock from "./CodeBlock";
import SidePanel from "./SidePanel";

import { replaceLinebreaks } from './utils';
import { replaceLinebreaks, objectToQueryString } from './utils';

import {
setThread,
Expand Down Expand Up @@ -92,13 +92,16 @@ class FrevaGPT extends React.Component {
}

async fetchData() {
// response of a new bot request is streamed
const response = await fetch(`/api/chatbot/streamresponse?` + new URLSearchParams({

const queryObject = {
input: this.state.userInput.content,
auth_key: process.env.BOT_AUTH_KEY,
thread_id: this.props.frevaGPT.thread,
freva_config: encodeURIComponent("/work/ch1187/clint/freva-dev/freva/evaluation_system.conf"),
}).toString()); // add signal for abortController
freva_config: "/work/ch1187/clint/freva-dev/freva/evaluation_system.conf",
};

// response of a new bot request is streamed
const response = await fetch(`/api/chatbot/streamresponse?` + helper.objectToQueryString(queryObject)); //, signal);

const reader = response.body.getReader();
const decoder = new TextDecoder('utf-8');
Expand Down
8 changes: 7 additions & 1 deletion assets/js/Containers/FrevaGPT/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ export function formatCode(mode, data) {
}

return codeSnippets;
}
}

export const objectToQueryString = (obj) => {
return Object.entries(obj)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&');
};

0 comments on commit 38e66ef

Please sign in to comment.