mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01:00
Remove references to demo
- The demo setting is no longer necessary for the time being, as we won't have anymore demo instances
This commit is contained in:
parent
b5972e9311
commit
800bb4f458
14 changed files with 297 additions and 649 deletions
|
@ -103,21 +103,6 @@ img.khoj-logo {
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.khoj-banner {
|
|
||||||
color: black;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.khoj-banner {
|
|
||||||
font-size: small;
|
|
||||||
margin: 0;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p#khoj-banner {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
div.khoj-header {
|
div.khoj-header {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
|
@ -274,8 +274,9 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<div id="khoj-banner-container" class="khoj-banner-container">
|
<div id="khoj-empty-container" class="khoj-empty-container">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Add Header Logo and Nav Pane-->
|
<!--Add Header Logo and Nav Pane-->
|
||||||
<div class="khoj-header">
|
<div class="khoj-header">
|
||||||
<a class="khoj-logo" href="/">
|
<a class="khoj-logo" href="/">
|
||||||
|
@ -454,6 +455,11 @@
|
||||||
border-bottom: 1px dotted #475569;
|
border-bottom: 1px dotted #475569;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.khoj-empty-container {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
@media (pointer: coarse), (hover: none) {
|
@media (pointer: coarse), (hover: none) {
|
||||||
abbr[title] {
|
abbr[title] {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -490,12 +496,6 @@
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
grid-template-columns: auto;
|
grid-template-columns: auto;
|
||||||
}
|
}
|
||||||
a.khoj-banner {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
p.khoj-banner {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@media only screen and (min-width: 600px) {
|
@media only screen and (min-width: 600px) {
|
||||||
body {
|
body {
|
||||||
|
@ -507,11 +507,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.khoj-banner-container {
|
|
||||||
padding: 0px;
|
|
||||||
margin: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#chat-tooltip {
|
div#chat-tooltip {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
|
@ -533,23 +528,6 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button#khoj-banner-submit,
|
|
||||||
input#khoj-banner-email {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid #475569;
|
|
||||||
background: #f9fafc;
|
|
||||||
}
|
|
||||||
|
|
||||||
button#khoj-banner-submit:hover,
|
|
||||||
input#khoj-banner-email:hover {
|
|
||||||
box-shadow: 0 0 11px #aaa;
|
|
||||||
}
|
|
||||||
div.khoj-banner-container-hidden {
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.programmatic-output {
|
div.programmatic-output {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
|
|
|
@ -362,35 +362,6 @@
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
var khojBannerSubmit = document.getElementById("khoj-banner-submit");
|
|
||||||
khojBannerSubmit?.addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var email = document.getElementById("khoj-banner-email").value;
|
|
||||||
fetch("https://app.khoj.dev/beta/users/", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: email
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(data) {
|
|
||||||
console.log(data);
|
|
||||||
if (data.user != null) {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "Thanks for signing up. We'll be in touch soon! 🚀";
|
|
||||||
document.getElementById("khoj-banner-submit").remove();
|
|
||||||
} else {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
}
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.log(error);
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script src="./renderer.js"></script>
|
<script src="./renderer.js"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -436,14 +436,6 @@
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.khoj-banner-container {
|
|
||||||
background: linear-gradient(-45deg, #FFC107, #FF9800, #FF5722, #FF9800, #FFC107);
|
|
||||||
background-size: 400% 400%;
|
|
||||||
animation: gradient 15s ease infinite;
|
|
||||||
text-align: center;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes gradient {
|
@keyframes gradient {
|
||||||
0% {
|
0% {
|
||||||
background-position: 0% 50%;
|
background-position: 0% 50%;
|
||||||
|
@ -460,57 +452,5 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button#khoj-banner-submit,
|
|
||||||
input#khoj-banner-email {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid #475569;
|
|
||||||
background: #f9fafc;
|
|
||||||
}
|
|
||||||
|
|
||||||
button#khoj-banner-submit:hover,
|
|
||||||
input#khoj-banner-email:hover {
|
|
||||||
box-shadow: 0 0 11px #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: 600px) {
|
|
||||||
a.khoj-banner {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
p.khoj-banner {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
var khojBannerSubmit = document.getElementById("khoj-banner-submit");
|
|
||||||
khojBannerSubmit?.addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var email = document.getElementById("khoj-banner-email").value;
|
|
||||||
fetch("https://app.khoj.dev/beta/users/", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: email
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(data) {
|
|
||||||
console.log(data);
|
|
||||||
if (data.user != null) {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "Thanks for signing up. We'll be in touch soon! 🚀";
|
|
||||||
document.getElementById("khoj-banner-submit").remove();
|
|
||||||
} else {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
}
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.log(error);
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -159,24 +159,22 @@ def configure_middleware(app):
|
||||||
app.add_middleware(SessionMiddleware, secret_key=os.environ.get("KHOJ_DJANGO_SECRET_KEY", "!secret"))
|
app.add_middleware(SessionMiddleware, secret_key=os.environ.get("KHOJ_DJANGO_SECRET_KEY", "!secret"))
|
||||||
|
|
||||||
|
|
||||||
if not state.demo:
|
@schedule.repeat(schedule.every(61).minutes)
|
||||||
|
def update_search_index():
|
||||||
@schedule.repeat(schedule.every(61).minutes)
|
try:
|
||||||
def update_search_index():
|
logger.info("📬 Updating content index via Scheduler")
|
||||||
try:
|
for user in get_all_users():
|
||||||
logger.info("📬 Updating content index via Scheduler")
|
all_files = collect_files(user=user)
|
||||||
for user in get_all_users():
|
|
||||||
all_files = collect_files(user=user)
|
|
||||||
state.content_index = configure_content(
|
|
||||||
state.content_index, state.config.content_type, all_files, state.search_models, user=user
|
|
||||||
)
|
|
||||||
all_files = collect_files(user=None)
|
|
||||||
state.content_index = configure_content(
|
state.content_index = configure_content(
|
||||||
state.content_index, state.config.content_type, all_files, state.search_models, user=None
|
state.content_index, state.config.content_type, all_files, state.search_models, user=user
|
||||||
)
|
)
|
||||||
logger.info("📪 Content index updated via Scheduler")
|
all_files = collect_files(user=None)
|
||||||
except Exception as e:
|
state.content_index = configure_content(
|
||||||
logger.error(f"🚨 Error updating content index via Scheduler: {e}", exc_info=True)
|
state.content_index, state.config.content_type, all_files, state.search_models, user=None
|
||||||
|
)
|
||||||
|
logger.info("📪 Content index updated via Scheduler")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"🚨 Error updating content index via Scheduler: {e}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
def configure_search_types(config: FullConfig):
|
def configure_search_types(config: FullConfig):
|
||||||
|
|
|
@ -106,21 +106,6 @@ img.khoj-logo {
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.khoj-banner {
|
|
||||||
color: black;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.khoj-banner {
|
|
||||||
font-size: medium;
|
|
||||||
margin: 0;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p#khoj-banner {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Dropdown in navigation menu*/
|
/* Dropdown in navigation menu*/
|
||||||
#khoj-nav-menu-container {
|
#khoj-nav-menu-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -261,17 +261,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<div id="khoj-banner-container" class="khoj-banner-container">
|
<div id="khoj-empty-container" class="khoj-empty-container">
|
||||||
{% if demo %}
|
|
||||||
<!-- Banner linking to https://khoj.dev -->
|
|
||||||
<a class="khoj-banner" href="https://khoj.dev" target="_blank">
|
|
||||||
<p id="khoj-banner" class="khoj-banner">
|
|
||||||
Enroll in Khoj cloud to get your own assistant
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
<input type="text" id="khoj-banner-email" placeholder="email" class="khoj-banner-email"></input>
|
|
||||||
<button id="khoj-banner-submit" class="khoj-banner-button">Submit</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Add Header Logo and Nav Pane-->
|
<!--Add Header Logo and Nav Pane-->
|
||||||
|
@ -480,12 +470,6 @@
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
grid-template-columns: auto;
|
grid-template-columns: auto;
|
||||||
}
|
}
|
||||||
a.khoj-banner {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
p.khoj-banner {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@media only screen and (min-width: 700px) {
|
@media only screen and (min-width: 700px) {
|
||||||
body {
|
body {
|
||||||
|
@ -497,14 +481,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.khoj-banner-container {
|
|
||||||
background: linear-gradient(-45deg, #FFC107, #FF9800, #FF5722, #FF9800, #FFC107);
|
|
||||||
background-size: 400% 400%;
|
|
||||||
animation: gradient 15s ease infinite;
|
|
||||||
text-align: center;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#chat-tooltip {
|
div#chat-tooltip {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
|
@ -526,19 +502,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button#khoj-banner-submit,
|
div.khoj-empty-container {
|
||||||
input#khoj-banner-email {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid var(--main-text-color);
|
|
||||||
background: #f9fafc;
|
|
||||||
}
|
|
||||||
|
|
||||||
button#khoj-banner-submit:hover,
|
|
||||||
input#khoj-banner-email:hover {
|
|
||||||
box-shadow: 0 0 11px #aaa;
|
|
||||||
}
|
|
||||||
div.khoj-banner-container-hidden {
|
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
@ -558,39 +522,4 @@
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
if ("{{demo}}" === "False") {
|
|
||||||
document.getElementById("khoj-banner-container").classList.remove("khoj-banner-container");
|
|
||||||
document.getElementById("khoj-banner-container").classList.add("khoj-banner-container-hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
var khojBannerSubmit = document.getElementById("khoj-banner-submit");
|
|
||||||
|
|
||||||
khojBannerSubmit?.addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var email = document.getElementById("khoj-banner-email").value;
|
|
||||||
fetch("https://app.khoj.dev/beta/users/", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: email
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(data) {
|
|
||||||
console.log(data);
|
|
||||||
if (data.user != null) {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "Thanks for signing up. We'll be in touch soon! 🚀";
|
|
||||||
document.getElementById("khoj-banner-submit").remove();
|
|
||||||
} else {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
}
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.log(error);
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -10,18 +10,6 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% if demo %}
|
|
||||||
<!-- Banner linking to https://khoj.dev -->
|
|
||||||
<div class="khoj-banner-container">
|
|
||||||
<a class="khoj-banner" href="https://khoj.dev" target="_blank">
|
|
||||||
<p id="khoj-banner" class="khoj-banner">
|
|
||||||
Enroll in Khoj cloud to get your own assistant
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
<input type="text" id="khoj-banner-email" placeholder="email" class="khoj-banner-email"></input>
|
|
||||||
<button id="khoj-banner-submit" class="khoj-banner-button">Submit</button>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="khoj-header"></div>
|
<div class="khoj-header"></div>
|
||||||
|
|
||||||
<!-- Login Modal -->
|
<!-- Login Modal -->
|
||||||
|
@ -106,19 +94,6 @@
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button#khoj-banner-submit,
|
|
||||||
input#khoj-banner-email {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid #475569;
|
|
||||||
background: #f9fafc;
|
|
||||||
}
|
|
||||||
|
|
||||||
button#khoj-banner-submit:hover,
|
|
||||||
input#khoj-banner-email:hover {
|
|
||||||
box-shadow: 0 0 11px #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#login-modal {
|
div#login-modal {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
@ -143,12 +118,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 700px) {
|
@media only screen and (max-width: 700px) {
|
||||||
a.khoj-banner {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
p.khoj-banner {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
div#login-modal {
|
div#login-modal {
|
||||||
margin-left: 10%;
|
margin-left: 10%;
|
||||||
margin-right: 10%;
|
margin-right: 10%;
|
||||||
|
@ -156,34 +125,5 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
var khojBannerSubmit = document.getElementById("khoj-banner-submit");
|
|
||||||
khojBannerSubmit?.addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var email = document.getElementById("khoj-banner-email").value;
|
|
||||||
fetch("https://app.khoj.dev/beta/users/", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: email
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(data) {
|
|
||||||
console.log(data);
|
|
||||||
if (data.user != null) {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "Thanks for signing up. We'll be in touch soon! 🚀";
|
|
||||||
document.getElementById("khoj-banner-submit").remove();
|
|
||||||
} else {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
}
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.log(error);
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script src="https://accounts.google.com/gsi/client" async defer></script>
|
<script src="https://accounts.google.com/gsi/client" async defer></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -270,19 +270,6 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% if demo %}
|
|
||||||
<!-- Banner linking to https://khoj.dev -->
|
|
||||||
<div class="khoj-banner-container">
|
|
||||||
<a class="khoj-banner" href="https://khoj.dev" target="_blank">
|
|
||||||
<p id="khoj-banner" class="khoj-banner">
|
|
||||||
Enroll in Khoj cloud to get your own assistant
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
<input type="text" id="khoj-banner-email" placeholder="email" class="khoj-banner-email"></input>
|
|
||||||
<button id="khoj-banner-submit" class="khoj-banner-button">Submit</button>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!--Add Header Logo and Nav Pane-->
|
<!--Add Header Logo and Nav Pane-->
|
||||||
{% import 'utils.html' as utils %}
|
{% import 'utils.html' as utils %}
|
||||||
{{ utils.heading_pane(user_photo, username) }}
|
{{ utils.heading_pane(user_photo, username) }}
|
||||||
|
@ -458,14 +445,6 @@
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.khoj-banner-container {
|
|
||||||
background: linear-gradient(-45deg, #FFC107, #FF9800, #FF5722, #FF9800, #FFC107);
|
|
||||||
background-size: 400% 400%;
|
|
||||||
animation: gradient 15s ease infinite;
|
|
||||||
text-align: center;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes gradient {
|
@keyframes gradient {
|
||||||
0% {
|
0% {
|
||||||
background-position: 0% 50%;
|
background-position: 0% 50%;
|
||||||
|
@ -482,57 +461,6 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button#khoj-banner-submit,
|
|
||||||
input#khoj-banner-email {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid var(--main-text-color);
|
|
||||||
background: #f9fafc;
|
|
||||||
}
|
|
||||||
|
|
||||||
button#khoj-banner-submit:hover,
|
|
||||||
input#khoj-banner-email:hover {
|
|
||||||
box-shadow: 0 0 11px #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: 700px) {
|
|
||||||
a.khoj-banner {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
p.khoj-banner {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
var khojBannerSubmit = document.getElementById("khoj-banner-submit");
|
|
||||||
khojBannerSubmit?.addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var email = document.getElementById("khoj-banner-email").value;
|
|
||||||
fetch("https://app.khoj.dev/beta/users/", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: email
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(data) {
|
|
||||||
console.log(data);
|
|
||||||
if (data.user != null) {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "Thanks for signing up. We'll be in touch soon! 🚀";
|
|
||||||
document.getElementById("khoj-banner-submit").remove();
|
|
||||||
} else {
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
}
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.log(error);
|
|
||||||
document.getElementById("khoj-banner").innerHTML = "There was an error signing up. Please contact team@khoj.dev";
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -119,7 +119,6 @@ def set_state(args):
|
||||||
state.verbose = args.verbose
|
state.verbose = args.verbose
|
||||||
state.host = args.host
|
state.host = args.host
|
||||||
state.port = args.port
|
state.port = args.port
|
||||||
state.demo = args.demo
|
|
||||||
state.anonymous_mode = args.anonymous_mode
|
state.anonymous_mode = args.anonymous_mode
|
||||||
state.khoj_version = version("khoj-assistant")
|
state.khoj_version = version("khoj-assistant")
|
||||||
state.chat_on_gpu = args.chat_on_gpu
|
state.chat_on_gpu = args.chat_on_gpu
|
||||||
|
|
|
@ -111,183 +111,187 @@ async def map_config_to_db(config: FullConfig, user: KhojUser):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# If it's a demo instance, prevent updating any of the configuration.
|
def _initialize_config():
|
||||||
if not state.demo:
|
if state.config is None:
|
||||||
|
state.config = FullConfig()
|
||||||
|
state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"])
|
||||||
|
|
||||||
def _initialize_config():
|
|
||||||
if state.config is None:
|
|
||||||
state.config = FullConfig()
|
|
||||||
state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"])
|
|
||||||
|
|
||||||
@api.get("/config/data", response_model=FullConfig)
|
@api.get("/config/data", response_model=FullConfig)
|
||||||
@requires(["authenticated"])
|
@requires(["authenticated"])
|
||||||
def get_config_data(request: Request):
|
def get_config_data(request: Request):
|
||||||
user = request.user.object
|
user = request.user.object
|
||||||
EntryAdapters.get_unique_file_types(user)
|
EntryAdapters.get_unique_file_types(user)
|
||||||
|
|
||||||
return state.config
|
return state.config
|
||||||
|
|
||||||
@api.post("/config/data")
|
|
||||||
@requires(["authenticated"])
|
|
||||||
async def set_config_data(
|
|
||||||
request: Request,
|
|
||||||
updated_config: FullConfig,
|
|
||||||
client: Optional[str] = None,
|
|
||||||
):
|
|
||||||
user = request.user.object
|
|
||||||
await map_config_to_db(updated_config, user)
|
|
||||||
|
|
||||||
configuration_update_metadata = {}
|
@api.post("/config/data")
|
||||||
|
@requires(["authenticated"])
|
||||||
|
async def set_config_data(
|
||||||
|
request: Request,
|
||||||
|
updated_config: FullConfig,
|
||||||
|
client: Optional[str] = None,
|
||||||
|
):
|
||||||
|
user = request.user.object
|
||||||
|
await map_config_to_db(updated_config, user)
|
||||||
|
|
||||||
enabled_content = await sync_to_async(EntryAdapters.get_unique_file_types)(user)
|
configuration_update_metadata = {}
|
||||||
|
|
||||||
if state.config.content_type is not None:
|
enabled_content = await sync_to_async(EntryAdapters.get_unique_file_types)(user)
|
||||||
configuration_update_metadata["github"] = "github" in enabled_content
|
|
||||||
configuration_update_metadata["notion"] = "notion" in enabled_content
|
|
||||||
configuration_update_metadata["org"] = "org" in enabled_content
|
|
||||||
configuration_update_metadata["pdf"] = "pdf" in enabled_content
|
|
||||||
configuration_update_metadata["markdown"] = "markdown" in enabled_content
|
|
||||||
|
|
||||||
if state.config.processor is not None:
|
if state.config.content_type is not None:
|
||||||
configuration_update_metadata["conversation_processor"] = state.config.processor.conversation is not None
|
configuration_update_metadata["github"] = "github" in enabled_content
|
||||||
|
configuration_update_metadata["notion"] = "notion" in enabled_content
|
||||||
|
configuration_update_metadata["org"] = "org" in enabled_content
|
||||||
|
configuration_update_metadata["pdf"] = "pdf" in enabled_content
|
||||||
|
configuration_update_metadata["markdown"] = "markdown" in enabled_content
|
||||||
|
|
||||||
update_telemetry_state(
|
if state.config.processor is not None:
|
||||||
request=request,
|
configuration_update_metadata["conversation_processor"] = state.config.processor.conversation is not None
|
||||||
telemetry_type="api",
|
|
||||||
api="set_config",
|
|
||||||
client=client,
|
|
||||||
metadata=configuration_update_metadata,
|
|
||||||
)
|
|
||||||
return state.config
|
|
||||||
|
|
||||||
@api.post("/config/data/content_type/github", status_code=200)
|
update_telemetry_state(
|
||||||
@requires(["authenticated"])
|
request=request,
|
||||||
async def set_content_config_github_data(
|
telemetry_type="api",
|
||||||
request: Request,
|
api="set_config",
|
||||||
updated_config: Union[GithubContentConfig, None],
|
client=client,
|
||||||
client: Optional[str] = None,
|
metadata=configuration_update_metadata,
|
||||||
):
|
)
|
||||||
_initialize_config()
|
return state.config
|
||||||
|
|
||||||
user = request.user.object
|
|
||||||
|
|
||||||
await adapters.set_user_github_config(
|
@api.post("/config/data/content_type/github", status_code=200)
|
||||||
user=user,
|
@requires(["authenticated"])
|
||||||
pat_token=updated_config.pat_token,
|
async def set_content_config_github_data(
|
||||||
repos=updated_config.repos,
|
request: Request,
|
||||||
)
|
updated_config: Union[GithubContentConfig, None],
|
||||||
|
client: Optional[str] = None,
|
||||||
|
):
|
||||||
|
_initialize_config()
|
||||||
|
|
||||||
update_telemetry_state(
|
user = request.user.object
|
||||||
request=request,
|
|
||||||
telemetry_type="api",
|
|
||||||
api="set_content_config",
|
|
||||||
client=client,
|
|
||||||
metadata={"content_type": "github"},
|
|
||||||
)
|
|
||||||
|
|
||||||
return {"status": "ok"}
|
await adapters.set_user_github_config(
|
||||||
|
user=user,
|
||||||
|
pat_token=updated_config.pat_token,
|
||||||
|
repos=updated_config.repos,
|
||||||
|
)
|
||||||
|
|
||||||
@api.post("/config/data/content_type/notion", status_code=200)
|
update_telemetry_state(
|
||||||
@requires(["authenticated"])
|
request=request,
|
||||||
async def set_content_config_notion_data(
|
telemetry_type="api",
|
||||||
request: Request,
|
api="set_content_config",
|
||||||
updated_config: Union[NotionContentConfig, None],
|
client=client,
|
||||||
client: Optional[str] = None,
|
metadata={"content_type": "github"},
|
||||||
):
|
)
|
||||||
_initialize_config()
|
|
||||||
|
|
||||||
user = request.user.object
|
return {"status": "ok"}
|
||||||
|
|
||||||
await adapters.set_notion_config(
|
|
||||||
user=user,
|
|
||||||
token=updated_config.token,
|
|
||||||
)
|
|
||||||
|
|
||||||
update_telemetry_state(
|
@api.post("/config/data/content_type/notion", status_code=200)
|
||||||
request=request,
|
@requires(["authenticated"])
|
||||||
telemetry_type="api",
|
async def set_content_config_notion_data(
|
||||||
api="set_content_config",
|
request: Request,
|
||||||
client=client,
|
updated_config: Union[NotionContentConfig, None],
|
||||||
metadata={"content_type": "notion"},
|
client: Optional[str] = None,
|
||||||
)
|
):
|
||||||
|
_initialize_config()
|
||||||
|
|
||||||
return {"status": "ok"}
|
user = request.user.object
|
||||||
|
|
||||||
@api.post("/delete/config/data/content_type/{content_type}", status_code=200)
|
await adapters.set_notion_config(
|
||||||
@requires(["authenticated"])
|
user=user,
|
||||||
async def remove_content_config_data(
|
token=updated_config.token,
|
||||||
request: Request,
|
)
|
||||||
content_type: str,
|
|
||||||
client: Optional[str] = None,
|
|
||||||
):
|
|
||||||
user = request.user.object
|
|
||||||
|
|
||||||
update_telemetry_state(
|
update_telemetry_state(
|
||||||
request=request,
|
request=request,
|
||||||
telemetry_type="api",
|
telemetry_type="api",
|
||||||
api="delete_content_config",
|
api="set_content_config",
|
||||||
client=client,
|
client=client,
|
||||||
metadata={"content_type": content_type},
|
metadata={"content_type": "notion"},
|
||||||
)
|
)
|
||||||
|
|
||||||
content_object = map_config_to_object(content_type)
|
return {"status": "ok"}
|
||||||
if content_object is None:
|
|
||||||
raise ValueError(f"Invalid content type: {content_type}")
|
|
||||||
|
|
||||||
await content_object.objects.filter(user=user).adelete()
|
|
||||||
await sync_to_async(EntryAdapters.delete_all_entries)(user, content_type)
|
|
||||||
|
|
||||||
enabled_content = await sync_to_async(EntryAdapters.get_unique_file_types)(user)
|
@api.post("/delete/config/data/content_type/{content_type}", status_code=200)
|
||||||
return {"status": "ok"}
|
@requires(["authenticated"])
|
||||||
|
async def remove_content_config_data(
|
||||||
|
request: Request,
|
||||||
|
content_type: str,
|
||||||
|
client: Optional[str] = None,
|
||||||
|
):
|
||||||
|
user = request.user.object
|
||||||
|
|
||||||
@api.post("/config/data/content_type/{content_type}", status_code=200)
|
update_telemetry_state(
|
||||||
@requires(["authenticated"])
|
request=request,
|
||||||
async def set_content_config_data(
|
telemetry_type="api",
|
||||||
request: Request,
|
api="delete_content_config",
|
||||||
content_type: str,
|
client=client,
|
||||||
updated_config: Union[TextContentConfig, None],
|
metadata={"content_type": content_type},
|
||||||
client: Optional[str] = None,
|
)
|
||||||
):
|
|
||||||
_initialize_config()
|
|
||||||
|
|
||||||
user = request.user.object
|
content_object = map_config_to_object(content_type)
|
||||||
|
if content_object is None:
|
||||||
|
raise ValueError(f"Invalid content type: {content_type}")
|
||||||
|
|
||||||
content_object = map_config_to_object(content_type)
|
await content_object.objects.filter(user=user).adelete()
|
||||||
await adapters.set_text_content_config(user, content_object, updated_config)
|
await sync_to_async(EntryAdapters.delete_all_entries)(user, content_type)
|
||||||
|
|
||||||
update_telemetry_state(
|
enabled_content = await sync_to_async(EntryAdapters.get_unique_file_types)(user)
|
||||||
request=request,
|
return {"status": "ok"}
|
||||||
telemetry_type="api",
|
|
||||||
api="set_content_config",
|
|
||||||
client=client,
|
|
||||||
metadata={"content_type": content_type},
|
|
||||||
)
|
|
||||||
|
|
||||||
return {"status": "ok"}
|
|
||||||
|
|
||||||
@api.post("/config/data/conversation/model", status_code=200)
|
@api.post("/config/data/content_type/{content_type}", status_code=200)
|
||||||
@requires(["authenticated"])
|
@requires(["authenticated"])
|
||||||
async def update_chat_model(
|
async def set_content_config_data(
|
||||||
request: Request,
|
request: Request,
|
||||||
id: str,
|
content_type: str,
|
||||||
client: Optional[str] = None,
|
updated_config: Union[TextContentConfig, None],
|
||||||
):
|
client: Optional[str] = None,
|
||||||
user = request.user.object
|
):
|
||||||
|
_initialize_config()
|
||||||
|
|
||||||
new_config = await ConversationAdapters.aset_user_conversation_processor(user, int(id))
|
user = request.user.object
|
||||||
|
|
||||||
update_telemetry_state(
|
content_object = map_config_to_object(content_type)
|
||||||
request=request,
|
await adapters.set_text_content_config(user, content_object, updated_config)
|
||||||
telemetry_type="api",
|
|
||||||
api="set_conversation_chat_model",
|
|
||||||
client=client,
|
|
||||||
metadata={"processor_conversation_type": "conversation"},
|
|
||||||
)
|
|
||||||
|
|
||||||
if new_config is None:
|
update_telemetry_state(
|
||||||
return {"status": "error", "message": "Model not found"}
|
request=request,
|
||||||
|
telemetry_type="api",
|
||||||
|
api="set_content_config",
|
||||||
|
client=client,
|
||||||
|
metadata={"content_type": content_type},
|
||||||
|
)
|
||||||
|
|
||||||
return {"status": "ok"}
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
|
||||||
|
@api.post("/config/data/conversation/model", status_code=200)
|
||||||
|
@requires(["authenticated"])
|
||||||
|
async def update_chat_model(
|
||||||
|
request: Request,
|
||||||
|
id: str,
|
||||||
|
client: Optional[str] = None,
|
||||||
|
):
|
||||||
|
user = request.user.object
|
||||||
|
|
||||||
|
new_config = await ConversationAdapters.aset_user_conversation_processor(user, int(id))
|
||||||
|
|
||||||
|
update_telemetry_state(
|
||||||
|
request=request,
|
||||||
|
telemetry_type="api",
|
||||||
|
api="set_conversation_chat_model",
|
||||||
|
client=client,
|
||||||
|
metadata={"processor_conversation_type": "conversation"},
|
||||||
|
)
|
||||||
|
|
||||||
|
if new_config is None:
|
||||||
|
return {"status": "error", "message": "Model not found"}
|
||||||
|
|
||||||
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
|
||||||
# Create Routes
|
# Create Routes
|
||||||
|
@ -377,6 +381,7 @@ async def search(
|
||||||
SearchType.Github,
|
SearchType.Github,
|
||||||
SearchType.Notion,
|
SearchType.Notion,
|
||||||
SearchType.Plaintext,
|
SearchType.Plaintext,
|
||||||
|
SearchType.Pdf,
|
||||||
]:
|
]:
|
||||||
# query markdown notes
|
# query markdown notes
|
||||||
search_futures += [
|
search_futures += [
|
||||||
|
|
|
@ -38,7 +38,6 @@ def index(request: Request):
|
||||||
"chat.html",
|
"chat.html",
|
||||||
context={
|
context={
|
||||||
"request": request,
|
"request": request,
|
||||||
"demo": state.demo,
|
|
||||||
"username": user.username,
|
"username": user.username,
|
||||||
"user_photo": user_picture,
|
"user_photo": user_picture,
|
||||||
},
|
},
|
||||||
|
@ -55,7 +54,6 @@ def index_post(request: Request):
|
||||||
"chat.html",
|
"chat.html",
|
||||||
context={
|
context={
|
||||||
"request": request,
|
"request": request,
|
||||||
"demo": state.demo,
|
|
||||||
"username": user.username,
|
"username": user.username,
|
||||||
"user_photo": user_picture,
|
"user_photo": user_picture,
|
||||||
},
|
},
|
||||||
|
@ -72,7 +70,6 @@ def search_page(request: Request):
|
||||||
"search.html",
|
"search.html",
|
||||||
context={
|
context={
|
||||||
"request": request,
|
"request": request,
|
||||||
"demo": state.demo,
|
|
||||||
"username": user.username,
|
"username": user.username,
|
||||||
"user_photo": user_picture,
|
"user_photo": user_picture,
|
||||||
},
|
},
|
||||||
|
@ -89,7 +86,6 @@ def chat_page(request: Request):
|
||||||
"chat.html",
|
"chat.html",
|
||||||
context={
|
context={
|
||||||
"request": request,
|
"request": request,
|
||||||
"demo": state.demo,
|
|
||||||
"username": user.username,
|
"username": user.username,
|
||||||
"user_photo": user_picture,
|
"user_photo": user_picture,
|
||||||
},
|
},
|
||||||
|
@ -107,7 +103,6 @@ def login_page(request: Request):
|
||||||
"login.html",
|
"login.html",
|
||||||
context={
|
context={
|
||||||
"request": request,
|
"request": request,
|
||||||
"demo": state.demo,
|
|
||||||
"google_client_id": google_client_id,
|
"google_client_id": google_client_id,
|
||||||
"redirect_uri": redirect_uri,
|
"redirect_uri": redirect_uri,
|
||||||
},
|
},
|
||||||
|
@ -125,142 +120,139 @@ def map_config_to_object(content_type: str):
|
||||||
return LocalPlaintextConfig
|
return LocalPlaintextConfig
|
||||||
|
|
||||||
|
|
||||||
if not state.demo:
|
@web_client.get("/config", response_class=HTMLResponse)
|
||||||
|
@requires(["authenticated"], redirect="login_page")
|
||||||
|
def config_page(request: Request):
|
||||||
|
user = request.user.object
|
||||||
|
user_picture = request.session.get("user", {}).get("picture")
|
||||||
|
enabled_content = set(EntryAdapters.get_unique_file_types(user).all())
|
||||||
|
|
||||||
@web_client.get("/config", response_class=HTMLResponse)
|
successfully_configured = {
|
||||||
@requires(["authenticated"], redirect="login_page")
|
"pdf": ("pdf" in enabled_content),
|
||||||
def config_page(request: Request):
|
"markdown": ("markdown" in enabled_content),
|
||||||
user = request.user.object
|
"org": ("org" in enabled_content),
|
||||||
user_picture = request.session.get("user", {}).get("picture")
|
"image": False,
|
||||||
enabled_content = set(EntryAdapters.get_unique_file_types(user).all())
|
"github": ("github" in enabled_content),
|
||||||
|
"notion": ("notion" in enabled_content),
|
||||||
|
"plaintext": ("plaintext" in enabled_content),
|
||||||
|
}
|
||||||
|
|
||||||
successfully_configured = {
|
if state.content_index:
|
||||||
"pdf": ("pdf" in enabled_content),
|
successfully_configured.update(
|
||||||
"markdown": ("markdown" in enabled_content),
|
{
|
||||||
"org": ("org" in enabled_content),
|
"image": state.content_index.image is not None,
|
||||||
"image": False,
|
}
|
||||||
"github": ("github" in enabled_content),
|
|
||||||
"notion": ("notion" in enabled_content),
|
|
||||||
"plaintext": ("plaintext" in enabled_content),
|
|
||||||
}
|
|
||||||
|
|
||||||
if state.content_index:
|
|
||||||
successfully_configured.update(
|
|
||||||
{
|
|
||||||
"image": state.content_index.image is not None,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
conversation_options = ConversationAdapters.get_conversation_processor_options().all()
|
|
||||||
all_conversation_options = list()
|
|
||||||
for conversation_option in conversation_options:
|
|
||||||
all_conversation_options.append(
|
|
||||||
{"chat_model": conversation_option.chat_model, "id": conversation_option.id}
|
|
||||||
)
|
|
||||||
|
|
||||||
selected_conversation_config = ConversationAdapters.get_conversation_config(user)
|
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
|
||||||
"config.html",
|
|
||||||
context={
|
|
||||||
"request": request,
|
|
||||||
"current_model_state": successfully_configured,
|
|
||||||
"anonymous_mode": state.anonymous_mode,
|
|
||||||
"username": user.username if user else None,
|
|
||||||
"conversation_options": all_conversation_options,
|
|
||||||
"selected_conversation_config": selected_conversation_config.id
|
|
||||||
if selected_conversation_config
|
|
||||||
else None,
|
|
||||||
"user_photo": user_picture,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@web_client.get("/config/content_type/github", response_class=HTMLResponse)
|
conversation_options = ConversationAdapters.get_conversation_processor_options().all()
|
||||||
@requires(["authenticated"], redirect="login_page")
|
all_conversation_options = list()
|
||||||
def github_config_page(request: Request):
|
for conversation_option in conversation_options:
|
||||||
user = request.user.object
|
all_conversation_options.append({"chat_model": conversation_option.chat_model, "id": conversation_option.id})
|
||||||
user_picture = request.session.get("user", {}).get("picture")
|
|
||||||
current_github_config = get_user_github_config(user)
|
|
||||||
|
|
||||||
if current_github_config:
|
selected_conversation_config = ConversationAdapters.get_conversation_config(user)
|
||||||
raw_repos = current_github_config.githubrepoconfig.all()
|
|
||||||
repos = []
|
return templates.TemplateResponse(
|
||||||
for repo in raw_repos:
|
"config.html",
|
||||||
repos.append(
|
context={
|
||||||
GithubRepoConfig(
|
"request": request,
|
||||||
name=repo.name,
|
"current_model_state": successfully_configured,
|
||||||
owner=repo.owner,
|
"anonymous_mode": state.anonymous_mode,
|
||||||
branch=repo.branch,
|
"username": user.username if user else None,
|
||||||
)
|
"conversation_options": all_conversation_options,
|
||||||
|
"selected_conversation_config": selected_conversation_config.id if selected_conversation_config else None,
|
||||||
|
"user_photo": user_picture,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@web_client.get("/config/content_type/github", response_class=HTMLResponse)
|
||||||
|
@requires(["authenticated"], redirect="login_page")
|
||||||
|
def github_config_page(request: Request):
|
||||||
|
user = request.user.object
|
||||||
|
user_picture = request.session.get("user", {}).get("picture")
|
||||||
|
current_github_config = get_user_github_config(user)
|
||||||
|
|
||||||
|
if current_github_config:
|
||||||
|
raw_repos = current_github_config.githubrepoconfig.all()
|
||||||
|
repos = []
|
||||||
|
for repo in raw_repos:
|
||||||
|
repos.append(
|
||||||
|
GithubRepoConfig(
|
||||||
|
name=repo.name,
|
||||||
|
owner=repo.owner,
|
||||||
|
branch=repo.branch,
|
||||||
)
|
)
|
||||||
current_config = GithubContentConfig(
|
|
||||||
pat_token=current_github_config.pat_token,
|
|
||||||
repos=repos,
|
|
||||||
)
|
)
|
||||||
current_config = json.loads(current_config.json())
|
current_config = GithubContentConfig(
|
||||||
else:
|
pat_token=current_github_config.pat_token,
|
||||||
current_config = {} # type: ignore
|
repos=repos,
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
|
||||||
"content_type_github_input.html",
|
|
||||||
context={
|
|
||||||
"request": request,
|
|
||||||
"current_config": current_config,
|
|
||||||
"username": user.username,
|
|
||||||
"user_photo": user_picture,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
@web_client.get("/config/content_type/notion", response_class=HTMLResponse)
|
|
||||||
@requires(["authenticated"], redirect="login_page")
|
|
||||||
def notion_config_page(request: Request):
|
|
||||||
user = request.user.object
|
|
||||||
user_picture = request.session.get("user", {}).get("picture")
|
|
||||||
current_notion_config = get_user_notion_config(user)
|
|
||||||
|
|
||||||
current_config = NotionContentConfig(
|
|
||||||
token=current_notion_config.token if current_notion_config else "",
|
|
||||||
)
|
|
||||||
|
|
||||||
current_config = json.loads(current_config.json())
|
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
|
||||||
"content_type_notion_input.html",
|
|
||||||
context={
|
|
||||||
"request": request,
|
|
||||||
"current_config": current_config,
|
|
||||||
"username": user.username,
|
|
||||||
"user_photo": user_picture,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
@web_client.get("/config/content_type/{content_type}", response_class=HTMLResponse)
|
|
||||||
@requires(["authenticated"], redirect="login_page")
|
|
||||||
def content_config_page(request: Request, content_type: str):
|
|
||||||
if content_type not in VALID_TEXT_CONTENT_TYPES:
|
|
||||||
return templates.TemplateResponse("config.html", context={"request": request})
|
|
||||||
|
|
||||||
object = map_config_to_object(content_type)
|
|
||||||
user = request.user.object
|
|
||||||
user_picture = request.session.get("user", {}).get("picture")
|
|
||||||
config = object.objects.filter(user=user).first()
|
|
||||||
if config == None:
|
|
||||||
config = object.objects.create(user=user)
|
|
||||||
|
|
||||||
current_config = TextContentConfig(
|
|
||||||
input_files=config.input_files,
|
|
||||||
input_filter=config.input_filter,
|
|
||||||
index_heading_entries=config.index_heading_entries,
|
|
||||||
)
|
)
|
||||||
current_config = json.loads(current_config.json())
|
current_config = json.loads(current_config.json())
|
||||||
|
else:
|
||||||
|
current_config = {} # type: ignore
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
"content_type_input.html",
|
"content_type_github_input.html",
|
||||||
context={
|
context={
|
||||||
"request": request,
|
"request": request,
|
||||||
"current_config": current_config,
|
"current_config": current_config,
|
||||||
"content_type": content_type,
|
"username": user.username,
|
||||||
"username": user.username,
|
"user_photo": user_picture,
|
||||||
"user_photo": user_picture,
|
},
|
||||||
},
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
@web_client.get("/config/content_type/notion", response_class=HTMLResponse)
|
||||||
|
@requires(["authenticated"], redirect="login_page")
|
||||||
|
def notion_config_page(request: Request):
|
||||||
|
user = request.user.object
|
||||||
|
user_picture = request.session.get("user", {}).get("picture")
|
||||||
|
current_notion_config = get_user_notion_config(user)
|
||||||
|
|
||||||
|
current_config = NotionContentConfig(
|
||||||
|
token=current_notion_config.token if current_notion_config else "",
|
||||||
|
)
|
||||||
|
|
||||||
|
current_config = json.loads(current_config.json())
|
||||||
|
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
"content_type_notion_input.html",
|
||||||
|
context={
|
||||||
|
"request": request,
|
||||||
|
"current_config": current_config,
|
||||||
|
"username": user.username,
|
||||||
|
"user_photo": user_picture,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@web_client.get("/config/content_type/{content_type}", response_class=HTMLResponse)
|
||||||
|
@requires(["authenticated"], redirect="login_page")
|
||||||
|
def content_config_page(request: Request, content_type: str):
|
||||||
|
if content_type not in VALID_TEXT_CONTENT_TYPES:
|
||||||
|
return templates.TemplateResponse("config.html", context={"request": request})
|
||||||
|
|
||||||
|
object = map_config_to_object(content_type)
|
||||||
|
user = request.user.object
|
||||||
|
user_picture = request.session.get("user", {}).get("picture")
|
||||||
|
config = object.objects.filter(user=user).first()
|
||||||
|
if config == None:
|
||||||
|
config = object.objects.create(user=user)
|
||||||
|
|
||||||
|
current_config = TextContentConfig(
|
||||||
|
input_files=config.input_files,
|
||||||
|
input_filter=config.input_filter,
|
||||||
|
index_heading_entries=config.index_heading_entries,
|
||||||
|
)
|
||||||
|
current_config = json.loads(current_config.json())
|
||||||
|
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
"content_type_input.html",
|
||||||
|
context={
|
||||||
|
"request": request,
|
||||||
|
"current_config": current_config,
|
||||||
|
"content_type": content_type,
|
||||||
|
"username": user.username,
|
||||||
|
"user_photo": user_picture,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
|
@ -42,7 +42,6 @@ def cli(args=None):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--disable-chat-on-gpu", action="store_true", default=False, help="Disable using GPU for the offline chat model"
|
"--disable-chat-on-gpu", action="store_true", default=False, help="Disable using GPU for the offline chat model"
|
||||||
)
|
)
|
||||||
parser.add_argument("--demo", action="store_true", default=False, help="Run Khoj in demo mode")
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--anonymous-mode",
|
"--anonymous-mode",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
|
|
@ -31,7 +31,6 @@ config_lock = threading.Lock()
|
||||||
chat_lock = threading.Lock()
|
chat_lock = threading.Lock()
|
||||||
SearchType = utils_config.SearchType
|
SearchType = utils_config.SearchType
|
||||||
telemetry: List[Dict[str, str]] = []
|
telemetry: List[Dict[str, str]] = []
|
||||||
demo: bool = False
|
|
||||||
khoj_version: str = None
|
khoj_version: str = None
|
||||||
device = get_device()
|
device = get_device()
|
||||||
chat_on_gpu: bool = True
|
chat_on_gpu: bool = True
|
||||||
|
|
Loading…
Reference in a new issue