mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Update formatting in admin.py and utils.py
This commit is contained in:
@@ -136,7 +136,15 @@ class KhojUserAdmin(UserAdmin, unfold_admin.ModelAdmin):
|
||||
fieldsets = (
|
||||
(
|
||||
"Personal info",
|
||||
{"fields": ("phone_number", "email_verification_code", "verified_phone_number", "verified_email","email_verification_code_expiry")},
|
||||
{
|
||||
"fields": (
|
||||
"phone_number",
|
||||
"email_verification_code",
|
||||
"verified_phone_number",
|
||||
"verified_email",
|
||||
"email_verification_code_expiry",
|
||||
)
|
||||
},
|
||||
),
|
||||
) + UserAdmin.fieldsets
|
||||
|
||||
|
||||
@@ -100,7 +100,10 @@ def completion_with_backoff(
|
||||
# Calculate cost of chat
|
||||
input_tokens = chunk.usage.prompt_tokens if hasattr(chunk, "usage") and chunk.usage else 0
|
||||
output_tokens = chunk.usage.completion_tokens if hasattr(chunk, "usage") and chunk.usage else 0
|
||||
cost = chunk.usage.model_extra.get("estimated_cost", 0) if hasattr(chunk, "usage") and chunk.usage else 0 # Estimated costs returned by DeepInfra API
|
||||
cost = (
|
||||
chunk.usage.model_extra.get("estimated_cost", 0) if hasattr(chunk, "usage") and chunk.usage else 0
|
||||
) # Estimated costs returned by DeepInfra API
|
||||
|
||||
tracer["usage"] = get_chat_usage_metrics(model_name, input_tokens, output_tokens, tracer.get("usage"), cost)
|
||||
|
||||
# Save conversation trace
|
||||
@@ -215,7 +218,9 @@ def llm_thread(
|
||||
# Calculate cost of chat
|
||||
input_tokens = chunk.usage.prompt_tokens if hasattr(chunk, "usage") and chunk.usage else 0
|
||||
output_tokens = chunk.usage.completion_tokens if hasattr(chunk, "usage") and chunk.usage else 0
|
||||
cost = chunk.usage.model_extra.get("estimated_cost", 0) if hasattr(chunk, "usage") and chunk.usage else 0 # Estimated costs returned by DeepInfra API
|
||||
cost = (
|
||||
chunk.usage.model_extra.get("estimated_cost", 0) if hasattr(chunk, "usage") and chunk.usage else 0
|
||||
) # Estimated costs returned by DeepInfra API
|
||||
tracer["usage"] = get_chat_usage_metrics(model_name, input_tokens, output_tokens, tracer.get("usage"), cost)
|
||||
|
||||
# Save conversation trace
|
||||
|
||||
Reference in New Issue
Block a user