Skip to content

Commit

Permalink
filedimegpt now supports querying files locally using llama3
Browse files Browse the repository at this point in the history
added listen to selection option in preview pane
  • Loading branch information
visnkmr committed Apr 20, 2024
1 parent e8a2fa1 commit 649db94
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filedime",
"version": "0.9.61",
"version": "0.9.62",
"private": true,
"engines": {
"node": "20.x"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "filedime"
version = "0.9.61"
version = "0.9.62"
description = "rust based file explorer."
authors = ["visnk"]
license = ""
Expand Down
36 changes: 20 additions & 16 deletions src/components/gptchatinterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function getchattime(){
function getchattimestamp(){
return new Date().getTime()
}
export default function GPTchatinterface({message,fgptendpoint}:gptargs){
export default function GPTchatinterface({message,fgptendpoint="localhost"}:gptargs){
console.log("endpoint-->"+fgptendpoint)
// const [time, setTime] = useState(new Date());
// useEffect(() => {
// const timer = setInterval(() => {
Expand Down Expand Up @@ -59,7 +60,7 @@ export default function GPTchatinterface({message,fgptendpoint}:gptargs){
const [chathistorytemp, setchathistorytemp] = useState([] as mitem[]);
const [chatbuttonstate,setcbs]=useState(false)
const [question,setq]=useState("")
const[filegptendpoint,setfge]=useState("http://localhost:8694")
const[filegptendpoint,setfge]=useState(`http://${fgptendpoint}:8694`)
const[localorremote,setlor]=useState(message?true:false)

// const [querystring, setqs] = useState([message.path]);
Expand Down Expand Up @@ -258,21 +259,24 @@ else{
fetchData();
};
useEffect(()=>{
// embed();
if(!fgptendpoint){

invoke("filegptendpoint",{
endpoint:""
}).then((e)=>{
console.log(e)
setfge(e)
setlor(()=>{
(e as string).includes("localhost")?embed():null;
return (e as string).includes("localhost")
})
})
}
else{
embed();
// if(!fgptendpoint){
// let url=typeof window !== 'undefined' ? window.location.hostname : '/'
// setfge(url)
// // invoke("filegptendpoint",{
// // endpoint:""
// // }).then((e)=>{
// // console.log(e)
// // setfge(e)
// // setlor(()=>{
// // (e as string).includes("localhost")?embed():null;
// // return (e as string).includes("localhost")
// // })
// // })
// }
// else
{
setfge(`http://${fgptendpoint}:8694`)
}
fgtest(); //check if filedimegpt is running
Expand Down
33 changes: 30 additions & 3 deletions src/components/readfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function ReadFileComp({message}:rfcprops){
.catch(console.error)
}
}, [message.path]);

const [selectedtext,setst]=useState("")
return (
<>

Expand Down Expand Up @@ -172,8 +172,30 @@ export default function ReadFileComp({message}:rfcprops){
</HoverCardContent>
</HoverCard>
</div>
<Button className="ml-4 text-white" variant={"outline"} onClick={()=>{
const requestBody = {
"text": `${selectedtext}`.toString(),
"comments":"something here"
};
fetch(`http://127.0.0.1:8694/tts`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
})
.then(response => {
console.log(response)
})
.catch(error => {
console.error('Error reading stream:', error)});
}}>Listen to selection</Button>
</div>
<div className={`h-[90%] overflow-${scrollorauto}`}>
<div onMouseUp={()=>{
const selectedT = window.getSelection().toString();
setst(selectedT)
console.log('Selected text:', selectedT);
}} className={`h-[90%] overflow-${scrollorauto}`}>

{IMAGE_TYPES.some(type => message.name.includes(type))?(
<TransformWrapper
Expand Down Expand Up @@ -205,4 +227,9 @@ export default function ReadFileComp({message}:rfcprops){
</div>
</>
)
}
}

// myDiv.addEventListener('mouseup', () => {
// const selectedText = window.getSelection().toString();
// console.log('Selected text:', selectedText);
// });

0 comments on commit 649db94

Please sign in to comment.