mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Make config API detailed response fields more intuitive, consistent
- Use name, id for every [search|chat|voice|pain]_model_option - Rename current_model_state field to more intuitive enabled_content_source - Update references to the update fields in config.html
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
<h3 id="card-title-computer" class="card-title">
|
<h3 id="card-title-computer" class="card-title">
|
||||||
<span>Files</span>
|
<span>Files</span>
|
||||||
<img id="configured-icon-computer"
|
<img id="configured-icon-computer"
|
||||||
style="display: {% if not current_model_state.computer %}none{% endif %}"
|
style="display: {% if not enabled_content_source.computer %}none{% endif %}"
|
||||||
class="configured-icon"
|
class="configured-icon"
|
||||||
src="/static/assets/icons/confirm-icon.svg"
|
src="/static/assets/icons/confirm-icon.svg"
|
||||||
alt="Configured">
|
alt="Configured">
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-action-row">
|
<div class="card-action-row">
|
||||||
<a class="card-button" href="/configure/content/computer">
|
<a class="card-button" href="/configure/content/computer">
|
||||||
{% if current_model_state.computer %}
|
{% if enabled_content_source.computer %}
|
||||||
Update
|
Update
|
||||||
{% else %}
|
{% else %}
|
||||||
Setup
|
Setup
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
|
||||||
</a>
|
</a>
|
||||||
<div id="clear-computer" class="card-action-row"
|
<div id="clear-computer" class="card-action-row"
|
||||||
style="display: {% if not current_model_state.computer %}none{% endif %}">
|
style="display: {% if not enabled_content_source.computer %}none{% endif %}">
|
||||||
<button class="card-button" onclick="clearContentType('computer')">
|
<button class="card-button" onclick="clearContentType('computer')">
|
||||||
Disable
|
Disable
|
||||||
</button>
|
</button>
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
class="configured-icon"
|
class="configured-icon"
|
||||||
src="/static/assets/icons/confirm-icon.svg"
|
src="/static/assets/icons/confirm-icon.svg"
|
||||||
alt="Configured"
|
alt="Configured"
|
||||||
style="display: {% if not current_model_state.github %}none{% endif %}">
|
style="display: {% if not enabled_content_source.github %}none{% endif %}">
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-description-row">
|
<div class="card-description-row">
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-action-row">
|
<div class="card-action-row">
|
||||||
<a class="card-button" href="/configure/content/github">
|
<a class="card-button" href="/configure/content/github">
|
||||||
{% if current_model_state.github %}
|
{% if enabled_content_source.github %}
|
||||||
Update
|
Update
|
||||||
{% else %}
|
{% else %}
|
||||||
Setup
|
Setup
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<div id="clear-github"
|
<div id="clear-github"
|
||||||
class="card-action-row"
|
class="card-action-row"
|
||||||
style="display: {% if not current_model_state.github %}none{% endif %}">
|
style="display: {% if not enabled_content_source.github %}none{% endif %}">
|
||||||
<button class="card-button" onclick="clearContentType('github')">
|
<button class="card-button" onclick="clearContentType('github')">
|
||||||
Disable
|
Disable
|
||||||
</button>
|
</button>
|
||||||
@@ -102,14 +102,14 @@
|
|||||||
class="configured-icon"
|
class="configured-icon"
|
||||||
src="/static/assets/icons/confirm-icon.svg"
|
src="/static/assets/icons/confirm-icon.svg"
|
||||||
alt="Configured"
|
alt="Configured"
|
||||||
style="display: {% if not current_model_state.notion %}none{% endif %}">
|
style="display: {% if not enabled_content_source.notion %}none{% endif %}">
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-description-row">
|
<div class="card-description-row">
|
||||||
<p class="card-description">Sync your Notion pages</p>
|
<p class="card-description">Sync your Notion pages</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action-row">
|
<div class="card-action-row">
|
||||||
{% if current_model_state.notion %}
|
{% if enabled_content_source.notion %}
|
||||||
<a class="card-button" href="/configure/content/notion">
|
<a class="card-button" href="/configure/content/notion">
|
||||||
Update
|
Update
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
|
|
||||||
<div id="clear-notion"
|
<div id="clear-notion"
|
||||||
class="card-action-row"
|
class="card-action-row"
|
||||||
style="display: {% if not current_model_state.notion %}none{% endif %}">
|
style="display: {% if not enabled_content_source.notion %}none{% endif %}">
|
||||||
<button class="card-button" onclick="clearContentType('notion')">
|
<button class="card-button" onclick="clearContentType('notion')">
|
||||||
Disable
|
Disable
|
||||||
</button>
|
</button>
|
||||||
@@ -181,8 +181,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-description-row">
|
<div class="card-description-row">
|
||||||
<select id="chat-models">
|
<select id="chat-models">
|
||||||
{% for option in conversation_options %}
|
{% for option in chat_model_options %}
|
||||||
<option value="{{ option.id }}" {% if option.id == selected_conversation_config %}selected{% endif %}>{{ option.chat_model }}</option>
|
<option value="{{ option.id }}" {% if option.id == selected_chat_model_config %}selected{% endif %}>{{ option.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -208,7 +208,7 @@
|
|||||||
<div class="card-description-row">
|
<div class="card-description-row">
|
||||||
<select id="paint-models">
|
<select id="paint-models">
|
||||||
{% for option in paint_model_options %}
|
{% for option in paint_model_options %}
|
||||||
<option value="{{ option.id }}" {% if option.id == selected_paint_model_config %}selected{% endif %}>{{ option.model_name }}</option>
|
<option value="{{ option.id }}" {% if option.id == selected_paint_model_config %}selected{% endif %}>{{ option.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1230,18 +1230,18 @@ def get_user_config(user: KhojUser, request: Request, is_detailed: bool = False)
|
|||||||
)
|
)
|
||||||
given_name = get_user_name(user)
|
given_name = get_user_name(user)
|
||||||
|
|
||||||
enabled_content_source = set(EntryAdapters.get_unique_file_sources(user))
|
enabled_content_sources_set = set(EntryAdapters.get_unique_file_sources(user))
|
||||||
successfully_configured = {
|
enabled_content_sources = {
|
||||||
"computer": ("computer" in enabled_content_source),
|
"computer": ("computer" in enabled_content_sources_set),
|
||||||
"github": ("github" in enabled_content_source),
|
"github": ("github" in enabled_content_sources_set),
|
||||||
"notion": ("notion" in enabled_content_source),
|
"notion": ("notion" in enabled_content_sources_set),
|
||||||
}
|
}
|
||||||
|
|
||||||
selected_conversation_config = ConversationAdapters.get_conversation_config(user)
|
selected_chat_model_config = ConversationAdapters.get_conversation_config(user)
|
||||||
conversation_options = ConversationAdapters.get_conversation_processor_options().all()
|
chat_models = ConversationAdapters.get_conversation_processor_options().all()
|
||||||
all_conversation_options = list()
|
chat_model_options = list()
|
||||||
for conversation_option in conversation_options:
|
for chat_model in chat_models:
|
||||||
all_conversation_options.append({"chat_model": conversation_option.chat_model, "id": conversation_option.id})
|
chat_model_options.append({"name": chat_model.chat_model, "id": chat_model.id})
|
||||||
|
|
||||||
search_model_options = adapters.get_or_create_search_models().all()
|
search_model_options = adapters.get_or_create_search_models().all()
|
||||||
all_search_model_options = list()
|
all_search_model_options = list()
|
||||||
@@ -1254,7 +1254,7 @@ def get_user_config(user: KhojUser, request: Request, is_detailed: bool = False)
|
|||||||
paint_model_options = ConversationAdapters.get_text_to_image_model_options().all()
|
paint_model_options = ConversationAdapters.get_text_to_image_model_options().all()
|
||||||
all_paint_model_options = list()
|
all_paint_model_options = list()
|
||||||
for paint_model in paint_model_options:
|
for paint_model in paint_model_options:
|
||||||
all_paint_model_options.append({"model_name": paint_model.model_name, "id": paint_model.id})
|
all_paint_model_options.append({"name": paint_model.model_name, "id": paint_model.id})
|
||||||
|
|
||||||
notion_oauth_url = get_notion_auth_url(user)
|
notion_oauth_url = get_notion_auth_url(user)
|
||||||
|
|
||||||
@@ -1277,13 +1277,13 @@ def get_user_config(user: KhojUser, request: Request, is_detailed: bool = False)
|
|||||||
"is_active": is_active,
|
"is_active": is_active,
|
||||||
"has_documents": has_documents,
|
"has_documents": has_documents,
|
||||||
"khoj_version": state.khoj_version,
|
"khoj_version": state.khoj_version,
|
||||||
"current_model_state": successfully_configured,
|
"enabled_content_source": enabled_content_sources,
|
||||||
"anonymous_mode": state.anonymous_mode,
|
"anonymous_mode": state.anonymous_mode,
|
||||||
"given_name": given_name,
|
"given_name": given_name,
|
||||||
"search_model_options": all_search_model_options,
|
"search_model_options": all_search_model_options,
|
||||||
"selected_search_model_config": current_search_model_option.id,
|
"selected_search_model_config": current_search_model_option.id,
|
||||||
"conversation_options": all_conversation_options,
|
"chat_model_options": chat_model_options,
|
||||||
"selected_conversation_config": selected_conversation_config.id if selected_conversation_config else None,
|
"selected_chat_model_config": selected_chat_model_config.id if selected_chat_model_config else None,
|
||||||
"paint_model_options": all_paint_model_options,
|
"paint_model_options": all_paint_model_options,
|
||||||
"selected_paint_model_config": selected_paint_model_config.id if selected_paint_model_config else None,
|
"selected_paint_model_config": selected_paint_model_config.id if selected_paint_model_config else None,
|
||||||
"user_photo": user_picture,
|
"user_photo": user_picture,
|
||||||
|
|||||||
Reference in New Issue
Block a user