Coder Social home page Coder Social logo

opendf's Introduction

OpenDF

Open Pythonic Dataflow Dialogue Framework

NEWLY ADDED - Dataflow Dialogue Generation

NEWLY ADDED - dataflow application development tutorial

This package is an implementation of (and interpretation) of the dataflow paradigm for dialogue systems which has been introduced by Microsoft's Semantic Machines in the paper Task oriented dialogue as dataflow synthesis, and which was accompanied by a large dataset (SMCalFlow) of dataflow-annotated dialogues has been released in their GitHub page.

This novel approach looks very promising, but unfortunately has not received much attention to date, as seen by the lack of follow-up publications and use.

This may be due to the fact that the code to run the dataflow expressions, as well as detailed documentation of the system, have not been released. Furthermore, SMCalFlow (which is, to date, the only dataset of dataflow annotations) is quite difficult to understand without documentation.

This package aims to address these difficulties by including:

  1. The basic infrastructure to construct, evaluate (execute), and inspect dataflow expressions;
  2. Code to transform the SMCalFlow dataset to a simplified format;
  3. Partial implementation of these simplified SMCalFlow functions.

This is intended to demonstrate that the dataflow dialogue paradigm is not inherently complicated (although specific application can be).

This implementation is incomplete, and most likely is very different from Semantic Machines' original implementation, but we hope that this package will ease the entry of more researchers and practitioners into this field, and that will stimulate new ideas and new systems using this paradigm.

Dataflow dialogues are not monolithic - there isn't just one correct implementation and way of use. Rather, there are many possible interpretations and flavours which can be implemented. Especially when it comes to applications, the implementation of node functions, and the way nodes interact with each other can be very different.

Finding good designs can be a challenge (it is basically a software engineering problem), but once good designs have been found, they can be used as templates, which can be reused for other applications.

Please give it a try and share your new designs!

See this document for some details about the dataflow dialogue framework, and this document about the SMCalFlow implementation.

In addition, see our LREC-2022 paper Simplifying Semantic Annotations of SMCalFlow.

See also this very good blog from Semantic Machines.

Update - see this document about the MultiWOZ-DF implementation in our paper MultiWOZ-DF - A Dataflow implementation of the MultiWOZ dataset.

Installation

The system should run on Python version 3.8 or above. It mainly depends on the libraries listed in the requirements.txt file. These dependencies can be installed in your environment by running:

pip install -r requirements.txt

WARNING: graphviz requires the installation of an additional library on the hosting operating system. If you do not have it installed yet, follow the instructions on this page, in order to install it on your specific operating system.

To run the generator, download spacy core model.

python -m spacy download en_core_web_md

Testing

In order to test OpenDF, run py.test from the repository's root directory.

Running

In order to execute a dataflow expression, simply run:

PYTHONPATH=$(pwd) python opendf/main.py

Or

PYTHONPATH=$(pwd) python opendf/main.py [-d index] [config params]

It will run the system with the example from opendf/examples/main_examples.py, defined by the index. In order to try new examples, simply enter them in the examples file.

dialog.py, dialog_simplify.py and dialog_text.py are other entry points of the system, each of which having its own example file, which are: opendf/examples/examples.py, opendf/examples/simplify_examples.py and opendf/examples/text_examples.py, respectively.

You can define your own Nodes in the playground file: opendf/applications/sandbox/sandbox.py

Example

In order to run dataflow, we need a P-expression (or simply, P-exp) that defines the dataflow graph. The advantage of using P-exp is that we can use machine learning models to learn a mapping between natural language expression and P-exp.

As an example, the sentence:

Delete the meeting with John's supervisor tomorrow.

Can be translated to:

DeleteEvent(AND(starts_at(Tomorrow()), with_attendee(FindManager(John))))

Which can be better seen as:

example 1 graph

As one can see, the P-exp is similar to the call of a function in a modern programing language. In this case, DeleteEvent, AND, starts_at, Tomorrow, with_attendee and FindManager are the name of nodes that correspond to python classes in the project. While the implementation of each node is given by its corresponding class. John, on the other hand, is a final value (in this case, a string) (optionally, a "#" can be used to explicitly indicate terminal values, but they are not required).

Each node receives a, possibly empty, list of arguments as inputs, that are also nodes. These arguments can be positional, named or a mix of both. The type of arguments expected by each node is called the signature of the node, and it is defined in its corresponding class.

The example above can be run using one of the commands below (assuming the user is in the root directory of the project):

PYTHONPATH=$(pwd) python opendf/main.py -d 1

or

PYTHONPATH=$(pwd) python opendf/main.py -e "DeleteEvent(AND(starts_at(Tomorrow()), with_attendee(FindManager(John))))"

And the result should look like the image below:

example 1 graph

The image might be slight different, depending on the type of nodes that are configured to show, hide or summarize.

Cite

If you use this work, please cite our LREC-2022 paper Simplifying Semantic Annotations of SMCalFlow.

If you rever to our MultiWOZ implementation, please also cite our MultiWOZ-DF paper MultiWOZ-DF - A Dataflow implementation of the MultiWOZ dataset.

opendf's People

Contributors

meron-tl avatar guimaraes-tl avatar hankcs avatar telepathylabsai avatar

Stargazers

wh7f avatar Alexandru Coca avatar Bruna Guedes avatar  avatar  avatar Yiheng Shu avatar  avatar  avatar Joe Geldart avatar mlciv avatar Bruno Henrique avatar Andrew Growney avatar  avatar Max Xu avatar  avatar Silvia Terragni avatar Ben Bogin avatar Itay Levy avatar Mingbo CUI avatar Modestas Filipavičius avatar Qingyang Wu avatar Brendan King avatar  avatar Longxu Dou avatar  avatar

