mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +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 = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
"Personal info",
|
"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
|
) + UserAdmin.fieldsets
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,10 @@ def completion_with_backoff(
|
|||||||
# Calculate cost of chat
|
# Calculate cost of chat
|
||||||
input_tokens = chunk.usage.prompt_tokens if hasattr(chunk, "usage") and chunk.usage else 0
|
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
|
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)
|
tracer["usage"] = get_chat_usage_metrics(model_name, input_tokens, output_tokens, tracer.get("usage"), cost)
|
||||||
|
|
||||||
# Save conversation trace
|
# Save conversation trace
|
||||||
@@ -215,7 +218,9 @@ def llm_thread(
|
|||||||
# Calculate cost of chat
|
# Calculate cost of chat
|
||||||
input_tokens = chunk.usage.prompt_tokens if hasattr(chunk, "usage") and chunk.usage else 0
|
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
|
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)
|
tracer["usage"] = get_chat_usage_metrics(model_name, input_tokens, output_tokens, tracer.get("usage"), cost)
|
||||||
|
|
||||||
# Save conversation trace
|
# Save conversation trace
|
||||||
|
|||||||
Reference in New Issue
Block a user