Comments (7)
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 3In 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.
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.
Ah wait, you mean external APIs via <sraix>
, sorry, I'm not sure about this, hopefully keiff will answer.
from program-y.
@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.
@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.
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.
@JustArchi Thanks. After running the alice2_rest.sh script, I am able to communicate with it.
from program-y.
Related Issues (20)
- Programy on PythonAnywhere HOT 1
- Program-Y is alive.... again HOT 2
- <system> tag in aiml doesn't work HOT 1
- scheduling extension doesn't print message
- Error when trying to save data from 'learnf' elements to MongoDB HOT 2
- Wikipedia doesn't seam to work HOT 1
- <learn> and <star> don't work together HOT 1
- How to get a variable value outside of aiml files inside python code?
- Setting SentenceSplitter on an embedded bot HOT 4
- Whenever I install program y, cryptography fails to install and the whole installation stops.
- Bug in pattern parser where the star index of the words will change
- WARNING:root:[Console] [bot] [brain] [testuser] - System command node disabled in config
- ModuleNotFoundError: No module named 'sqlalchemy'
- Pattern matching not work in a right way
- image not displaying in telegram
- GUI for my bot (Not a feature request I was just unsure where to ask) HOT 1
- Change Default Response
- AttributeError: module 'collections' has no attribute 'MutableSet' HOT 3
- module apscheduler not found
- Thoughts about ChatGPT service for ProgramY
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from program-y.