Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
2import logging
5def main():
6 # Parse CLI arguments
7 from askbob.util import make_argument_parser
8 parser = make_argument_parser()
9 args = parser.parse_args()
11 # Parse runtime configuration file values
12 import configparser
13 config = configparser.ConfigParser()
15 if not config.read(args.config):
16 logging.error(
17 f"The runtime configuration file {args.config} could not be loaded.")
18 return False
20 if args.setup: 20 ↛ 22line 20 didn't jump to line 22, because the condition on line 20 was never true
21 # Train and setup the assistant
22 from .setup import setup
23 setup(args, config)
24 else:
25 if 'Rasa' not in config or 'model' not in config['Rasa']:
26 logging.error(
27 "Missing Rasa.model location in the runtime configuration file.")
28 return False
30 if args.voice and not args.serve:
31 logging.error(
32 "The -v flag must be used in conjunction with the -s flag.")
33 return False
35 # Run the voice assistant
36 from askbob.action.responder import RasaResponseService
37 responder = RasaResponseService(
38 config['Rasa']['model'],
39 config['Plugins'].get('location', 'plugins'),
40 config['Plugins'].getint('action_server_port', fallback=5055)
41 ) if 'Plugins' in config else RasaResponseService(config['Rasa']['model'])
43 if args.serve: 43 ↛ 53line 43 didn't jump to line 53, because the condition on line 43 was never false
44 if 'Server' not in config: 44 ↛ 49line 44 didn't jump to line 49, because the condition on line 44 was never false
45 logging.error("No server configuration provided.")
46 return False
48 # Run Ask Bob in server mode
49 from .server import serve
50 serve(responder, config, args.voice)
51 else:
52 # Run Ask Bob in interactive mode
53 from askbob.loop import interactive_loop
54 import asyncio
55 asyncio.run(interactive_loop(args, config, responder))
58if __name__ == '__main__':
59 main()