Skip to content

Commit

Permalink
Fixed issue with adding shouts to prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
kirgrim committed Feb 21, 2024
1 parent 4f05ed3 commit 64d0618
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
7 changes: 4 additions & 3 deletions chat_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ async def custom_http_exception_handler(request, exc):
allow_methods=["*"],
allow_headers=["*"],
)
static_suffix = (
"/build" if os.environ.get("KLAT_ENV", "dev").upper() == "PROD" else ""
)
# static_suffix = (
# "/build" if os.environ.get("KLAT_ENV", "dev").upper() == "PROD" else ""
# )
static_suffix = ""
chat_app.mount(
"/css",
StaticFiles(directory=f"chat_client/static/css{static_suffix}"),
Expand Down
10 changes: 9 additions & 1 deletion chat_server/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ async def user_message(sid, data):

mongo_queries.add_shout(data=new_shout_data)
if is_announcement == "0" and data.get("prompt_id"):
is_ok = MongoDocumentsAPI.PROMPTS.add_shout_to_prompt(data)
is_ok = MongoDocumentsAPI.PROMPTS.add_shout_to_prompt(
prompt_id=data["prompt_id"],
user_id=data["userID"],
message_id=data["message_id"],
prompt_state=data["promptState"],
)
if is_ok:
await sio.emit(
"new_prompt_message",
Expand Down Expand Up @@ -312,6 +317,8 @@ async def prompt_completed(sid, data):
"""
prompt_id = data["context"]["prompt"]["prompt_id"]

LOG.info(f"setting {prompt_id = } as completed")

MongoDocumentsAPI.PROMPTS.set_completed(
prompt_id=prompt_id, prompt_context=data["context"]
)
Expand Down Expand Up @@ -704,6 +711,7 @@ async def emit_error(
"""
if not context:
context = {}
LOG.error(message)
await sio.emit(
context.pop("callback_event", "klatchat_sio_error"),
data={"msg": message},
Expand Down
6 changes: 3 additions & 3 deletions services/klatchat_observer/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,19 +712,19 @@ def handle_saving_prompt_data(self, body: dict):
@create_mq_callback()
def on_stt_response(self, body: dict):
"""Handles receiving STT response"""
LOG.info(f"Received STT Response: {body}")
LOG.debug(f"Received STT Response: {body}")
self.sio.emit("stt_response", data=body)

@create_mq_callback()
def on_tts_response(self, body: dict):
"""Handles receiving TTS response"""
LOG.info(f"Received TTS Response: {body}")
LOG.debug(f"Received TTS Response: {body}")
self.sio.emit("tts_response", data=body)

@create_mq_callback()
def on_subminds_state(self, body: dict):
"""Handles receiving subminds state message"""
LOG.info(f"Received submind state: {body}")
LOG.debug(f"Received submind state: {body}")
body["msg_type"] = "subminds_state"
self.sio.emit("broadcast", data=body)

Expand Down
3 changes: 2 additions & 1 deletion utils/database_utils/mongo_utils/queries/dao/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_prompts(

def add_shout_to_prompt(
self, prompt_id: str, user_id: str, message_id: str, prompt_state: PromptStates
):
) -> bool:
prompt = self.get_item(item_id=prompt_id)
if prompt and prompt["is_completed"] == "0":
if (
Expand Down Expand Up @@ -157,6 +157,7 @@ def add_shout_to_prompt(
data={f"data.{store_key}": store_data},
data_action="push" if store_type == list else "set",
)
return True

def _add_participant(self, prompt_id: str, user_id: str):
return self._execute_query(
Expand Down

0 comments on commit 64d0618

Please sign in to comment.