Giter VIP home page Giter VIP logo

Comments (4)

rodrigopivi avatar rodrigopivi commented on May 31, 2024

Hi @gauravbrills,

Yes, you can use it from javascript (node or browsers). You should just be able to require the adapter you want to use. chatito/dist/adapters/rasa here is an example of how the IDE uses the adapters programatically:

https://github.com/rodrigopivi/Chatito/blob/master/web/components/Editor/Editor.tsx#L448

Let me know if that worked

from chatito.

gauravbrills avatar gauravbrills commented on May 31, 2024

HI @rodrigopivi actually I wanted to be able to generate the chatitio dsl file programatically by which I mean generated the DSL code in the file via code and then subsequently generate the data sets from ui .

from chatito.

rodrigopivi avatar rodrigopivi commented on May 31, 2024

Don't see what is the blocker, you should be able to just generate the text template programatically. Alternatively, instead of passing a string, you can also pass a JS object (the AST). Currently, chatito uses PEG.js to parse the plain text and form an abstract representation of what is inside the text.

This abstract representation is just a js object you can also construct manually, and then pass to the generator:

just call this method with a valid AST object, that implementts the IChatitoEntityAST interface.

You can create an object that implements this interface:
https://github.com/rodrigopivi/Chatito/blob/master/src/types.ts#L22

And then pass that object to this generator function:
https://github.com/rodrigopivi/Chatito/blob/master/src/main.ts#L144

For example, this DSL:

%[hi]('training': '1')
    ~[greet?] @[name] ~[all good]

@[name]
    ~[gauravbrills]

Will generate this AST:

[
   {
      "type": "IntentDefinition",
      "key": "hi",
      "args": {
         "training": "1"
      },
      "location": {
         "start": {
            "offset": 0,
            "line": 1,
            "column": 1
         },
         "end": {
            "offset": 22,
            "line": 1,
            "column": 23
         }
      },
      "inner": [
         [
            {
               "value": "greet",
               "type": "Alias",
               "opt": true
            },
            {
               "value": " ",
               "type": "Text"
            },
            {
               "value": "name",
               "type": "Slot",
               "opt": false,
               "location": {
                  "start": {
                     "offset": 37,
                     "line": 2,
                     "column": 15
                  },
                  "end": {
                     "offset": 44,
                     "line": 2,
                     "column": 22
                  }
               },
               "variation": null
            },
            {
               "value": " ",
               "type": "Text"
            },
            {
               "value": "all good",
               "type": "Alias",
               "opt": false
            }
         ]
      ]
   },
   {
      "type": "SlotDefinition",
      "key": "name",
      "args": null,
      "location": {
         "start": {
            "offset": 58,
            "line": 4,
            "column": 1
         },
         "end": {
            "offset": 65,
            "line": 4,
            "column": 8
         }
      },
      "inner": [
         [
            {
               "value": "gauravbrills",
               "type": "Alias",
               "opt": false
            }
         ]
      ],
      "variation": null
   }
]

Not sure what if this is kind of the programatic interface you are trying to hook to. Note: you should be able to just skip passing the 'location' attribute since its only used for error reporting when the dsl was incorrect, this way you can just extend aliases or sentences by adding a new item in the corresponding object array for that entity, i have not removed the location attribute in the example to show the actual AST generated, but you can do it to make the object smaller and easier to understand

from chatito.

gauravbrills avatar gauravbrills commented on May 31, 2024

@rodrigopivi Thanks for the application got it 👍

from chatito.

Related Issues (20)

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.