import random | |
import json | |
class DialogueEngine: | |
def __init__(self, persona, templates): | |
self.persona = persona | |
self.templates = templates | |
self.history = [] | |
def respond(self, user_input): | |
self.history.append(user_input) | |
response = random.choice(self.templates["poetic"]) + "。" | |
support = random.choice(self.templates["support"]) | |
return f"{self.persona['name']}:{response} {support}" | |