mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-21 21:50:49 +02:00
abstracts textarea
This commit is contained in:
parent
7b9f3ee9c2
commit
7c4e7ab07a
2 changed files with 43 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import React from 'react';
|
||||
import TextChat from './components/TextChat';
|
||||
|
||||
const App = () => {
|
||||
|
||||
|
@ -7,7 +8,8 @@ const App = () => {
|
|||
<div className="w-80 bg-slate-800"></div>
|
||||
<div className="flex h-full w-full flex-col bg-gray-50 ">
|
||||
<div className="flex-1 overflow-y-auto"></div>
|
||||
<textarea className="m-10 h-16 p-4" onChange={(e) => console.log(e.target.value)}/>
|
||||
{/* <textarea className="m-10 h-16 p-4" onChange={(e) => console.log(e.target.value)}/> */}
|
||||
<TextChat />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
40
src/components/TextChat.jsx
Normal file
40
src/components/TextChat.jsx
Normal file
|
@ -0,0 +1,40 @@
|
|||
import React from 'react';
|
||||
import EventSource from 'eventsource';
|
||||
|
||||
export default function TextChat() {
|
||||
const handleKeyPress = (e) => {
|
||||
if (e.key === 'Enter' && e.shiftKey) {
|
||||
console.log('Enter + Shift');
|
||||
}
|
||||
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
console.log('Submit Enter');
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
const events = new EventSource('http://localhost:3050/ask');
|
||||
events.onopen = function () {
|
||||
console.log('connection is opened');
|
||||
};
|
||||
|
||||
events.onmessage = function (e) {
|
||||
console.log(e);
|
||||
};
|
||||
|
||||
events.onerror = function (e) {
|
||||
console.log(e, 'error in opening conn.');
|
||||
events.close();
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<textarea
|
||||
className="m-10 h-16 p-4"
|
||||
onKeyUp={handleKeyPress}
|
||||
onChange={(e) => console.log(e.target.value)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue