Skip to content

Commit

Permalink
Refactor source message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
StanGirard committed Apr 22, 2024
1 parent a77f29e commit 422db14
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,21 @@ def ask_question(self, body, brain_id, thread_ts, question=None):
for source in sources
]
)
question_response["assistant"] += f"\n\n*Sources:*\n{source_text}"
# Send sources as a separate message
self.app.client.chat_postMessage(
channel=body["event"]["channel"],
text=f"*Sources:*\n{source_text}",
blocks=[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"*Sources:*\n{source_text}",
},
}
],
thread_ts=thread_ts,
)

# Split the message if it's too long
messages = [
Expand Down Expand Up @@ -448,7 +462,21 @@ def handle_iteractive_request(self, payload):
for source in sources
]
)
question_response["assistant"] += f"\n\n*Sources:*\n{source_text}"
# Send sources as a separate message
self.app.client.chat_postMessage(
channel=body["event"]["channel"],
text=f"*Sources:*\n{source_text}",
blocks=[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"*Sources:*\n{source_text}",
},
}
],
thread_ts=thread_ts,
)

# Split the message if it's too long
messages = [
Expand Down

0 comments on commit 422db14

Please sign in to comment.