Skip to content

Commit

Permalink
feat: added workspace to main request
Browse files Browse the repository at this point in the history
  • Loading branch information
PauliusPreiksaCode committed Jun 24, 2024
1 parent 785fa66 commit ab95666
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions GUI/back-end/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@

@app.route('/api/v1/request', methods=['POST'])
def process():
request_data = request.get_json()
request_data = request.json.get('content')
request_workspace = request.json.get('workspace')
print(request_data)
print(request_workspace)
print("Got data")
logging.info(request_data)
if not request_data:
Expand Down Expand Up @@ -75,4 +78,5 @@ def process():

# Run the app
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=8080)
# app.run(debug=True, host='0.0.0.0', port=8080)
app.run(debug=True, port=8080)
9 changes: 8 additions & 1 deletion GUI/front-end/src/components/displays/chat/ChatDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AccountCircle as AccountCircleIcon } from '@mui/icons-material';
import { useApplicationContext } from '../../../contexts';
import { KathLogo } from '../../svgs';
import { useSendRequest } from '../../../hooks';
import { useWorkspaceContext } from '../../../contexts/tool/UseWorkspaceContext';

interface Props {}

Expand All @@ -14,6 +15,7 @@ export const ChatDisplay: React.FC<Props> = () => {
const [isInputDisabled, setIsInputDisabled] = React.useState(false);

const applicationContext = useApplicationContext();
const workspaceContext = useWorkspaceContext();
const sendRequest = useSendRequest();

const handleSubmit = async (content: string) => {
Expand All @@ -23,7 +25,12 @@ export const ChatDisplay: React.FC<Props> = () => {
<ChatInstance icon={<AccountCircleIcon />} author='User' content={content} />,
]);

const responseResult = await sendRequest.mutateAsync(content);
const data = {
content: content,
workspace: workspaceContext.workspace,
}

const responseResult = await sendRequest.mutateAsync(data);
setIsInputDisabled(false);

setChatInstances((prevInstances) => [
Expand Down
4 changes: 2 additions & 2 deletions GUI/front-end/src/services/request/requestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { ENDPOINTS } from "../../types/constants";
import httpClient from "../httpClient";


export async function sendRequest(request: string) {
export async function sendRequest(data: { content: string, workspace: string | null}) {
return await httpClient
.post(ENDPOINTS.REQUEST, request)
.post(ENDPOINTS.REQUEST, data)
.then((res) => res.data)
.catch((err) => {
console.error(err);
Expand Down

0 comments on commit ab95666

Please sign in to comment.