|
|
|
import React, { useState } from 'react'; |
|
import axios from 'axios'; |
|
|
|
const Popup = () => { |
|
const [message, setMessage] = useState(''); |
|
const [response, setResponse] = useState(''); |
|
|
|
const sendQuery = async () => { |
|
try { |
|
const result = await axios.post('http://0.0.0.0:8000/query', { query: message }); |
|
setResponse(result.data.response); |
|
} catch (error) { |
|
setResponse('Error communicating with the server.'); |
|
} |
|
}; |
|
|
|
return ( |
|
<div className="chatbox"> |
|
<input |
|
type="text" |
|
value={message} |
|
onChange={e => setMessage(e.target.value)} |
|
className="chat-input" |
|
placeholder="Type your message..." |
|
/> |
|
<button onClick={sendQuery} className="chat-send-btn">Send</button> |
|
<div className="response-box"> |
|
{response} |
|
</div> |
|
</div> |
|
); |
|
}; |
|
|
|
export default Popup; |
|
|