Watchers

Song Feng avatar Yi Zhang avatar  avatar  avatar  avatar  avatar

opendf's Issues

RuntimeError: ParserException("Syntax error at `LexToken(OPEN_ARGUMENTS,'(',1,40)`")

Dear authors,

There seems to a bug when expressions suggested by MultipleEventSuggestionsException are executed:

Dialog 16

GUID: 4a53ad40-3012-4b3b-bae2-02dad4b71c13:

  • U1: Create meeting for today at noon and make my ShowAs status Busy
  • A1: I've put that on your calendar. Your status is set to Busy.
  • U2: I would like to set a lunch appointment at 1 am after that.
  • A2: I've put that on your calendar. Your status is set to Busy.

Data:

{"dialogue_id": "4a53ad40-3012-4b3b-bae2-02dad4b71c13", "turns": [{"agent_utterance": {"described_entities": [], "original_text": "I've put that on your calendar. Your status is set to Busy.", "tokens": ["I", "'ve", "put", "that", "on", "your", "calendar", ".", "Your", "status", "is", "set", "to", "Busy", "."]}, "lispress": " CreateEvent( AND( has_status( ShowAsStatus( Busy ) ) , starts_at( Today( ) ) , starts_at( Noon( ) ) ) ) ", "program_execution_oracle": {"has_exception": false, "refer_are_correct": true}, "skip": true, "turn_index": 0, "user_utterance": {"original_text": "Create meeting for today at noon and make my ShowAs status Busy", "tokens": ["Create", "meeting", "for", "today", "at", "noon", "and", "make", "my", "ShowAs", "status", "Busy"]}}, {"agent_utterance": {"described_entities": [], "original_text": "I've put that on your calendar. Your status is set to Busy.", "tokens": ["I", "'ve", "put", "that", "on", "your", "calendar", ".", "Your", "status", "is", "set", "to", "Busy", "."]}, "lispress": " CreateEvent( AND( has_subject( lunch  appointment ) , starts_at( NextTime( time= NumberAM( 1 ) ) ) ) ) ", "program_execution_oracle": {"has_exception": false, "refer_are_correct": true}, "skip": true, "turn_index": 1, "user_utterance": {"original_text": "I would like to set a lunch appointment at 1 am after that.", "tokens": ["I", "would", "like", "to", "set", "a", "lunch", "appointment", "at", "1", "am", "after", "that", "."]}}]}

U1's request gets a MultipleEventSuggestionsException:

Screen Shot 2022-06-20 at 3 53 39 PM

When I try to execute AcceptSuggestion, ParserException was raised. The expression caused the issue was:

ModifyEventRequest(AND(starts_at(DateTime(date=Date(year=2022, month=1, day=3), time=Time(hour=11, minute=0))), ends_at(DateTime(date=Date(year=2022, month=1, day=3), time=Time(hour=11, minute=30))), at_location(online)))

ParserException: Syntax error at `LexToken(ASSIGN_NODE,'$',1,92)`

Dear authors,

I don't mean to post too many issues but this one seems to be a different type. I noticed if a simplified expression contains variables then OpenDF won't be able to parse it. E.g.,

Dialog:

  • When is my presentation next week?
  • The "budgeting presentation" is on Wednesday the 20th from 2:00 to 3:00 PM.
  • Do I have anything schedule after that?
  • No, I didn't find any events on Wednesday the 20th after 3:00.

Expressions:

 FindEvents(
    AND(
       at_time(
          NextWeekList(
             ) ) ,
       has_subject(
          presentation ) ) ) 
          
  do(
    Let(
       x0 ,
       :end(
          refer(
             Event?(
                ) ) ) ) ,
    GTf(
       size(
          FindEvents(
             AND(
                starts_at(
                   :date(
                      $ x0 ) ) ,
                starts_at(
                   GT(
                      :time(
                         $ x0 ) ) ) ) ) ) ,
       0 ) ) 

OpenDF raises exceptions:

opendf.exceptions.python_exception.ParserException: Syntax error at `LexToken(ASSIGN_NODE,'$',1,92)`

Could you offer some suggestions to fix it? Thanks and have a good day.

Support SMCalFlow 2.x

Dear authors,

I'm brainstorming to add support for SMCalFlow 2.x. I understand OpenDF is written for 1.x and you mentioned:

Later, a second version was released (V2), which uses a slightly different format, but in this work we use V1.

But most recent works on this dataset use V2 for benchmarking. So, I'm thinking about an upgrade to V2 for broader audience. Could you offer me some suggestions if you have time?

  1. Would it be easier to implement v2 support in OpenDF than to implement a downgrade script to convert v2 to v1?
  2. From my limited understanding of OpenDF, I'll need to modify pre_simplify and simplify_graph. What's the difference between these two?

A list of references:

opendf.exceptions.df_exception.MultipleEntriesSingletonException

Dear authors,

I found a dialog that OpenDF cannot execute due to MultipleEntriesSingletonException.

Dialog 47

GUID: e13711b6-e221-416b-81e6-2a4bdfdc72a7 OpenDF:

  • U1: Can you see if my manager if the organizer of dance show
  • A1: Yes. David Lax is the organizer of "Dance Show".
  • U2: Interesting. Is my manager the organizer of the event right after that?
  • A2: Yes, David is the organizer of "Dance Show afterparty".

