Skip to content

Commit

Permalink
Merge pull request #14 from TogetherCrew/fix/hivemind-received-intera…
Browse files Browse the repository at this point in the history
…ction

fix: the rabbitMQ couldn't handle sending objects!
  • Loading branch information
amindadgar authored Jan 18, 2024
2 parents edf422c + d3a4315 commit e647df7
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,18 @@ 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!")

interaction = json.loads(bot_given_info["content"]["interaction"])
chat_input_interaction = ChatInputCommandInteraction.from_dict(interaction)
create_interaction_content = Payload.DISCORD_BOT.INTERACTION_RESPONSE.Create(
interaction=bot_given_info.to_dict(),
interaction=chat_input_interaction,
data=InteractionResponse(
type=4,
data=InteractionCallbackData(
Expand Down Expand Up @@ -78,7 +84,7 @@ def ask_question_auto_search(
}

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 e647df7

Please sign in to comment.