Refactor.

This commit is contained in:
retoor 2025-02-24 14:43:29 +01:00
parent 1b377c9303
commit 1b3200c6da
5 changed files with 16 additions and 24 deletions

View File

@ -8,6 +8,6 @@
# MIT License
if __name__ == '__main__':
if __name__ == "__main__":
import ragent
ragent.main()

View File

@ -6,6 +6,7 @@
# MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
import ragent
import json
@ -22,8 +23,8 @@ def main():
]
print(agent.communicate(message_batch))
response = agent.communicate(
"What is the apples divided by the oranges "
"and what is your name btw?"
"What are the apples divided by the oranges "
"and what is your name by the way?"
)
print("Response:", response)
print("Transcript:")

View File

@ -1,10 +1,10 @@
# Written by retoor@molodetz.nl
# This script simulates a conversation between Hermione Granger and Draco Malfoy from the Harry Potter world. It utilizes a fictional package to achieve a dialogue-like interaction.
# This script simulates a conversation between Hermione Granger and Draco Malfoy from the Harry Potter world using a fictional package to create a dialogue-like interaction.
# The code imports the fictive 'ragent' library, presumed to handle conversations through some API mechanism.
# The code imports the fictive 'ragent' library, which is presumed to handle conversations through some API mechanism.
# MIT License
@ -33,8 +33,7 @@ import ragent as agent
def main(api_key=None):
if api_key is None:
api_key = agent.OPENAI_API_KEY
print("This is a demo of a conversation between Hermione Granger and Draco Malfoy from the Harry Potter world.")
print()
print("This is a demo of a conversation between Hermione Granger and Draco Malfoy from the Harry Potter world.\n")
message_count = 0

View File

@ -26,8 +26,8 @@ if __name__ == "__main__":
name = 'Katya'
print(f"This is a demo of a Replika with the name '{name}'")
print(f"{name} is very social and engaging.")
print("It's your AI companion but way cheaper than the real Replika!")
print("It's your AI companion but much cheaper than the real Replika!")
print("Besides talking like Replika, it isn't a goldfish like Replika. It remembers everything you say.")
print("Give Replika two apples and ask how many apples it got. It will answer the right amount.")
print("Give Replika two apples and ask how many apples it got. It will answer the correct amount.")
print("Ask her to repeat what it said before. It will repeat that.")
main()

View File

@ -30,11 +30,7 @@
from ragent import Agent, OPENAI_API_KEY
def echo(text: str) -> str:
"""
Gives echo of current text
"""
print("WHAHAHAHA")
return text
@ -44,16 +40,13 @@ class Tools:
self.data = {}
def remember(self, key, value) -> None:
""" Store a value given by user in memory """
self.data[key] = value
print(f"XXXXXXXXX Remembering {key}:{value}")
def recall(self, key: str) -> str:
""" Returns a value requested by user """
print(f"XXXXXXXX Recalling {key}")
return self.data.get(key)
def main(api_key=None):
if api_key is None:
api_key = OPENAI_API_KEY
@ -66,6 +59,5 @@ def main(api_key=None):
response = agent.communicate(user_input)
print(response)
if __name__ == '__main__':
main()