Skip to content

Commit 839a9c7

Browse files
authored
Update main.py
1 parent 6bd5192 commit 839a9c7

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

waifu/main.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def __init__(self, discord_sender):
4545
# Initialize memory to store context
4646
self.memory = []
4747

48-
async def handle_command(self, command, args):
48+
async def handle_command(self, command, args, author):
4949
if command in self.handlers:
50-
await self.handlers[command](args)
50+
await self.handlers[command](args, author)
5151
else:
5252
self.discord_sender.send_tagged_message("unknown_command", command)
5353

54-
async def handle_anime(self, args):
54+
async def handle_anime(self, args, author):
5555
if args:
5656
anime_details = self.anilist_handler.get_anime_details(args)
5757
if isinstance(anime_details, dict):
@@ -66,35 +66,40 @@ async def handle_anime(self, args):
6666
else:
6767
self.discord_sender.send_tagged_message("anime_info", "No anime name provided.")
6868

69-
async def handle_manga(self, args):
69+
async def handle_manga(self, args, author):
7070
if args:
7171
manga_description = self.anilist_handler.get_manga_description(args)
7272
self.discord_sender.send_tagged_message("manga_info", manga_description)
7373
else:
7474
self.discord_sender.send_tagged_message("manga_info", "No manga name provided.")
7575

76-
async def handle_character(self, args):
76+
async def handle_character(self, args, author):
7777
if args:
7878
character_description = self.anilist_handler.get_character_description(args)
7979
self.discord_sender.send_tagged_message("character_info", character_description)
8080
else:
8181
self.discord_sender.send_tagged_message("character_info", "No character name provided.")
8282

83-
async def handle_rina(self, args):
83+
async def handle_rina(self, args, author):
8484
if args:
85-
# Use OpenAI API to generate a response based on user input
85+
#send the personality to it in the beginning
86+
if not self.memory: # Check if the memory is empty (conversation is just starting)
87+
intro_message = "can you act like a anime girl with like a cute personality or hard one idk but like something along that line from next text on? noo no emotional thing into it just a text pls lol"
88+
self.memory.append({"role": "assistant", "content": intro_message})
89+
90+
user_message = f"User ({author}): {args}" # Include the author's username
8691
completion = self.client.chat.completions.create(
8792
model="meta-llama/llama-3.2-11b-vision-instruct:free",
88-
messages=self.memory + [{"role": "user", "content": args}] # Append context to memory
93+
messages=self.memory + [{"role": "user", "content": user_message}] # Append context to memory
8994
)
90-
response = completion.choices[0].message.content # Get the response
91-
self.memory.append({"role": "user", "content": args}) # Save user input to memory
95+
response = completion.choices[0].message.content # response
96+
self.memory.append({"role": "user", "content": user_message}) # Save user memory
9297
self.memory.append({"role": "assistant", "content": response}) # Save AI response to memory
9398
self.discord_sender.send_tagged_message("rina_response", response)
9499
else:
95100
self.discord_sender.send_tagged_message("rina_response", "No input provided.")
96101

97-
async def handle_rec(self, args):
102+
async def handle_rec(self, args, author):
98103
if args:
99104
rec = self.handle_rec.get_similar_anime(args)
100105
if rec:
@@ -227,7 +232,7 @@ async def event_loop(ws):
227232
command = command_parts[0].strip().lower()
228233
args = ""
229234

230-
await command_handler.handle_command(command, args)
235+
await command_handler.handle_command(command, args, author)
231236

232237
if content.strip():
233238
command_parts = content.split(' ', 1)

0 commit comments

Comments
 (0)