This commit is contained in:
s495727 2024-06-10 18:20:11 +02:00
parent f7ee0ba059
commit 4620e53229
3 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,6 @@ from service.dialog_policy import DialogPolicy
from service.natural_languag_understanding import NaturalLanguageUnderstanding from service.natural_languag_understanding import NaturalLanguageUnderstanding
from service.natural_language_generation import NaturalLanguageGeneration, parse_frame from service.natural_language_generation import NaturalLanguageGeneration, parse_frame
from service.templates import templates from service.templates import templates
from convlab.dialog_agent import PipelineAgent
# initialize classes # initialize classes
nlu = NaturalLanguageUnderstanding() # NLU nlu = NaturalLanguageUnderstanding() # NLU
@ -32,6 +31,7 @@ while True:
# DP # DP
system_action = dialog_policy.predict(monitor) system_action = dialog_policy.predict(monitor)
print("System action: ", system_action) print("System action: ", system_action)
# NLG # NLG
act, slots = parse_frame(frame) act, slots = parse_frame(frame)
response = language_generation.generate(act, slots) response = language_generation.generate(act, slots)

View File

@ -1,7 +1,7 @@
from .slot import Slot from .slot import Slot
class Frame: class Frame:
def __init__(self, source: str, act: str, slots: list[Slot]): def __init__(self, source: str, act: str, slots: list[Slot] = []):
self.source = source self.source = source
self.slots = slots self.slots = slots
self.act = act self.act = act

View File

@ -42,8 +42,8 @@ SLOTS:
class NaturalLanguageUnderstanding(): class NaturalLanguageUnderstanding():
def __init__(self, use_mocks=False): def __init__(self, use_mocks=False):
if use_mocks: self.use_mocks = use_mocks
self.use_mocks = True if self.use_mocks:
return return
from flair.models import SequenceTagger from flair.models import SequenceTagger