-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(audiorag): acutal app development
- Loading branch information
Showing
23 changed files
with
559 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Ollama RAG with LLAMA 3</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<script src="./main.js" defer></script> | ||
</head> | ||
<body class="w-screen h-screen bg-emerald-100 overflow-scroll flex flex-row"> | ||
<div id="files" class="flex flex-col w-[30%] p-8 gap-4"><h1 class="text-xl">Files in RAG store</h1></div> | ||
<div id="main" class="flex flex-col w-[70%] p-8 gap-4"><h1 class="text-xl">Chat</h1></div> | ||
<div class="fixed bottom-8 right-8 h-12 flex items-stretch justify-stretch"> | ||
<form method="post" enctype="multipart/form-data" action="/upload"> | ||
<input type="file" name="file" class="ml-4 outline-none p-2 self-center"> | ||
<input type="submit" value="Upload" class="cursor-pointer hover:underline"> | ||
</form> | ||
<div id="spinner" class="w-12 h-12 outline hidden animate-spin"></div> | ||
<input | ||
type="text" | ||
name="q" | ||
id="q" | ||
value="" | ||
class="ml-4 outline-none w-[600px] rounded-l-full p-2 px-8" | ||
/> | ||
<button | ||
id="send" | ||
class="bg-emerald-600 text-white p-2 px-4 rounded-r-full" | ||
> | ||
Send | ||
</button> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
document.querySelector("#send").onclick = async () => { | ||
const prompt = document.querySelector("#q").value; | ||
document.querySelector("#q").value = ""; | ||
|
||
document.querySelector("#spinner").classList.toggle("hidden"); | ||
|
||
const q_div = document.createElement("div"); | ||
q_div.className = | ||
"m-4 mr-24 flex flex-col gap-2 items-start bg-emerald-400 p-4 rounded-md"; | ||
const user_div = document.createElement("div"); | ||
user_div.innerText = "User:"; | ||
const prompt_div = document.createElement("div"); | ||
prompt_div.innerText = prompt; | ||
q_div.appendChild(user_div); | ||
q_div.appendChild(prompt_div); | ||
document.querySelector("#main").appendChild(q_div); | ||
|
||
const req = await fetch("/api/query", { | ||
body: JSON.stringify({ | ||
prompt, | ||
}), | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
const res = await req.json(); | ||
console.log(res); | ||
const r_div = document.createElement("div"); | ||
r_div.className = | ||
"m-4 ml-24 flex flex-col gap-2 bg-emerald-300 p-4 rounded-md"; | ||
const a_div = document.createElement("div"); | ||
a_div.innerText = "RAG:"; | ||
const answer_div = document.createElement("div"); | ||
answer_div.innerText = res.answer; | ||
const context_div = document.createElement("div"); | ||
res.context.forEach((elem) => { | ||
const context_item = document.createElement("div"); | ||
context_item.className = "m-4 border-b-2"; | ||
const text = document.createElement("div"); | ||
text.innerText = elem.page_content; | ||
context_item.appendChild(text); | ||
const source = document.createElement("div"); | ||
source.innerText = elem.metadata.source; | ||
source.className = "text-right font-semibold"; | ||
context_item.appendChild(source); | ||
context_div.appendChild(context_item); | ||
}); | ||
r_div.appendChild(a_div); | ||
r_div.appendChild(answer_div); | ||
r_div.appendChild(context_div); | ||
|
||
document.querySelector("#main").appendChild(r_div); | ||
|
||
document.querySelector("#spinner").classList.toggle("hidden"); | ||
}; | ||
const getFileType = (filename) => { | ||
switch (filename.split('.').at(-1)) { | ||
case 'txt': | ||
return 'Text file'; | ||
case 'wav': | ||
return 'WAV Sound recording'; | ||
case 'pdf': | ||
return 'PDF document'; | ||
default: | ||
return '<<unknown>>'; | ||
} | ||
}; | ||
|
||
fetch("/files").then(res=>res.json().then(json=>{ | ||
document.querySelector("#files").innerHTML = `<h1 class="text-xl">Files in RAG store</h1>` + json.map(file=>` | ||
<div class="p-4 bg-white rounded-md flex flex-row items-center justify-between"><div>${file}</div><div class="italic">${getFileType(file)}</div></div> | ||
`).join("") | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 31 additions & 31 deletions
62
audio-rag/native/ios/audiorag/Images.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
{ | ||
"images" : [ | ||
"images": [ | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
"idiom": "iphone", | ||
"scale": "2x", | ||
"size": "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
"idiom": "iphone", | ||
"scale": "3x", | ||
"size": "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
"idiom": "iphone", | ||
"scale": "2x", | ||
"size": "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
"idiom": "iphone", | ||
"scale": "3x", | ||
"size": "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
"idiom": "iphone", | ||
"scale": "2x", | ||
"size": "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
"idiom": "iphone", | ||
"scale": "3x", | ||
"size": "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
"idiom": "iphone", | ||
"scale": "2x", | ||
"size": "60x60" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
"idiom": "iphone", | ||
"scale": "3x", | ||
"size": "60x60" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
"idiom": "ios-marketing", | ||
"scale": "1x", | ||
"size": "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
"info": { | ||
"author": "xcode", | ||
"version": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
"info": { | ||
"version": 1, | ||
"author": "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.