Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Integrate with discord slash commands #12

Merged
merged 18 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update: Added hivemind-bot thinking process!
We needed to let the discord-bot know if the hivemind-bot is working, else after two second the discord-bot would raise an error.
  • Loading branch information
amindadgar committed Jan 10, 2024
commit 87eefcd5dcb2a9b8ee1499fbfd6adbce90fc1a84
24 changes: 20 additions & 4 deletions celery_app/tasks.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
from tc_messageBroker.rabbit_mq.payload.discord_bot.base_types.interaction_callback_data import (
InteractionCallbackData,
)
from tc_messageBroker.rabbit_mq.payload.discord_bot.interaction_response import InteractionResponse
from tc_messageBroker.rabbit_mq.payload.discord_bot.chat_input_interaction import (
ChatInputCommandInteraction,
)
@@ -36,6 +37,22 @@ def ask_question_auto_search(
the information data that needed to be sent back to the bot again.
This would be the `ChatInputCommandInteraction`.
"""
create_interaction_content = Payload.DISCORD_BOT.INTERACTION_RESPONSE.Create(
interaction=bot_given_info.to_dict(),
data=InteractionResponse(
type=4,
data=InteractionCallbackData(
content="Processing your question ...",
flags=64
),
),
).to_dict()

job_send(
event=Event.DISCORD_BOT.INTERACTION_RESPONSE.CREATE,
queue_name=Queue.DISCORD_BOT,
content=create_interaction_content,
)

# for now we have just the discord platform
response, source_nodes = query_multiple_source(
@@ -55,14 +72,13 @@ def ask_question_auto_search(
"source_nodes": source_nodes_dict,
}

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

job_send(
event=Event.DISCORD_BOT.INTERACTION_RESPONSE.CREATE,
event=Event.DISCORD_BOT.INTERACTION_RESPONSE.EDIT,
queue_name=Queue.DISCORD_BOT,
content=response_payload,
)