Skip to content

Commit

Permalink
fix: the rabbitMQ couldn't handle sending objects!
Browse files Browse the repository at this point in the history
The celery is using rabbitMQ as its broker and it couldn't support the objects!
  • Loading branch information
amindadgar committed Jan 18, 2024
1 parent edf422c commit b906fe0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions celery_app/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
def ask_question_auto_search(
question: str,
community_id: str,
bot_given_info: ChatInputCommandInteraction,
bot_given_info: dict[str, Any],
) -> None:
"""
this task is for the case that the user asks a question
Expand All @@ -38,12 +38,15 @@ def ask_question_auto_search(
the community that the question was asked in
bot_given_info : tc_messageBroker.rabbit_mq.payload.discord_bot.chat_input_interaction.ChatInputCommandInteraction
the information data that needed to be sent back to the bot again.
This would be the `ChatInputCommandInteraction`.
This would be a dictionary representing the keys
- `event`
- `date`
- `content`: which is the `ChatInputCommandInteraction` as a dictionary
"""
prefix = f"COMMUNITY_ID: {community_id} | "
logging.info(f"{prefix}Processing question!")
create_interaction_content = Payload.DISCORD_BOT.INTERACTION_RESPONSE.Create(
interaction=bot_given_info.to_dict(),
interaction=bot_given_info,
data=InteractionResponse(
type=4,
data=InteractionCallbackData(
Expand Down Expand Up @@ -77,8 +80,11 @@ def ask_question_auto_search(
"source_nodes": source_nodes_dict,
}

interaction = json.loads(bot_given_info["content"]["interaction"])
chat_input_interaction = ChatInputCommandInteraction.from_dict(interaction)

response_payload = Payload.DISCORD_BOT.INTERACTION_RESPONSE.Edit(
interaction=bot_given_info.to_dict(),
interaction=chat_input_interaction,
data=InteractionCallbackData(content=json.dumps(results)),
).to_dict()

Expand Down
2 changes: 1 addition & 1 deletion worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def query_llm(recieved_data: dict[str, Any]):
ask_question_auto_search.delay(
question=user_input,
community_id=community_id,
bot_given_info=recieved_input,
bot_given_info=recieved_data,
)


Expand Down

0 comments on commit b906fe0

Please sign in to comment.