Skip to content

Commit

Permalink
✨ feat(playground): Add random_prompt method to RandomPromptGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoskys committed Feb 7, 2024
1 parent b3e31d2 commit ef4c96a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ loop.run_until_complete(main())
```python
from novelai_python.utils.random_prompt import RandomPromptGenerator

s = RandomPromptGenerator(nsfw_enabled=False).generate()
s = RandomPromptGenerator(nsfw_enabled=False).random_prompt()
print(s)
```

Expand Down
2 changes: 1 addition & 1 deletion playground/random_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
print(gen.get_weighted_choice([['m', 30], ['f', 50], ['o', 10]], ['m']))
print("====")
for i in range(200):
s = RandomPromptGenerator(nsfw_enabled=True).generate()
s = RandomPromptGenerator(nsfw_enabled=True).random_prompt()
print(s)
7 changes: 6 additions & 1 deletion src/novelai_python/utils/random_prompt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,21 @@ def random_prompt(self, *,
enable_moods: bool = True,
enable_character: bool = True,
enable_identity: bool = False,
must_appear=None,
):
if must_appear is None:
must_appear = []
tags = []
# 必须出现的标签
tags.extend(must_appear)
if self.nsfw_enabled:
tags.append('nsfw')
if random.random() < 0.1:
tags.append('explicit')
tags.append('lewd')
irs = self.get_weighted_choice([[1, 70], [2, 20], [3, 7], [0, 5]], tags)
if self.nsfw_enabled:
irs = self.get_weighted_choice([[1, 35], [2, 20], [3, 7]], tags)
irs = self.get_weighted_choice([[1, 40], [2, 20], [3, 7]], tags)
if irs == 0:
tags.append('no humans')
if random.random() < 0.3:
Expand Down

0 comments on commit ef4c96a

Please sign in to comment.