mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Check if n is populated before making a comparison
This commit is contained in:
parent
6707ccc463
commit
adb2e8cc5f
1 changed files with 7 additions and 6 deletions
|
@ -110,12 +110,13 @@ def chat_history(
|
|||
}
|
||||
)
|
||||
|
||||
# Get latest N messages if N > 0
|
||||
if n > 0 and meta_log.get("chat"):
|
||||
meta_log["chat"] = meta_log["chat"][-n:]
|
||||
# Else return all messages except latest N
|
||||
elif n < 0 and meta_log.get("chat"):
|
||||
meta_log["chat"] = meta_log["chat"][:n]
|
||||
if n:
|
||||
# Get latest N messages if N > 0
|
||||
if n > 0 and meta_log.get("chat"):
|
||||
meta_log["chat"] = meta_log["chat"][-n:]
|
||||
# Else return all messages except latest N
|
||||
elif n < 0 and meta_log.get("chat"):
|
||||
meta_log["chat"] = meta_log["chat"][:n]
|
||||
|
||||
update_telemetry_state(
|
||||
request=request,
|
||||
|
|
Loading…
Add table
Reference in a new issue