Git Product home page Git Product logo

Comments (7)

keiffster avatar keiffster commented on June 16, 2024 2

SRIAX in AIML 2 are a bit rubbish, added by the Pandora guys to allow them to call their own services, but they are not well documented and not extensible enough for what I wanted

Instead use the tag which is used for calling Python classes directly, which can then call other APIs via whichever mechanism you prefer as normal python code

Check out src/test/parser/template/graph/test_extension.py which shows examples of how to call an extension from within an AIML Tag.

1 2 3

In this example, TestExtension conforms to a basic class of

class TestExtension(object):

def execute(self, data):
    print(data)
    return "executed"

When the template is evaluated, your extension class is dynamically loaded, and execute called with all the other data passed as a string into the variable data.

Parse this, do whatever operation you want to do and then return a string of values which will then be returned as part of normal AIML parsing.

If you want to parse the returned values, you can wrap this in an tag

WARNING, make sure your extension class is on the python path or it will not be picked up

Keiff

from program-y.

JustArchi avatar JustArchi commented on June 16, 2024 1

curl 'http://127.0.0.1:5000/api/v1.0/ask?sessionid=123&question=hello'

{
  "response": {
    "answer": "Hi nice to see you!",
    "question": "hello",
    "sessionid": "123"
  }
}

For example how to launch REST server, check alice2_rest.sh in bots/alice2.

BTW, sessions don't seem to work yet.

from program-y.

JustArchi avatar JustArchi commented on June 16, 2024

Ah wait, you mean external APIs via <sraix>, sorry, I'm not sure about this, hopefully keiff will answer.

from program-y.

newdev7 avatar newdev7 commented on June 16, 2024

@JustArchi @keiffster Thanks for your answer. Now I'm able to call the external API's using the tag which is used for calling Python classes as mentioned by you. Now I'm trying to call the program-y from external interface, I'll raise a question if I need any help.

from program-y.

newdev7 avatar newdev7 commented on June 16, 2024

@JustArchi I tried to use the curl command in the terminal. But it returns Failed to connect to 127.0.0.1 port 5000: Connection refused. The configuration says localhost & port 5000 only, Can you help me with the information for the same.

from program-y.

JustArchi avatar JustArchi commented on June 16, 2024

And did you start Program-Y REST server first?

root@archi:~# netstat -tulpn | grep 5000
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      2941/python3

You need firstly to start REST server, for example with alice2_rest.sh script in bots/alice2, then once it's up and listening you can communicate with it.

from program-y.

newdev7 avatar newdev7 commented on June 16, 2024

@JustArchi Thanks. After running the alice2_rest.sh script, I am able to communicate with it.

from program-y.

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.