Skip to content

Commit

Permalink
Catch case where chain cannot be built from content
Browse files Browse the repository at this point in the history
  • Loading branch information
Fingel committed Jan 9, 2025
1 parent 6dd49de commit 28b20f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "django-llm-poison"
version = "0.2.0"
version = "0.2.1"
description = "Add your description here"
readme = "README.md"
authors = [{ name = "Austin Riba", email = "austin@m51.io" }]
Expand Down
5 changes: 4 additions & 1 deletion src/django_llm_poison/markov.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def build_model_for_content(value: str):
hash = hashlib.sha1(value.encode()).hexdigest()
stripped = strip_tags(value)
if not MarkovModel.objects.filter(hash=hash).exists():
model = markovify.Text(stripped)
try:
model = markovify.Text(stripped)
except Exception:
return None
markov_model = MarkovModel.objects.create(hash=hash, text=model.to_json())
cache.delete("combined_model")
return markov_model
Expand Down

0 comments on commit 28b20f5

Please sign in to comment.