Skip to content

Commit

Permalink
Add chatbots_observer MQ user for Chatbots implementation
Browse files Browse the repository at this point in the history
Update Klat deployment to support latest changes
  • Loading branch information
NeonDaniel committed May 21, 2024
1 parent 823b3c9 commit a710b7f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
43 changes: 35 additions & 8 deletions neon_diana_utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,19 @@ def configure_klat_chat(external_url: str = None,
if subdomain != "www":
forward_www = click.confirm(f"Route www.{domain} traffic to Klat?")

# Confirm admin login
username = "admin"
password = None
confirmed = False
while not confirmed:
username = click.prompt("Klat admin username", type=str,
default=username)
password = click.prompt("Klat admin password", type=str,
default=password)
confirmed = click.confirm(f"Is `{username}`/`{password}` correct?")
klat_admin = {"KLAT_AUTH_CREDENTIALS": {"username": username,
"password": password}}

# Get Libretranslate HTTP API URL
libretranslate_url = "https://libretranslate.2022.us"
confirmed = False
Expand Down Expand Up @@ -1018,15 +1031,27 @@ def configure_klat_chat(external_url: str = None,
click.echo(pformat(sftp_config))
confirmed = click.confirm("Is this configuration correct?")

# Configure k8s management
confirmed = False
k8s_ns = "default"
while not confirmed:
k8s_ns = click.prompt("Kubernetes Namespace", type=str,
default=k8s_ns)
confirmed = click.confirm(f"Is this `{k8s_ns}` correct?")

# Define klat.yaml config
config = {"SIO_URL": api_url,
"MQ": {"users": {"chat_observer": user_config},
"server": "neon-rabbitmq",
"port": 5672},
config = {"CHAT_OBSERVER": {"SIO_URL": api_url,
"MQ": {"users": {"chat_observer": user_config},
"server": "neon-rabbitmq",
"port": 5672},
"KLAT_AUTH_CREDENTIALS": klat_admin,
"SCAN_NEON_SERVICE": False},
"CHAT_CLIENT": {"SERVER_URL": api_url,
"FORCE_HTTPS": https,
"RUNTIME_CONFIG": {
"CHAT_SERVER_URL_BASE": api_url}},
# TODO: `CHAT_SERVER_URL_BASE` is deprecated
"CHAT_SERVER_URL_BASE": api_url,
"MAX_CONVERSATIONS_PER_PAGE": 4}},
"CHAT_SERVER": {"DEBUG": True,
"MINIFY": False,
"SERVER_IP": "klat-chat-server",
Expand All @@ -1036,9 +1061,11 @@ def configure_klat_chat(external_url: str = None,
"SECRET": "775115fdecb9b4971193b919d27d410a",
"JWT_ALGO": "HS256"},
"LIBRE_TRANSLATE_URL": libretranslate_url,
"SFTP": sftp_config
},
"DATABASE_CONFIG": mongo_config}
"SFTP": sftp_config,
"K8S_CONFIG": {"K8S_DEFAULT_NAMESPACE": k8s_ns,
"K8S_CONFIG_PATH": "kube_config"},
"DATABASE_CONFIG": mongo_config}
}

if orchestrator == Orchestrator.KUBERNETES:
shutil.copytree(join(dirname(__file__), "templates", "klat"),
Expand Down
15 changes: 15 additions & 0 deletions neon_diana_utils/templates/rmq_backend_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ users:
password:
tags:
- chatbots
- name: "chatbots_observer"
password:
tags:
- klat
- chatbots
vhosts:
- name: "/neon_emails"
- name: "/neon_api"
Expand Down Expand Up @@ -225,4 +230,14 @@ permissions:
vhost: "/translation"
configure: ".*"
write: ".*"
read: ".*"
- user: "chat_observer"
vhost: "/llm"
configure: ".*"
write: ".*"
read: ".*"
- user: "chatbots_observer"
vhost: "/chatbots"
configure: ".*"
write: ".*"
read: ".*"

0 comments on commit a710b7f

Please sign in to comment.