mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Use default values, delete content config on disable and update state
This commit is contained in:
parent
362063f5fe
commit
0a86220d42
5 changed files with 26 additions and 12 deletions
|
@ -138,7 +138,6 @@ export class KhojChatModal extends Modal {
|
|||
return `${time_string}, ${date_string}`;
|
||||
}
|
||||
|
||||
|
||||
async getChatHistory(): Promise<void> {
|
||||
// Get chat history from Khoj backend
|
||||
let chatUrl = `${this.setting.khojUrl}/api/chat/init?client=obsidian`;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
function chat() {
|
||||
// Extract required fields for search from form
|
||||
let query = document.getElementById("chat-input").value.trim();
|
||||
let results_count = localStorage.getItem("khojResultsCount");
|
||||
let results_count = localStorage.getItem("khojResultsCount") || 5;
|
||||
console.log(`Query: ${query}`);
|
||||
|
||||
// Short circuit on empty query
|
||||
|
@ -93,14 +93,17 @@
|
|||
|
||||
// Decode message chunk from stream
|
||||
const chunk = decoder.decode(value, { stream: true });
|
||||
if (chunk.startsWith("### compiled references:")) {
|
||||
// Display references used to generate response
|
||||
const rawReferences = chunk.split("### compiled references:")[1];
|
||||
const rawReferencesAsJson = JSON.parse(rawReferences);
|
||||
let polishedReferences = rawReferencesAsJson
|
||||
.map((reference, index) => generateReference(reference, index))
|
||||
if (chunk.includes("### compiled references:")) {
|
||||
const additionalResponse = chunk.split("### compiled references:")[0];
|
||||
new_response_text.innerHTML += additionalResponse;
|
||||
|
||||
const rawReference = chunk.split("### compiled references:")[1];
|
||||
const rawReferenceAsJson = JSON.parse(rawReference);
|
||||
let polishedReference = rawReferenceAsJson.map((reference, index) => generateReference(reference, index))
|
||||
.join("<sup>,</sup>");
|
||||
new_response_text.innerHTML += polishedReferences;
|
||||
|
||||
new_response_text.innerHTML += polishedReference;
|
||||
document.getElementById("chat-body").scrollTop = document.getElementById("chat-body").scrollHeight;
|
||||
} else {
|
||||
// Display response from Khoj
|
||||
if (new_response_text.innerHTML === "🤔") {
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
query = document.getElementById("query").value.trim();
|
||||
type = document.getElementById("type").value;
|
||||
searchHint = document.getElementById("info-hint");
|
||||
results_count = localStorage.getItem("khojResultsCount");
|
||||
results_count = localStorage.getItem("khojResultsCount") || 5;
|
||||
console.log(`Query: ${query}, Type: ${type}, Results Count: ${results_count}`);
|
||||
|
||||
// Short circuit on empty query
|
||||
|
|
|
@ -104,8 +104,8 @@ class PdfToJsonl(TextToJsonl):
|
|||
entry_to_location_map += zip(pdf_entries_per_file, [pdf_file] * len(pdf_entries_per_file))
|
||||
entries.extend(pdf_entries_per_file)
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing file: {pdf_file}. This file will not be indexed.")
|
||||
logger.error(e)
|
||||
logger.warning(f"Unable to process file: {pdf_file}. This file will not be indexed.")
|
||||
logger.warning(e)
|
||||
|
||||
return entries, dict(entry_to_location_map)
|
||||
|
||||
|
|
|
@ -81,6 +81,17 @@ if not state.demo:
|
|||
if state.config.content_type:
|
||||
state.config.content_type[content_type] = None
|
||||
|
||||
if content_type == "github":
|
||||
state.model.github_search = None
|
||||
elif content_type == "plugins":
|
||||
state.model.plugin_search = None
|
||||
elif content_type == "pdf":
|
||||
state.model.pdf_search = None
|
||||
elif content_type == "markdown":
|
||||
state.model.markdown_search = None
|
||||
elif content_type == "org":
|
||||
state.model.org_search = None
|
||||
|
||||
try:
|
||||
save_config_to_file_updated_state()
|
||||
return {"status": "ok"}
|
||||
|
@ -123,6 +134,7 @@ if not state.demo:
|
|||
state.config = FullConfig()
|
||||
state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"])
|
||||
state.config.processor = ProcessorConfig(conversation=updated_config)
|
||||
state.processor_config = configure_processor(state.config.processor)
|
||||
try:
|
||||
save_config_to_file_updated_state()
|
||||
return {"status": "ok"}
|
||||
|
|
Loading…
Reference in a new issue