Skip to content

Commit

Permalink
fix ollama bug (#999)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
KevinHuSh committed May 30, 2024
1 parent c3c2515 commit 83803a7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/db/services/dialog_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ def count():
if c < max_length:
return c, msg

ll = num_tokens_from_string(msg_[0].content)
l = num_tokens_from_string(msg_[-1].content)
ll = num_tokens_from_string(msg_[0]["content"])
l = num_tokens_from_string(msg_[-1]["content"])
if ll / (ll + l) > 0.8:
m = msg_[0].content
m = msg_[0]["content"]
m = encoder.decode(encoder.encode(m)[:max_length - l])
msg[0].content = m
msg[0]["content"] = m
return max_length, msg

m = msg_[1].content
m = msg_[1]["content"]
m = encoder.decode(encoder.encode(m)[:max_length - l])
msg[1].content = m
msg[1]["content"] = m
return max_length, msg


Expand Down

0 comments on commit 83803a7

Please sign in to comment.