File size: 498 Bytes
ec9d18e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Run."""
# pylint: disable=invalid-name
from random import choice
import gradio as gr

from convbot import convbot

lost_msg = [
    "I don't follow.",
    "Say it agan?",
    "Come again?",
    "I am afraid I dont't understand.",
    "I am lost.",
]


def bot(message: str) -> str:
    try:
        res = convbot(message)
    except Exception as exc:
        res = f"{choice(lost_msg)} (reason: {exc})"
    return res


iface = gr.Interface(fn=bot, inputs="text", outputs="text")
iface.launch()