Spaces:
Runtime error
Runtime error
File size: 1,084 Bytes
4ecdaad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from Prompt import *
class Memory:
def __init__(self,role,name,content) -> None:
self.send_role = role
self.send_name = name
self.content = content
def get_gpt_message(self,role):
return {"role":role,"content":self.content}
@classmethod
def get_chat_history(self,messages,agent_name =None):
"""
Splice a memory list into a sentence
input :
messages(list) : list of memory(Memory)
Return :
chat_history(str) : One sentence after integration
"""
chat_history = ""
for message in messages:
name,role,content = message.send_name,message.send_role,message.content
if agent_name and agent_name==name:
name = "you"
chat_history += eval(Single_message)
chat_history = eval(Chat_total_message)
return chat_history
def get_query(self):
"Return : query(str):last sentence"
name,role,content = self.send_name,self.send_role,self.content
return eval(Single_message) |