Database:
Screen Shot 2022-06-21 at 10 50 49 AM

I know since there're 2 events matching Dance Show so OpenDF raised MultipleEntriesSingletonException when executing singleton. However, wouldn't it be better for singleton to just take the first event since SMCalFlow's engine is able to execute this program?

revise only saves updated data on the second run

I'm trying to call revise to update an Event

Therefore I consider the following dialog

CreateEvent(AND(has_subject(AI Training for our website),with_attendee(dan),starts_at(AND(Today(),HourMinuteAm(hours=11,minutes=30)))))

Does this look ok? -
AI Training for our website with 2 Attendees
Dan Smith
You: notresponded, the status is busy
starting today at 11:30 lasting 30 minutes
and held online

AcceptSuggestion()

AI Training for our website with 2 Attendees NL Dan Smith: notresponded, the status is busy NL You: notresponded, the status is busy NL starting today at 11:30 lasting 30 minutes NL and held online

revise(old=Event??(), new=0golf, inp_nm=subject, newMode=extend)

AI Training for our website with You: notresponded, the status is busy starting today at 11:30 lasting 30 minutes NL and held online

grafik

as you can see the event name has not been updated (same in the graphViz graph)

However, if I run the command again, this time with a different subject, I can see my previous command (subject=0golf) being evaluated.

grafik

I can confirm that also the database (evt.add_event call) only receives the correct value on the second revise call, with the data being from the 2nd previous call

EDIT:
I'm using resources/smcalflow_config.yaml

grafik

Multiple Suggest Actions Get Reduced to One

Dear authors,

I found another possible bug that makes the execution result different from SMCalFlow. When there are multiple suggestion actions in one turn, OpenDF simply record the first one and discard the rest. See this dialog:

GUID: 18863eb5-824a-4f50-adc8-4ade051f8ed5

  • U1: Add Jacob's soccer game and Kylde park on Monday at 4 p.m. Schedule dinner at Mario's after the game at 7.
  • A1: I've put that on your calendar. Your status is set to Busy. I've put that on your calendar. Your status is set to Busy.

OpenDF result:

Screen Shot 2022-06-17 at 3 40 49 PM

You can see the dinner event is not committed.

I checked the codes and found this line could be the issue:

if isinstance(ex, list):
ex = ex[0]
if isinstance(ex, DFException):

Although there aren't so many turns that have multiple suggest actions, can we make this prev_sugg_act plural to be compatible with SMCalFlow?

getattr- getattr : signature does not have a field dayOfWeek

Dear authors,

I found OpenDF is trying to repeatedly call getattr while the signature validation failed:

Dialog 54

GUID: 096db3b5-b0cf-4268-8841-04936f86ac2b OpenDF:

  • U1: Did I host a graduation party last year?
  • A1: Yes, I found one event matching "graduation party". It was "Graduation Party" on May 19, 2019 from 5:00 to 5:30 PM.
  • U2: What did I do after the graduation party last year?
  • A2: I found one event on May 19, 2019 after 5:30 PM. It was "Graduation After-Party" from 7:00 to 7:30 PM.
  • U3: What day was the graduation party event last year?
  • A3: On May 19, 2019, it was Sunday.

Program:

 :dayOfWeek(
    :date(
       :start(
          FindEvents(
             AND(
                at_time(
                   FullYearofYear(
                      LastYear(
                         ) ) ) ,
                has_subject(
                   graduation party ) ) ) ) ) ) 

Graph:
Screen Shot 2022-06-21 at 11 42 15 AM

Unreasonable NoEventSuggestionException

Dear authors,

Sometimes OpenDF cannot create any suggestions while the constraints are reasonable. E.g,

Dialog 51

GUID: 000bd599-8de0-4d3a-bcc6-6a863fb6996c OpenDF:

  • U1: Go ahead and add vacation to my calendar from tomorrow at noon until the 25th at 5:30 pm and mark me as out of office during that time.
  • A1: Is this good?
  • U2: Sure.
  • A2: I've put that on your calendar. Your status is set to Out of Office.

Program:

 do(
    Let(
       x0 ,
       Tomorrow(
          ) ) ,
    CreateEvent(
       AND(
          has_status(
             ShowAsStatus(
                OutOfOffice ) ) ,
          has_subject(
             vacation ) ,
          starts_at(
             $ x0 ) ,
          starts_at(
             Noon(
                ) ) ,
          ends_at(
             nextDayOfMonth(
                $ x0 ,
                25 ) ) ,
          ends_at(
             HourMinutePm(
                hours= 5 ,
                minutes= 30 ) ) ) ) )

I checked the SQL used to find time slots, but it's just too long to read. Maybe something went wrong there?

