keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
348 stars 138 forks source link

error while loading openchatbot #241

Closed ohoachuck closed 4 years ago

ohoachuck commented 4 years ago

Hello, any ideas why I'm getting an error while trying to load REST script with OpenChatBot service declared ?

Expected Behavior

No error while running ./y-bot-flask-rest.sh

Current Behavior

Initiating Flask REST Service... Loading, please wait... No bot root argument set, defaulting to [../../config/xnix] Found a total of 1 errors in your grammars, check your errors store Found a total of 6 duplicates in your grammars, check your duplicates store Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/clients/restful/flask/client.py", line 89, in <module> REST_CLIENT = FlaskRestBotClient("flask") File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/clients/restful/flask/client.py", line 25, in __init__ RestBotClient.__init__(self, id, argument_parser) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/clients/restful/client.py", line 31, in __init__ BotClient.__init__(self, id, argument_parser) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/clients/client.py", line 69, in __init__ self._bot_factory = BotFactory(self, self.configuration.client_configuration) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/clients/botfactory.py", line 69, in __init__ self.load_bots(configuration) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/clients/botfactory.py", line 83, in load_bots bot = Bot(config, client=self._client) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/bot.py", line 43, in __init__ self._brain_factory = BrainFactory(self) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/brainfactory.py", line 68, in __init__ self.loads_brains(bot) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/brainfactory.py", line 82, in loads_brains brain = Brain(bot, config) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/brain.py", line 98, in __init__ self.load(self.configuration) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/brain.py", line 233, in load self.load_services(configuration) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/brain.py", line 359, in load_services ServiceFactory.preload_services(configuration.services) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/services/service.py", line 55, in preload_services meta_class = loader.instantiate_class(service_config.classname) File "/Users/oho/Documents/Dev/Web/openchatbot/openchatbot.io.dev/programy/src/programy/utils/classes/loader.py", line 33, in instantiate_class imported_module = importlib.import_module(module_path) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked ModuleNotFoundError: No module named 'programy.services.openchat'

Possible Solution

?

Steps to Reproduce

  1. install program-y from pip with venv

    python3.6 -m venv programy
    cd programy
    source ./bin/activate
    pip3 install --no-cache-dir programy
    python3 -m programy.admin.tool download y-bot
    (as per tuto)

    WARNING: I'm using mac OS tuto here, but Linux tuto for pip install program-y is missing a "return" in the install command ligne (between programs and Collecting). I think this might lead to confusion for beginners (see https://github.com/keiffster/program-y/wiki/Install_Linux_Pip).

    (programy) keith@ubuntu:~/mybots/programy$ pip3 install --no-cache-dir programyCollecting programy
  2. set config/xnix/config.flask.rest.yaml as follow:

    services:
        OPENCHAT:
            classname: programy.services.openchat.OpenChatRESTService
        REST:
            classname: programy.services.rest.GenericRESTService
            method: GET
            host: 0.0.0.0
        Pannous:
            classname: programy.services.pannous.PannousService
            url: http://weannie.pannous.com/api
        Pandora:
            classname: programy.services.pandora.PandoraService
            url: http://www.pandorabots.com/pandora/talk-xml
        Wikipedia:
            classname: programy.services.wikipediaservice.WikipediaService
        DuckDuckGo:
            classname: programy.services.duckduckgo.DuckDuckGoService
            url: http://api.duckduckgo.com
    
    openchatbots:
        protocols: http, https
        domains: org, co.uk
        ocb:
            url: https://openchatbot.io/api/v1.0/ask
            method: GET
        dd:
            url: https://doungdoung.com/api/doungdoung/v1.0/ask
            method: GET
        chatbot4:
            url: http://localhost:7777/api/rest/v2.0/ask
            method: GET
            api_key: '11111111111111'
  3. cd scripts/xnix
    ./y-bot-flask-rest.sh

Context (Environment)

Detailed Description

Possible Implementation

This might be due to my specific env ?

ohoachuck commented 4 years ago

Hello, Sorry, I should have looked closely and search more before posting. This was due to an obvious typo in the config file : current wrong config:

    services:
        OPENCHAT:
            classname: programy.services.openchat.OpenChatRESTService

should be replaced by:

    services:
        OPENCHAT:
            classname: programy.services.openchatbot.service.OpenChatRESTService

To be corrected in the doc then.

keiffster commented 4 years ago

Glad you have it resolved, I’ll update docs shortly. Sorry about that.

Output has been low recently as I have spent the time adding unit test coverage as a baseline for the rest of the work planned in 2020

Over 1000 additional unit tests added and coverage at 92%. This will be the core of v4. With out the coverage I cannot do the splitting into core, extensions and clients that I want to do.

So the structure will be something like

programy-core programy-client-facebook programy-client-slack programy-client-openchat programy-ext-weather programy-ext-wikipedia etc

To stop myself going mad I have added 23 new services which can pull data from a variety of open data sources, UK Rail, breweries, stocks, quotes etc

So lots to do

ohoachuck commented 4 years ago

👍 Your work on Program-y always impress me. Great to hear your plan.

O.

Envoyé de mon iPhone

Le 23 nov. 2019 à 18:16, Keith Sterling notifications@github.com a écrit :

 Glad you have it resolved, I’ll update docs shortly. Sorry about that.

Output has been low recently as I have spent the time adding unit test coverage as a baseline for the rest of the work planned in 2020

Over 1000 additional unit tests added and coverage at 92%. This will be the core of v4. With out the coverage I cannot do the splitting into core, extensions and clients that I want to do.

So the structure will be something like

programy-core programy-client-facebook programy-client-slack programy-client-openchat programy-ext-weather programy-ext-wikipedia etc

To stop myself going mad I have added 23 new services which can pull data from a variety of open data sources, UK Rail, breweries, stocks, quotes etc

So lots to do

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.