Rename selected voice model in get config API response for consistency

- Update references in new and old web client settings
- Arrange new client settings props and add header comments similar to
- config response for code readability
This commit is contained in:
Debanjum Singh Solanky
2024-07-17 17:12:26 +05:30
parent b3253562a5
commit ade2f6f5d1
3 changed files with 18 additions and 13 deletions

View File

@@ -34,30 +34,34 @@ export interface SyncedContent {
notion: boolean;
}
export interface UserConfig {
// user info
username: string | null;
user_photo: string | null;
is_active: boolean;
has_documents: boolean;
khoj_version: string;
enabled_content_source: SyncedContent;
anonymous_mode: boolean;
given_name: string;
phone_number: string;
is_phone_number_verified: boolean;
// user content, model settings
enabled_content_source: SyncedContent;
has_documents: boolean;
search_model_options: ModelOptions[];
selected_search_model_config: number;
chat_model_options: ModelOptions[];
selected_chat_model_config: number;
paint_model_options: ModelOptions[];
selected_paint_model_config: number;
billing_enabled: boolean;
voice_model_options: ModelOptions[];
selected_voice_model_config: number;
// user billing info
subscription_state: string;
subscription_renewal_date: string;
// server settings
khoj_cloud_subscription_url: string | undefined;
is_twilio_enabled: boolean;
billing_enabled: boolean;
is_eleven_labs_enabled: boolean;
voice_model_options: ModelOptions[];
selected_voice_config: number;
phone_number: string;
is_phone_number_verified: boolean;
is_twilio_enabled: boolean;
khoj_version: string;
anonymous_mode: boolean;
notion_oauth_url: string;
detail: string;
}
@@ -68,6 +72,7 @@ export function useUserConfig(detailed: boolean = false) {
const { data, error } = useSWR<UserConfig>(url, fetcher, { revalidateOnFocus: false });
if (error || !data || data.detail === 'Forbidden') return null;
console.log(data);
return data;
}

View File

@@ -235,7 +235,7 @@
<div class="card-description-row">
<select id="voice-models">
{% for option in voice_model_options %}
<option value="{{ option.id }}" {% if option.id == selected_voice_config %}selected{% endif %}>{{ option.name }}</option>
<option value="{{ option.id }}" {% if option.id == selected_voice_model_config %}selected{% endif %}>{{ option.name }}</option>
{% endfor %}
</select>
</div>

View File

@@ -1285,7 +1285,7 @@ def get_user_config(user: KhojUser, request: Request, is_detailed: bool = False)
if len(voice_model_options) == 0:
eleven_labs_enabled = False
selected_voice_config = ConversationAdapters.get_voice_model_config(user)
selected_voice_model_config = ConversationAdapters.get_voice_model_config(user)
return {
"request": request,
@@ -1306,7 +1306,7 @@ def get_user_config(user: KhojUser, request: Request, is_detailed: bool = False)
"paint_model_options": all_paint_model_options,
"selected_paint_model_config": selected_paint_model_config.id if selected_paint_model_config else None,
"voice_model_options": voice_model_options,
"selected_voice_config": selected_voice_config.model_id if selected_voice_config else None,
"selected_voice_model_config": selected_voice_model_config.model_id if selected_voice_model_config else None,
# user billing info
"subscription_state": user_subscription_state,
"subscription_renewal_date": subscription_renewal_date,