python-client icon indicating copy to clipboard operation
python-client copied to clipboard

REST API

Open StrangeTcy opened this issue 9 years ago • 7 comments

At the moment, README contains a line "Requires the REST API to be configured as described here", in which "here" links to another README with a link to OpenCog wiki page about the whole Python setup, not just thr REST API. Shouldn't we "cut out the middle man", as it were?

StrangeTcy avatar Aug 24 '16 03:08 StrangeTcy

Yes.

Please note that the code here might be bit-rotted; I am not sure that there are any active users of this stuff.

linas avatar Aug 24 '16 05:08 linas

Ok, I'm pretty sure I'm running the neccessary servers (cogserver and relex server) and my REST API is loaded, but when I run opencog-nlp.ipynb, it fails on In [5] with

KeyError Traceback (most recent call last) in () ----> 1 to_logic("I think that all dogs can fly.")

/home/enoch/the_machine/python-client/opencog.pyc in to_logic(sentence, clear, display) 405 if clear: 406 scheme("(clear)") --> 407 scheme('(r2l "' + sentence + '")') 408 if display: 409 print scheme("(cog-outgoing-set (car (cog-get-atoms 'SetLink)))")

/home/enoch/the_machine/python-client/opencog.pyc in scheme(command) 74 75 result = post(uri + 'scheme', data=json.dumps(data), headers=headers) ---> 76 return result.json()['response'] 77 78

KeyError: 'response'

The RelEx server says

127.0.0.1 - - [04/Sep/2016 16:31:01] "POST /api/v1.1/scheme HTTP/1.1" 200 - [2016-09-04 16:31:01,726] ERROR in app: Exception on /api/v1.1/scheme [POST] Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request return self.view_functionsrule.endpoint File "/usr/local/lib/python2.7/dist-packages/flask_restful/init.py", line 477, in wrapper resp = resource(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/flask/views.py", line 84, in view return self.dispatch_request(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/flask_restful/init.py", line 587, in dispatch_request resp = meth(_args, *_kwargs) File "/home/enoch/opencog/opencog/python/web/api/apischeme.py", line 81, in post response = scheme_eval(self.atomspace, data['command']) File "opencog/scheme_wrapper.pyx", line 34, in opencog.scheme_wrapper.scheme_eval (/home/enoch/atomspace/build/opencog/cython/opencog/scheme_wrapper.cpp:931) RuntimeError: Scheme: Failed to execute '(r2l "I think that all dogs can fly.") ' Backtrace: In ice-9/boot-9.scm: 157: 12 [catch #t #<catch-closure 2c98420> ...] In unknown file: ?: 11 [apply-smob/1 #<catch-closure 2c98420>] In ice-9/boot-9.scm: 157: 10 [catch #t #<catch-closure 2c98300> ...] In unknown file: ?: 9 [apply-smob/1 #<catch-closure 2c98300>] ?: 8 [call-with-input-string "(r2l "I think that all dogs can fly.")\n" ...] In ice-9/boot-9.scm: 2401: 7 [save-module-excursion #<procedure 2c84510 at ice-9/eval-string.scm:65:9 ()>] In ice-9/eval-string.scm: 44: 6 [read-and-eval #<input: string 2cb1a90> #:lang ...] 37: 5 [lp (r2l "I think that all dogs can fly.")] In ice-9/eval.scm: 386: 4 [eval #<memoized (r2l (quote "I think that all dogs can fly."))> ()] 393: 3 [eval # ()] In unknown file: ?: 2 [memoize-variable-access! # #<directory (guile-user) 27dac60>] In ice-9/boot-9.scm: 102: 1 [#<procedure 2efc980 at ice-9/boot-9.scm:97:6 (thrown-k . args)> unbound-variable ...] In unknown file: ?: 0 [apply-smob/1 #<catch-closure 2c982c0> unbound-variable ...]

ERROR: In procedure apply-smob/1: ERROR: Unbound variable: r2l ABORT: unbound-variable (/home/enoch/atomspace/opencog/cython/opencog/PyScheme.cc:41) 127.0.0.1 - - [04/Sep/2016 16:31:01] "POST /api/v1.1/scheme HTTP/1.1" 500 -

StrangeTcy avatar Sep 04 '16 13:09 StrangeTcy

To clarify my general intent: I wish to have a working pipeline which would allow me to talk with an AGI-to-be by typing english sentences. I expect it to be something like chat window -> NLP (including RelEx) -> AtomSpace. I also expected this example to show how such a pipeline is supposed to work. So far, for me, it hasn't.

StrangeTcy avatar Sep 04 '16 15:09 StrangeTcy

I beleive that you need to have the relex2logic rules loaded.

The only part of the langauge pipeline that is guaranteed to work, at this time, is the chatbot. it uses the whole rele2logic pipeine, and etc. but does not use the REST api's

linas avatar Sep 04 '16 17:09 linas

Perhaps, but the python notebook just mentions RelEx2Logic, it doesn't explicitly tell you that it needs to be be loaded, nor does it explain how to do it, nor provides useful links.

I should probably try to use the wiki, but I think that over time I'm not gonna be the only one to stumble into such lack of clarity. Also, at the moment the wiki reports a lot of general wiki and php errors. Please someone do something about that :-/

StrangeTcy avatar Sep 04 '16 17:09 StrangeTcy

The python notebook is old and unmaintained. I've actually never seen it myself, I heard it exists, but I don't know where. The core issue is that people create stuff, and then don't stick around long enough to maintain it. Thus, the core systems work -- as they're in regular use. Things off to the side bit-rot.

The website -- well, similar story -- a few days ago, someone upgraded the version of PHP on it, but failed to update all of the website scripts to go with it. So now that has to be fixed. Maintenance is a constant struggle -- turns out that large complex living systems exhibit many of the same properties, such as aging -- and rejuvenation doesn't happen automatically.

linas avatar Sep 04 '16 17:09 linas

That's the impression I was forming, yes. Perhaps I was wrong when I supposed that you could start tinkering with OpenCog by just installing the basics and trying to make relevant code that caught your eye work.

Either way, because of your advice I turned my attention to RelEx2Logic and following wiki advice. And it doesn't work as I want it to, either :-) But some parts do, which I'll consider a good start.

StrangeTcy avatar Sep 04 '16 17:09 StrangeTcy