mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 09:25:06 +01:00
Set up basic ui page with no functionality
This commit is contained in:
parent
6244ccc01a
commit
baee52648d
4 changed files with 72 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@ __pycache__
|
|||
tests/data/.*
|
||||
src/.data
|
||||
.vscode
|
||||
*.gz
|
||||
*.pt
|
32
config.yml
Normal file
32
config.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
content-type:
|
||||
org:
|
||||
input-files: ["/home/saba/notes/notes.org", "/home/saba/notes/writing.org"]
|
||||
input-filter: null
|
||||
compressed-jsonl: ".notes.json.gz"
|
||||
embeddings-file: ".note_embeddings.pt"
|
||||
|
||||
# ledger:
|
||||
# input-files: /home/projects/personal-finance/bon.beancount
|
||||
# input-filter: null
|
||||
# compressed-jsonl: .transactions.jsonl.gz
|
||||
# embeddings-file: .transaction_embeddings.pt
|
||||
|
||||
# image:
|
||||
# input-directory: "tests/data"
|
||||
# embeddings-file: "tests/data/.image_embeddings.pt"
|
||||
# batch-size: 50
|
||||
# use-xmp-metadata: "no"
|
||||
|
||||
# music:
|
||||
# input-files: ["tests/data/music.org"]
|
||||
# input-filter: null
|
||||
# compressed-jsonl: "tests/data/.songs.jsonl.gz"
|
||||
# embeddings-file: "tests/data/.song_embeddings.pt"
|
||||
|
||||
search-type:
|
||||
asymmetric:
|
||||
encoder: "sentence-transformers/msmarco-MiniLM-L-6-v3"
|
||||
cross-encoder: "cross-encoder/ms-marco-MiniLM-L-6-v2"
|
||||
|
||||
image:
|
||||
encoder: "clip-ViT-B-32"
|
11
src/main.py
11
src/main.py
|
@ -4,7 +4,9 @@ from typing import Optional
|
|||
|
||||
# External Packages
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
# Internal Packages
|
||||
from src.search_type import asymmetric, symmetric_ledger, image_search
|
||||
|
@ -12,12 +14,17 @@ from src.utils.helpers import get_from_dict
|
|||
from src.utils.cli import cli
|
||||
from src.utils.config import SearchType, SearchModels, TextSearchConfig, ImageSearchConfig, SearchConfig
|
||||
|
||||
|
||||
# Application Global State
|
||||
model = SearchModels()
|
||||
search_config = SearchConfig()
|
||||
app = FastAPI()
|
||||
|
||||
# app.mount("/views", StaticFiles(directory="./views"), name="views")
|
||||
templates = Jinja2Templates(directory="views/")
|
||||
|
||||
@app.get('/ui', response_class=HTMLResponse)
|
||||
def ui(request: Request):
|
||||
return templates.TemplateResponse("config.html", context={'request': request})
|
||||
|
||||
@app.get('/search')
|
||||
def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None):
|
||||
|
|
28
views/config.html
Normal file
28
views/config.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Set directories for your config file.</title>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
<input type="file" id="filepicker" name="fileList" />
|
||||
<h2>Org notes</h2>
|
||||
<label>Input Files</label>
|
||||
<input type="textarea" id="org-files" name="org-files" placeholder='"/home/saba/notes/notes.org", "/home/saba/notes/writing.org"/'>
|
||||
<label>Input Filter</label>
|
||||
<input type="text" id="org-files" name="org-files" placeholder="null">
|
||||
</form>
|
||||
</body>
|
||||
<script>
|
||||
var filePicker = document.getElementById("filepicker");
|
||||
filePicker.addEventListener("change", () => {
|
||||
console.log(filePicker);
|
||||
for (const file of filePicker.files) {
|
||||
let url = URL.createObjectURL(file);
|
||||
console.log(url);
|
||||
if (file.name) {
|
||||
console.log(file);
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
Loading…
Reference in a new issue