Skip to content

Commit

Permalink
Added hidden switch for selecting bot model
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Oct 7, 2024
1 parent 028c28a commit ee64fe2
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion assets/js/Containers/FrevaGPT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
FormControl,
InputGroup,
Card,
Button } from 'react-bootstrap';
Button,
Form } from 'react-bootstrap';

import { browserHistory } from 'react-router';
import { isEmpty, has } from 'lodash';
Expand Down Expand Up @@ -47,6 +48,8 @@ class FrevaGPT extends React.Component {
this.state = {
loading: false,
userInput: "",
botModelList: [],
botModel: "",
};
}

Expand All @@ -62,6 +65,16 @@ class FrevaGPT extends React.Component {
this.getOldThread(givenQueryParams.thread_id);
this.setState({ loading: false });
}

const getBotModels = async () => {
const queryObject = {
auth_key: process.env.BOT_AUTH_KEY,
};
const response = await fetch(`/api/chatbot/availablechatbots?` + objectToQueryString(queryObject));
this.setState({ botModelList: await response.json()});
}

getBotModels();
}

createNewChat() {
Expand Down Expand Up @@ -104,6 +117,7 @@ class FrevaGPT extends React.Component {
input: this.state.userInput,
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",
};

Expand Down Expand Up @@ -220,6 +234,16 @@ class FrevaGPT extends React.Component {
</div>

<Col md={4}>
<Form.Select
value={this.botModel}
onChange={(x) => { this.setState({ botModel: x.target.value }); }}
className="me-1 mb-3"
placeholder="Choose Chatbot"
hidden>
{this.state.botModelList.map((x) => {
return <option key={x}>{x}</option>;
})}
</Form.Select>
<SidePanel/>
</Col>

Expand Down

0 comments on commit ee64fe2

Please sign in to comment.