-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
81 lines (59 loc) · 2.29 KB
/
main.py
File metadata and controls
81 lines (59 loc) · 2.29 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import asyncio
import logging
from dotenv import load_dotenv
from src.utils.commandline import CommandLine
from src.utils.config import CLIArgs
load_dotenv()
def main():
from src.graph.node_map import NODE_MAP
from src.queue.rabbit_client import RabbitClient
from src.voice.listen import Listen
try:
rabbit_client = RabbitClient()
except Exception as e:
logging.error(
"Error connecting to RabbitMQ. Use `make rabbitmq` to start a container.\nExiting...")
logging.error(e)
return
# Create a queue for the node if needed. Useful for your own integrations.
def create_queues():
for node_type in NODE_MAP:
create_queue = NODE_MAP[node_type].create_queue
if create_queue:
rabbit_client.create_queue(node_type)
# Used for logging and easily fine-tuning the AI
queue_args = {'x-max-length': 10}
rabbit_client.create_queue(
"ai.builder.responses", arguments=queue_args)
rabbit_client.create_queue(
"ai.personality.responses", arguments=queue_args)
# Used to signal for thinking/idle
rabbit_client.create_queue("request.status", arguments=queue_args)
create_queues()
def _on_interrupt():
logging.info("Exiting...")
rabbit_client.close()
listener = Listen(rabbit_client)
listener.on_interrupt_callback = _on_interrupt
listener.start()
def load_config():
args = CommandLine().read_command_line()
CLIArgs.update_from_args(args)
def configure_logging():
logging.getLogger('httpx').setLevel(logging.WARNING)
logging.getLogger('asyncio').setLevel(logging.WARNING)
logging.getLogger('aio_pika').setLevel(logging.WARNING)
logging.getLogger('pika').setLevel(logging.WARNING)
logging.getLogger('httpcore').setLevel(logging.WARNING)
logging.getLogger('openai').setLevel(logging.WARNING)
logging.getLogger('faster_whisper').setLevel(logging.WARNING)
if CLIArgs.verbose:
logging.basicConfig(level=logging.DEBUG,
format='%(name)s: %(message)s')
else:
logging.basicConfig(level=logging.INFO,
format='%(name)s: %(message)s')
if __name__ == "__main__":
load_config()
configure_logging()
main()