SELECT start_table.point_in_time                                                                       AS suggested_starts_at,
       datetime(start_table.point_in_time, '+' || CAST(duration_table."offset" AS VARCHAR) ||
                                           ' minutes')                                                 AS suggested_ends_at,
       round((julianday(datetime(start_table.point_in_time,
                                 '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes')) -
              julianday(start_table.point_in_time)) * 24 * 60 *
             60)                                                                                       AS suggested_duration,
       location_table.id                                                                               AS suggested_location_id,
       location_table.name                                                                             AS suggested_location_name,
       location_table.always_free,
       date(start_table.point_in_time) IN (SELECT holiday.date
                                           FROM holiday)                                               AS in_holiday,
       (time(start_table.point_in_time) < time('09:00:00') OR time(start_table.point_in_time) > time('17:00:00') OR
        CAST(strftime('%w', start_table.point_in_time) AS INTEGER) < 1 OR
        CAST(strftime('%w', start_table.point_in_time) AS INTEGER) >
        5)                                                                                             AS in_off_hours,
       false                                                                                           AS bad_for_subject,
       (SELECT count(DISTINCT event_has_attendee.recipient_id) AS count
        FROM event_has_attendee
                 JOIN event ON event.id = event_has_attendee.event_id
        WHERE event_has_attendee.recipient_id IN (1007)
          AND ((event.starts_at <= start_table.point_in_time AND start_table.point_in_time < event.ends_at) OR
               (event.starts_at <
                datetime(start_table.point_in_time, '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes') AND
                datetime(start_table.point_in_time, '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes') <=
                event.ends_at) OR (start_table.point_in_time <= event.starts_at AND event.starts_at <
                                                                                    datetime(start_table.point_in_time,
                                                                                             '+' ||
                                                                                             CAST(duration_table."offset" AS VARCHAR) ||
                                                                                             ' minutes')) OR
               (start_table.point_in_time < event.ends_at AND event.ends_at <= datetime(start_table.point_in_time,
                                                                                        '+' ||
                                                                                        CAST(duration_table."offset" AS VARCHAR) ||
                                                                                        ' minutes')))) AS attendees_clashes
FROM possible_time AS start_table,
     possible_duration AS duration_table,
     location AS location_table
WHERE start_table.point_in_time <
      datetime(start_table.point_in_time, '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes')
  AND location_table.name LIKE '%online%'
  AND NOT (EXISTS(SELECT location.id
                  FROM event
                           JOIN location ON location.id = event.location_id
                  WHERE ((event.starts_at <= start_table.point_in_time AND start_table.point_in_time < event.ends_at) OR
                         (event.starts_at < datetime(start_table.point_in_time,
                                                     '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes') AND
                          datetime(start_table.point_in_time,
                                   '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes') <= event.ends_at) OR
                         (start_table.point_in_time <= event.starts_at AND event.starts_at <
                                                                           datetime(start_table.point_in_time, '+' ||
                                                                                                               CAST(duration_table."offset" AS VARCHAR) ||
                                                                                                               ' minutes')) OR
                         (start_table.point_in_time < event.ends_at AND event.ends_at <=
                                                                        datetime(start_table.point_in_time, '+' ||
                                                                                                            CAST(duration_table."offset" AS VARCHAR) ||
                                                                                                            ' minutes')))
                    AND location.always_free = false
                    AND location.id = location_table.id))
  AND (date(start_table.point_in_time) = date('2022-01-04') AND
       (time(start_table.point_in_time) >= time('11:00:00') AND time(start_table.point_in_time) <= time('13:00:00')))
  AND (date(datetime(start_table.point_in_time, '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes')) =
       date('2022-01-25') AND
       time(datetime(start_table.point_in_time, '+' || CAST(duration_table."offset" AS VARCHAR) || ' minutes')) =
       time('17:30:00'))
ORDER BY in_holiday, in_off_hours, bad_for_subject, suggested_starts_at

Memory Leaking? Error - unknown node #64, after running two dialogs one after another

Dear authors,

I tried to run two dialogs in a loop but got this wired exception. If I run them in separate scripts everything works fine. I made sure to create a new DialogContext but seems that OpenDF is leaking memories from previous run somewhere in a global variable?

Code:

        for i, dia in enumerate(dataset):
            data = importlib.import_module(f'data{i}')
            populate_stub_database(data)
            d_context = DialogContext()
            d_context.suppress_exceptions = True  # avoid exit in
            ret = execute_dialog(dia, d_context)

Log:

