threefoldtech / home

Starting point for the threefoldtech organization
https://threefold.io
Apache License 2.0
9 stars 4 forks source link

chatbot improvements 10.2 [development_fixes] #403

Closed despiegk closed 4 years ago

despiegk commented 4 years ago

improvements

questions

is not like a DSL

see /sandbox/code/github/threefoldtech/jumpscaleX_core/JumpscaleCore/servers/threebot/base_chatflows/food_get.py

def chat(bot):
    """
    to call http://localhost:5050/chat/session/food_get
    """
    html = """\
# Loading food...
 <div class="progress">
  <div class="progress-bar active" role="progressbar" aria-valuenow="{0}"
  aria-valuemin="0" aria-valuemax="100" style="width:{0}%">
    {0}%
  </div>
</div> 
"""

    res = {}
    waittime = bot.int_ask("Wait time")
    for x in range(waittime):
        bot.md_show_update(html.format((x / waittime) * 100))
        gevent.sleep(1)

    form = bot.new_form()
    food = form.string_ask("What do you need to eat?")
    amount = form.int_ask("Enter the amount you need to eat from %s in grams:" % food)
    sides = form.multi_choice("Choose your side dishes: ", ["rice", "fries", "saute", "mashed potato"])
    drink = form.single_choice("Choose your Drink: ", ["tea", "coffee", "lemon"])
    form.ask()

    res = """
    # You have ordered: 
    - {{amount.value}} grams, with sides {{sides.value}} and {{drink.value}} drink
    ### Click next 
    for the final step which will redirect you to threefold.me
    """
    res = j.tools.jinja2.template_render(text=j.core.text.strip(res), **locals())
    bot.md_show(res)
    bot.redirect("https://threefold.me")

not good

xmonader commented 4 years ago
xmonader commented 4 years ago

@despiegk I'll move to to start to pickup when you have the time to help with it

xmonader commented 4 years ago

state mgmt will be later in 10.3 maybe

Pishoy commented 4 years ago

@xmonader is it merged to development or verify it in development_chatbot ?

i verified in development_chatbot but got below error

JSX> cl = j.servers.threebot.local_start_default()                                                                                                                                                          
no server running need to start
++ '[' start == kill ']'
++ tmux -f /sandbox/cfg/.tmux.conf has-session -t main
no server running on /tmp/tmux-0/default
++ '[' 1 -eq 1 ']'
++ echo 'no server running need to start'
++ tmux -f /sandbox/cfg/.tmux.conf new -s main -d 'bash --rcfile /sandbox/bin/env_tmux_detach.sh'
++ '[' start '!=' start ']'
Sun 15 15:20:02 ystemFSDecorators.py - 156 - wrapper                            : EXCEPTION: 
    Argument fileFrom in j.sal.fs.copyFile expects an existing path value!
        /sandbox/lib/jumpscale/Jumpscale/servers/openresty/web_resources/lualib/redis.lua does not exist.
--TRACEBACK------------------
<stdin> in <module>
    1    
/sandbox/lib/jumpscale/Jumpscale/servers/threebot/ThreeBotServersFactory.py in local_start_default
    84    self.default.stop()
/sandbox/lib/jumpscale/Jumpscale/servers/threebot/ThreebotServer.py in stop
    381    self.openresty_server.stop()
/sandbox/lib/jumpscale/Jumpscale/servers/threebot/ThreebotServer.py in openresty_server
    93    name=f"{self.name}_openresty_threebot", executor=self.executor
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in get
    113    jsconfig = self._new(name=name, autosave=autosave, **kwargs)
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in _new
    93    jsconfig = jsconfig_klass(parent=self, jsxobject=jsxobject, **kwargs_to_class)
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSBase.py in __init__
    64    self._init(**kwargs)
/sandbox/lib/jumpscale/Jumpscale/servers/openresty/OpenRestyServer.py in _init
    47    self.install()
/sandbox/lib/jumpscale/Jumpscale/servers/openresty/OpenRestyServer.py in install
    104    j.core.tools.text_replace("/sandbox/openresty/lualib/redis.lua"),
/sandbox/lib/jumpscale/Jumpscale/sal/fs/SystemFSDecorators.py in wrapper
    156    raise j.exceptions.Value(msg)
-----------------------------

None
xmonader commented 4 years ago

check on development_fixes

Pishoy commented 4 years ago

food_get is stuck as below picture

JSX> cl3 = j.clients.gedis.get(name='default3',host='127.0.0.1', port=8901, package_name="zerobot.packagemanager")                                                                                          
JSX> cl3.actors.package_manager.package_add(path='/sandbox/code/github/threefoldtech/jumpscaleX_threebot/ThreeBotPackages/zerobot/chatbot_examples')                                                        
JSX> cl3.reload()                                                                                                                                                                                           

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/bottle.py", line 862, in _handle return route.call(args) File "/usr/local/lib/python3.6/dist-packages/bottle.py", line 1742, in wrapper rv = callback(*a, *ka) File "/usr/local/lib/python3.6/dist-packages/bottle_websocket/plugin.py", line 5, in wrapper callback(request.environ.get('wsgi.websocket'), args, kwargs) File "/sandbox/lib/jumpscale/threebot_packages/zerobot/webinterface/bottle/gedis.py", line 21, in gedis_websocket message = ws.receive() AttributeError: 'NoneType' object has no attribute 'receive'

- jsx version 

3BOTDEVEL:jsxtest:jumpscaleX_core: git log -1 commit 1e6a2ca5464b5904c91398822d67822a61e72f84 (HEAD -> development_fixes, origin/development_fixes) Author: Dina-Abd-Elrahman dena.elsayad@gmail.com Date: Wed Dec 18 12:50:41 2019 +0200

sshagent test cases

3BOTDEVEL:jsxtest:jumpscaleX_core: git log -1^C 3BOTDEVEL:jsxtest:jumpscaleX_core: cd ../jumpscaleX_threebot/ 3BOTDEVEL:jsxtest:jumpscaleX_threebot: git log -1 commit aaa8609a5d797abca89130dd1f887afdb4bfbd4c (HEAD -> development_fixes, origin/development_fixes) Merge: 6de20843 a73e2f8f Author: serboctor boctor.sarah@gmail.com Date: Tue Dec 17 15:59:16 2019 +0200

Merge branch 'development_fixes' of github.com:threefoldtech/jumpscaleX_threebot into development_fixes

![image](https://user-images.githubusercontent.com/21987477/71083488-ccedb780-219b-11ea-92c0-ba8b628b509a.png)
xmonader commented 4 years ago

Tested against wrong commits. closing.