Skip to content

Commit

Permalink
Cleanup changes
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
NeonDaniel committed Dec 8, 2023
1 parent 8f781fd commit 949b827
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ chatbots:
> bots, `bot_id` is the MQ `service_name`.

Any bot-specific configuration will be accessible as `self.bot_config`. For Klat
v1 connections, `username` and `password` should be specified in the `chatbots`
v1 connections, `password` should be specified in the `chatbots`
config section.

#### MQ Connection configuration
Expand All @@ -50,6 +50,14 @@ MQ:
password: <MQ user `neon_bot_submind`'s password>
```

#### SocketIO Connection configuration
For v1 bots, SIO connections may be configured in `~/.config/neon/chatbots.yaml`:
```yaml
socket_io:
server: 2222.us
port: 8888
```
### Organizing your bots
It is recommended to create a module for each of your bots. You should use subdirectories, each containing `__init__.py`
that includes your `ChatBot` as well as any supporting configuration files, etc. You may also organize this as a
Expand Down
4 changes: 1 addition & 3 deletions chatbot_core/utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ def start_bots(domain: str = None, bot_dir: str = None, username: str = None,
credentials = load_credentials_yml(cred_file)
else:
credentials = {}
# TODO: Else read from Configuration
processes = []

# Check for specified bot to start
Expand Down Expand Up @@ -604,8 +603,7 @@ def run_mq_bot(chatbot_name: str, vhost: str = '/chatbots',
@returns: Started ChatBotV2 instance
"""
from neon_utils.log_utils import init_log
init_log({"logs": {"level_overrides": {"error": ['pika', 'chatterbot'],
"warning": ["filelock"]}}})
init_log(log_name=chatbot_name)
os.environ['CHATBOT_VERSION'] = 'v2'
run_kwargs = run_kwargs or dict()
init_kwargs = init_kwargs or dict()
Expand Down
10 changes: 7 additions & 3 deletions chatbot_core/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ def __init__(self, *args, **kwargs):
socket, domain, username, password, on_server, is_prompter = \
self.parse_init(*args, **kwargs)
LOG.info(f"Starting {username}")
socket = socket or start_socket()
ChatBotABC.__init__(self, username)
if not socket:
from ovos_config.config import Configuration
sio_config = Configuration().get("socket_io", {})
socket = start_socket(addr=sio_config.get("server"),
port=sio_config.get("port"))
init_nick = "Prompter" if is_prompter else ""
KlatApi.__init__(self, socket, domain, init_nick)
ChatBotABC.__init__(self, username)
# self.log.debug("Connector started")
self.on_server = on_server
self.is_prompter = is_prompter
Expand All @@ -52,7 +56,7 @@ def __init__(self, *args, **kwargs):
self.selected_history = list()

self.username = username
self.password = password
self.password = password or self.bot_config.get("password")

self.facilitator_nicks = ["proctor", "scorekeeper", "stenographer"]
self.response_probability = 75 # % probability for a bot to respond to an input in non-proctored conversation
Expand Down
1 change: 0 additions & 1 deletion chatbot_core/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(self, *args, **kwargs):
config, service_name, vhost, bot_type = self.parse_init(*args, **kwargs)
mq_config = config.get("MQ") or config
bot_config = config.get("chatbots", {}).get(service_name)
# TODO: Parse config here for MQ config section vs chatbot config
KlatAPIMQ.__init__(self, mq_config, service_name, vhost)
ChatBotABC.__init__(self, service_name, bot_config)
self.bot_type = bot_type
Expand Down

0 comments on commit 949b827

Please sign in to comment.