Skip to content

Commit

Permalink
feat: unstable llama example
Browse files Browse the repository at this point in the history
  • Loading branch information
av committed Sep 25, 2024
1 parent 41da732 commit e7d7ac1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions boost/src/chat_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def parents(self):

return parents[::-1]

def ancestor(self):
node = self
while node.parent:
node = node.parent
return node

def history(self):
node = self
messages = [{
Expand Down
42 changes: 42 additions & 0 deletions boost/src/custom_modules/unstable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ID_PREFIX = "unstable"

import chat as ch
import llm
import random

extreme_traits = [
"Eccentric", "Obsessive", "Impulsive", "Paranoid", "Narcissistic",
"Perfectionist", "Overly Sensitive", "Extremely Independent", "Manipulative",
"Aloof"
]

temperaments = ["Choleric", "Melancholic", "Phlegmatic", "Sanguine"]

reply_styles = [
"Blunt", "Sarcastic", "Overly Polite", "Evading", "Confrontational"
]


# Function to generate a random personality description
def random_personality():
selected_traits = random.sample(extreme_traits, 3)
selected_temperament = random.choice(temperaments)
selected_reply_style = random.choice(reply_styles)

description = (
f"You are {', '.join(selected_traits)}. "
f"You are known for yout {selected_temperament} temperament."
f"You tend to write your replies in a {selected_reply_style} manner."
f"Ensure that you reply to the User accordingly."
)

return description


async def apply(chat: 'ch.Chat', llm: 'llm.LLM'):
personality = random_personality()
chat.tail.ancestor().add_parent(
ch.ChatNode(role="system", content=personality)
)

await llm.stream_final_completion()

0 comments on commit e7d7ac1

Please sign in to comment.