File "OpenDF/opendf/graph/eval.py", line 87, in recursive_eval
node.evaluate(prev_nodes, prev_goals)
File "OpenDF/opendf/graph/nodes/node.py", line 945, in evaluate
self.exec(all_nodes, goals)
File "OpenDF/opendf/applications/smcalflow/nodes/objects.py", line 959, in exec
r, e = self.call_construct_eval(d, self.context)
File "OpenDF/opendf/graph/nodes/node.py", line 1870, in call_construct_eval
g, ex = construct_graph(sexp, d_context, register=register, top_only=top_only, constr_tag=constr_tag,
File "OpenDF/opendf/graph/constr_graph.py", line 91, in construct_graph
raise ex
File "OpenDF/opendf/graph/constr_graph.py", line 87, in construct_graph
root = ast_top_down_construct(prs[0], None, d_context, register=register, top_only=top_only,
File "OpenDF/opendf/graph/constr_graph.py", line 293, in ast_top_down_construct
_ = ast_top_down_construct(nd, n, d_context, register, False, constr_tag)
File "OpenDF/opendf/graph/constr_graph.py", line 293, in ast_top_down_construct
_ = ast_top_down_construct(nd, n, d_context, register, False, constr_tag)
File "OpenDF/opendf/graph/constr_graph.py", line 210, in ast_top_down_construct
n = d_context.get_node(ast.name)
File "OpenDF/opendf/graph/dialog_context.py", line 171, in get_node
raise SemanticException('Error - unknown node #%d' % nm)
opendf.exceptions.python_exception.SemanticException: Error - unknown node #64

This current context only contain 35 nodes so this #64 node must be leaked from previous turn.
Screen Shot 2022-06-22 at 11 27 49 AM

opendf.exceptions.python_exception.ParserException: Syntax error at `LexToken(OPEN_ARGUMENTS,'(',1,15)`

Dear authors,

I found this very common bug that occurs in many many dialogs. So I'm wishing for a fix such that a lot of dialogs can benefit.

Expressions:

CreateEvent(
    AND(
       has_subject(
          swimming ) ,
       starts_at(
          NextDOW(
             FRIDAY ) ) ) ) 

AcceptSuggestion()

First expression executes fine, but the second AcceptSuggestion() raises:

Traceback (most recent call last):
File "OpenDF/opendf/applications/smcalflow/nodes/functions.py", line 1409, in exec
d = Event.create_suggestion(cp, self)
File "OpenDF/opendf/applications/smcalflow/nodes/objects.py", line 904, in create_suggestion
return Event.get_event_factory().create_event_suggestion(root, parent, avoid_id)
File "OpenDF/opendf/applications/smcalflow/nodes/event_factory.py", line 784, in create_event_suggestion
self.get_suggestions_from_database(root, root.context, subj, atts, avoid_id)
File "OpenDF/opendf/applications/smcalflow/nodes/event_factory.py", line 860, in get_suggestions_from_database
selection = self.create_database_selection(root, d_context, subject, attendees_ids, ignore_event_id)
File "OpenDF/opendf/applications/smcalflow/nodes/event_factory.py", line 928, in create_database_selection
cstart = Node.get_truncated_constraint_tree(ttree, 'TimeSlot', 'DateTime', 'start')
File "OpenDF/opendf/graph/nodes/node.py", line 2504, in get_truncated_constraint_tree
r, e = Node.call_construct(sexp, d_context)
File "OpenDF/opendf/graph/nodes/node.py", line 1857, in call_construct
g, ex = construct_graph(sexp, d_context, register=register, top_only=top_only, constr_tag=constr_tag,
File "OpenDF/opendf/graph/constr_graph.py", line 91, in construct_graph
raise ex
File "OpenDF/opendf/graph/constr_graph.py", line 86, in construct_graph
prs = parse_p_expressions(sexp)
File "OpenDF/opendf/parser/pexp_parser.py", line 460, in parse_p_expressions
return parser.parse(expressions)
File "OpenDF/opendf/parser/pexp_parser.py", line 351, in parse
self.parser.parse(input=expressions, lexer=self.lexer)
File "OpenDF/venv/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "OpenDF/venv/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "OpenDF/venv/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
r = errorfunc(token)
File "OpenDF/opendf/parser/pexp_parser.py", line 443, in p_error
raise ParserException(p)
opendf.exceptions.python_exception.ParserException: Syntax error at `LexToken(OPEN_ARGUMENTS,'(',1,15)`

How to Implement Nodes that Are Not Implemented Yet?

Dear authors,

I've read your paper and I'm aware that simplification is one of your major contributions and the execution engine is an ongoing process. I tried to execute some simplified dialogs and I noticed some functions are not implemented yet. E.g.,

  • Can you create an event right after the last event on my calender for 2 hours?
  • Is this good?
opendf.exceptions.python_exception.UnknownNodeTypeException: No such node type: FindLastEventn
  • Create a new event at 6 weeks after the next staff meeting for HR reviews
  • Is this good?
opendf.exceptions.python_exception.UnknownNodeTypeException: No such node type: adjustByPeriodDuration

Could you offer some suggestions? Also I'm willing to contribute to this open source project if needed.

"I could not find a matching time." Exception

Dear authors,

I'm having a strange problem that OpenDF said "I could not find a matching time" even if the calendar is almost empty. E.g,

Dialog 39

GUID: b8e3f6eb-88a2-4467-8ba2-74da83b1c09e OpenDF:

  • U1: Create an event for 6 AM tomorrow: "Print flight tickets"
  • A1: I've put that on your calendar. Your status is set to Busy.
  • U2: Schedule flight the day after that at 7 pm.
  • A2: I've put that on your calendar. Your status is set to Busy.

Program:

 CreateEvent(
    AND(
       has_subject(
          Print flight tickets ) ,
       starts_at(
          Tomorrow(
             ) ) ,
       starts_at(
          NumberAM(
             6 ) ) ) )

 CreateEvent(
    AND(
       has_subject(
          flight ) ,
       starts_at(
          adjustByPeriod(
             refer(
                Date?(
                   ) ) ,
             toDays(
                1 ) ) ) ,
       starts_at(
          NumberPM(
             7 ) ) ) ) 

Database after execution:
Screen Shot 2022-06-21 at 10 19 19 AM

Graphs:
39.dot.pdf

After the second turn, OpenDF raised I could not find a matching time. Do you have a suggestion? which doesn't make sense to me. Could you help me out?

opendf.exceptions.python_exception.SemanticException: alias usage should respect positional order : MD.month

Dear authors,

When running the simplified expression generated by OpenDF, sometimes MD raised the following exception:

File "OpenDF/test/research/run_dialog/run_utility.py", line 70, in execute_dialog
igl, ex = construct_graph(isexp, d_context, constr_tag=OUTLINE_SIMP, no_post_check=True)
File "OpenDF/opendf/graph/constr_graph.py", line 91, in construct_graph
raise ex
File "OpenDF/opendf/graph/constr_graph.py", line 87, in construct_graph
root = ast_top_down_construct(prs[0], None, d_context, register=register, top_only=top_only,
File "OpenDF/opendf/graph/constr_graph.py", line 293, in ast_top_down_construct
_ = ast_top_down_construct(nd, n, d_context, register, False, constr_tag)
File "OpenDF/opendf/graph/constr_graph.py", line 293, in ast_top_down_construct
_ = ast_top_down_construct(nd, n, d_context, register, False, constr_tag)
File "OpenDF/opendf/graph/constr_graph.py", line 293, in ast_top_down_construct
_ = ast_top_down_construct(nd, n, d_context, register, False, constr_tag)
File "OpenDF/opendf/graph/constr_graph.py", line 264, in ast_top_down_construct
raise SemanticException('alias usage should respect positional order : %s.%s' % (typ, alias))
opendf.exceptions.python_exception.SemanticException: alias usage should respect positional order : MD.month

Dialog 37

GUID: a70dc17b-7e6b-4a7a-a8fb-71bdaad5f39d OpenDF:

  • U1: Please put in dentist appt 2:30 12/19
  • A1: I've put that on your calendar. Your status is set to Busy.
  • U2: Is there anything I have on the schedule before that?
  • A2: No, I didn't find any events before yesterday at 2:30 PM.

Program:

 CreateEvent(
    AND(
       has_subject(
          dentist appt ) ,
       starts_at(
          MD(
             day= 19 ,
             month= toMonth(
                12 ) ) ) ,
       starts_at(
          HourMinutePm(
             hours= 2 ,
             minutes= 30 ) ) ) ) 

getattr- AcceptSuggestion : signature does not have a field item

Dear all,

I'm trying to make the user accept suggestion from a delete event operation. But I got this wired exception. I'm not sure why the graph has to call get item on AcceptSuggestion.

Dialog 48

GUID: e9b23d87-1b3c-4660-92b0-62d74a445706 OpenDF:

  • U1: Mark meeting with Jeff Monday at 4pm
  • A1: Is this good?
  • U2: That's fine. Cancel the Meeting with Dave before that
  • A2: I've put that on your calendar. __BREAK Is this what you want me to cancel?

Data:

{"dialogue_id": "e9b23d87-1b3c-4660-92b0-62d74a445706", "turns": [{"agent_utterance": {"described_entities": ["entity@126098598"], "original_text": "Is this good?", "tokens": ["Is", "this", "good", "?"]}, "lispress": " CreateEvent( AND( with_attendee( Jeff ) , starts_at( NextDOW( MONDAY ) ) , starts_at( NumberPM( 4 ) ) ) ) ", "program_execution_oracle": {"has_exception": true, "refer_are_correct": true}, "skip": false, "turn_index": 0, "user_utterance": {"original_text": "Mark meeting with Jeff Monday at 4pm", "tokens": ["Mark", "meeting", "with", "Jeff", "Monday", "at", "4", "pm"]}}, {"agent_utterance": {"described_entities": ["entity@1006503236"], "original_text": "I've put that on your calendar. __BREAK Is this what you want me to cancel?", "tokens": ["I", "'ve", "put", "that", "on", "your", "calendar", ".", "Is", "this", "what", "you", "want", "me", "to", "cancel", "?"]}, "lispress": " do( Let( x0 , AcceptSuggestion( ) ) , do( Yield( $ x0 ) , DeleteEvent( AND( starts_at( LT( :start( :item( $ x0 ) ) ) ) , with_attendee( Dave ) ) ) ) ) ", "program_execution_oracle": {"has_exception": true, "refer_are_correct": true}, "skip": false, "turn_index": 1, "user_utterance": {"original_text": "That's fine. Cancel the Meeting with Dave before that", "tokens": ["That", "'s", "fine", ".", "Cancel", "the", "Meeting", "with", "Dave", "before", "that"]}}], "_id": 863}

Program:

 CreateEvent(
    AND(
       with_attendee(
          Jeff ) ,
       starts_at(
          NextDOW(
             MONDAY ) ) ,
       starts_at(
          NumberPM(
             4 ) ) ) ) 

 do(
    Let(
       x0 ,
       AcceptSuggestion(
          ) ) ,
    do(
       Yield(
          $ x0 ) ,
       DeleteEvent(
          AND(
             starts_at(
                LT(
                   :start(
                      :item(
                         $ x0 ) ) ) ) ,
             with_attendee(
                Dave ) ) ) ) ) 

Graph:
Screen Shot 2022-06-21 at 11 05 05 AM

How to confirm suggestions from a MultipleEventSuggestionsException?

Dear authors,

I'm trying to make OpenDF commit suggestions from a MultipleEventSuggestionsException to the database. I tried to execute a AcceptSuggestion call after the turn it was raised. However, the expression got executed was only ModifyEventRequest(AND(starts_at(DateTime(date=Date(year=2022, month=1, day=3), time=Time(hour=16, minute=0))), ends_at(DateTime(date=Date(year=2022, month=1, day=3), time=Time(hour=16, minute=30))), at_location(online))), which doesn't really write to database. Could you give me a hint?

Dialog 26

GUID: 711e9573-a9c1-49cb-a887-da7258638e7a OpenDF:

  • U1: What time is my train tomorrow?
  • A1: You have one event on your calendar. Your "train" is tomorrow from 3:00 to 3:30 PM.
  • U2: After that set family time from 4 and make sure there isn't anything else on the schedule.
  • A2: I've put that on your calendar. Your status is set to Busy.

Data:

{"dialogue_id": "711e9573-a9c1-49cb-a887-da7258638e7a", "turns": [{"agent_utterance": {"described_entities": [], "original_text": "You have one event on your calendar. Your \"train\" is tomorrow from 3:00 to 3:30 PM.", "tokens": ["You", "have", "one", "event", "on", "your", "calendar", ".", "Your", "\"", "train", "\"", "is", "tomorrow", "from", "3", ":", "00", "to", "3", ":", "30", "PM", "."]}, "lispress": " FindEvents( AND( starts_at( Tomorrow( ) ) , has_subject( train ) ) ) ", "program_execution_oracle": {"has_exception": false, "refer_are_correct": true}, "skip": true, "turn_index": 0, "user_utterance": {"original_text": "What time is my train tomorrow?", "tokens": ["What", "time", "is", "my", "train", "tomorrow", "?"]}}, {"agent_utterance": {"described_entities": [], "original_text": "I've put that on your calendar. Your status is set to Busy.", "tokens": ["I", "'ve", "put", "that", "on", "your", "calendar", ".", "Your", "status", "is", "set", "to", "Busy", "."]}, "lispress": " CreateEvent( AND( has_subject( family  time ) , starts_at( GE( :end( refer( Event?( ) ) ) ) ) , starts_at( NumberPM( 4 ) ) ) ) ", "program_execution_oracle": {"has_exception": false, "refer_are_correct": true}, "skip": true, "turn_index": 1, "user_utterance": {"original_text": "After that set family time from 4 and make sure there isn't anything else on the schedule.", "tokens": ["After", "that", "set", "family", "time", "from", "4", "and", "make", "sure", "there", "is", "n't", "anything", "else", "on", "the", "schedule", "."]}}], "_id": 428}

opendf.exceptions.python_exception.SemanticException: ConstructError - Unexpected param type - pos2/Str

Dear authors,

I spot another bug that nodes like DayOfWeek(Str(SATURDAY)) won't execute, e.g.:

Dialog 7

GUID: 16aab101-e67c-42a4-887d-d2ad99cc300e :

  • U1: Put camping trip on my calendar for Saturday at 9 am for 12 hours
  • A1: I've put that on your calendar. Your status is set to Busy.
  • U2: Change that to the Saturday after that at 8 am.
  • A2: I've changed your camping trip to February 2nd at 8:00 AM.

Program:

 UpdateEvent(
    refer(
       Event?(
          ) ) ,
    AND(
       starts_at(
          nextDayOfWeek(
             :date(
                :start(
                   refer(
                      Event?(
                         ) ) ) ) ,
             DayOfWeek(
                SATURDAY ) ) ) ,
       starts_at(
          NumberAM(
             8 ) ) ) ) 

Maybe OpenDF wrongly added a redundant Str to wrap SATURDAY?

Graphviz: Error: not well-formed (invalid token) in line 1

Dear authors,

Graphviz doesn't allow for & in html code. So could you help me to sanitize it?

Database has D&D Night:

Screen Shot 2022-06-21 at 5 11 01 PM

Program:

 FindEvents(
    starts_at(
       adjustByPeriod(
          refer(
             Date?(
                ) ) ,
          toDays(
             1 ) ) ) )

Log:

Error: not well-formed (invalid token) in line 1
... <HTML>D&D  Night ...
in label of node 31=D&D  Night
Traceback (most recent call last):
File "OpenDF/venv/lib/python3.8/site-packages/graphviz/backend/execute.py", line 91, in run_check
proc.check_returncode()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 448, in check_returncode
raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '[PosixPath('dot'), '-Kdot', '-Tpdf', '-O', '93.dot']' returned non-zero exit status 1.

`AcceptSuggestion` doesn't take effect

Dear authors,

I've been reading your great paper and experimenting with OpenDF for quite a while. Seems that AcceptSuggestion is not correctly implemented as it doesn't really complies to a confirmation that writes the database. For example, consider the following dialog:

  • what is my appointment with janice kang
  • I didn't find any events with janice kang.
  • create appointment with janice kang
  • Here are some times when you and Janice Kang are free.
  • yes sexp=AcceptSuggestion()
  • I've put that on your calendar on Wednesday from 10:00 to 10:30 AM.

As highlighted above, the turn in bold doesn't take effect but instead it raises EventConfirmationException('Does this look ok? ...) to ask for confirmation again which eventually terminates OpenDF execution.

After digging a little deeper, I find the confirm flag is never set to true anywhere. Maybe this is the core problem? Maybe the solution is to set it to true in AcceptSuggestion node?

Thanks.

AttributeError: 'NoneType' object has no attribute 'call_eval'

Dear authors,

OpenDF failed to execute this dialog, which might deserve a fix:

Dialog 75

GUID: 47c6ad36-cf06-4240-85ac-efd59d21390a OpenDF:

  • U1: Tell me when I have something to do again
  • A1: I found 1 matching event on your calendar. It's "lunch with Maggie" on Tuesday the 19th from 1:00 to 2:00 PM.
  • U2: Anything after that?
  • A2: No, I didn't find any events on Tuesday the 19th after 2:00 PM.
  • U3: I thought my next event wasn't until Tuesday
  • A3: The "lunch with Maggie" on Tuesday the 19th from 1:00 to 2:00 PM.

Program:

 FindEvents(
    Event?(
       ) ) 

If the calendar is empty, OpenDF raises:

Traceback (most recent call last):
File "OpenDF/opendf/graph/eval.py", line 87, in recursive_eval
node.evaluate(prev_nodes, prev_goals)
File "OpenDF/opendf/graph/nodes/node.py", line 945, in evaluate
self.exec(all_nodes, goals)
File "OpenDF/opendf/applications/smcalflow/nodes/functions.py", line 1286, in exec
r.call_eval(add_goal=False)  # pedantic
AttributeError: 'NoneType' object has no attribute 'call_eval'

Why two spaces are used in strings instead of just one?

Dear authors,

I have a question that is not so critical but it's a little bit confusing. I saw SQL generated by OpenDF are using double spaces in every string. As a result, I have to use double spaces in person names, topic etc., which is not convenient for debugging.

E.g.,

SELECT event.id,
       event.subject,
       event.starts_at,
       event.ends_at,
       event.location_id,
       event.organizer_id,
       location.name,
       location.always_free
FROM event
         LEFT OUTER JOIN location ON event.location_id = location.id
WHERE (event.subject LIKE '%dinner  reservation%' AND date(event.starts_at) = date('2022-01-06') AND
       ((time(event.starts_at) >= time('17:00:00') AND time(event.starts_at) <= time('21:30:00')) OR
        (time(event.ends_at) >= time('17:00:00') AND time(event.ends_at) <= time('21:30:00')) OR
        (time(event.starts_at) <= time('17:00:00') AND time(event.ends_at) >= time('17:00:00')) OR
        (time(event.starts_at) <= time('21:30:00') AND time(event.ends_at) >= time('21:30:00'))))

dinner reservation won't be matched.

Wrongly Simplified Graph with Semantics Missing

Dear authors,

After more experiments on OpenDF, I noticed a wrongly simplified graph that some semantics from SMCalFlow is missing. Its turns are like this:

  1. What time is my train tomorrow?
  2. You have one event on your calendar. Your "train" is tomorrow from 3:00 to 3:30 PM.
  3. After that set family time from 4 and make sure there isn't anything else on the schedule.
  4. I've put that on your calendar. Your status is set to Busy.

In utterance 3, SMCalFlow correctly annotated that the date of "family time" needs to match the date of "train", which is a reference and needs to be resolved. As highlighted in the red box, DF correctly annotated the date of “family time” in utterance 3 is the end day of “train” event.
Screen Shot 2022-06-09 at 2 43 39 PM

However, OpenDF failed to convert the date part into its simplified graph, leading to mismatch semantics in its compiled/executed graphs too.

Screen Shot 2022-06-09 at 2 49 03 PM

I don't know how many such graphs are there but I assume it's not a unique case. I'm wondering if there is a way to fix it. I'd appreciate it if you can offer some suggestions.

Thank you.

time(NULL) > time('13:30:00') Generated as A SQL Query

Dear authors,

I found sometimes the SQL statements generated by OpenDF is wrong that its where clause contains time(NULL) > time('13:30:00') which will never gets evaluated to true. E.g.,

Dialog 15

GUID: 47aa12c3-d912-47ac-b585-03dcd4ac3827 :

  • U1: Add a meeting with Anna today at 1pm.
  • A1: Is this good?
  • U2: Do I have a meeting after that one as well?
  • A2: Yes, I found one event today after 1:30. It's "Quick Meet" from 3:00 PM to 3:30 PM.

Program:

 CreateEvent(
    AND(
       with_attendee(
          Anna ) ,
       starts_at(
          Today(
             ) ) ,
       starts_at(
          NumberPM(
             1 ) ) ) ) 

 do(
    Let(
       x0 ,
       :end(
          refer(
             Event?(
                ) ) ) ) ,
    GTf(
       size(
          FindEvents(
             AND(
                starts_at(
                   :date(
                      $ x0 ) ) ,
                starts_at(
                   GT(
                      :time(
                         $ x0 ) ) ) ) ) ) ,
       0 ) ) 

SQL:

SELECT event.id, event.subject, event.starts_at, event.ends_at, event.location_id, event.organizer_id, location.name, location.always_free FROM event LEFT OUTER JOIN location ON event.location_id = location.id WHERE (date(event.starts_at) = date('2022-01-03') AND time(NULL) > time('13:30:00'))

The where clause should be WHERE (date(event.starts_at) = date('2022-01-03') AND time(event.starts_at) > time('13:30:00'))

Dialog Simplify Error(s)

Hi, I am having some trouble getting dialog_simplify.py to work on the test examples simplify_examples.py. I'm running the command as:

PYTHONPATH=$(pwd) python opendf/dialog_simplify.py -d 1 ../smcalflow

I was able to fix the first couple of errors but I'm now stuck on this error:

Traceback (most recent call last):
  File "/home/shivag5/Documents/research/comp-gen/OpenDF/opendf/dialog_simplify.py", line 183, in dialog
    bgl, ex = pre_simplify_graph(igl, d_context)
  File "/home/shivag5/Documents/research/comp-gen/OpenDF/opendf/graph/simplify_graph.py", line 87, in pre_simplify_graph
    e = recursive_pre_simplify(nd, d_context, nd, None, None)
  File "/home/shivag5/Documents/research/comp-gen/OpenDF/opendf/graph/simplify_graph.py", line 99, in recursive_pre_simplify
    e = recursive_pre_simplify(n.input_view(i), d_context, top, e,
  File "/home/shivag5/Documents/research/comp-gen/OpenDF/opendf/graph/simplify_graph.py", line 99, in recursive_pre_simplify
    e = recursive_pre_simplify(n.input_view(i), d_context, top, e,
  File "/home/shivag5/Documents/research/comp-gen/OpenDF/opendf/graph/simplify_graph.py", line 105, in recursive_pre_simplify
    m, e, mode = n.pre_simplify(top, mode, d_context)
TypeError: pre_simplify() takes 3 positional arguments but 4 were given

The other errors were:

  1. argparse.ArgumentError: argument --log/-l: conflicting option strings: --log, -l because the --log argument is added twice.
  2. AttributeError: 'Namespace' object has no attribute 'environment' because parser = add_environment_option(parser) is missing in dialog_simplify.py unlike in dialog.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.