Refactor.
This commit is contained in:
parent
1b377c9303
commit
1b3200c6da
@ -8,6 +8,6 @@
|
||||
# MIT License
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
import ragent
|
||||
ragent.main()
|
@ -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:")
|
||||
|
@ -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
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
import ragent as agent
|
||||
|
||||
def main(name="Katya", api_key=agent.OPENAI_API_KEY):
|
||||
replika = agent.ReplikaAgent(name=name, api_key=api_key,temperature=0.1)
|
||||
replika = agent.ReplikaAgent(name=name, api_key=api_key, temperature=0.1)
|
||||
try:
|
||||
while True:
|
||||
user_input = input("You: ")
|
||||
@ -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()
|
@ -30,11 +30,7 @@
|
||||
|
||||
from ragent import Agent, OPENAI_API_KEY
|
||||
|
||||
|
||||
def echo(text: str)->str:
|
||||
"""
|
||||
Gives echo of current text
|
||||
"""
|
||||
def echo(text: str) -> str:
|
||||
print("WHAHAHAHA")
|
||||
return text
|
||||
|
||||
@ -43,21 +39,18 @@ class Tools:
|
||||
def __init__(self):
|
||||
self.data = {}
|
||||
|
||||
def remember(self,key, value) -> None:
|
||||
""" Store a value given by user in memory """
|
||||
def remember(self, key, value) -> None:
|
||||
self.data[key] = value
|
||||
print(f"XXXXXXXXX Remembering {key}:{value}")
|
||||
|
||||
def recall(self,key: str) -> str:
|
||||
""" Returns a value requested by user """
|
||||
def recall(self, key: str) -> str:
|
||||
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
|
||||
agent = Agent("You execute tools.","ragent_tools_Example",api_key=api_key,temperature=0.1)
|
||||
agent = Agent("You execute tools.", "ragent_tools_Example", api_key=api_key, temperature=0.1)
|
||||
agent.set_tools(Tools())
|
||||
while True:
|
||||
user_input = input("> ")
|
||||
@ -66,6 +59,5 @@ def main(api_key=None):
|
||||
response = agent.communicate(user_input)
|
||||
print(response)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user