-
-
Save KyMidd/0a04bb892666ea060d9eb16e7c2e5cdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def build_conversation_turn(content, message, headers): | |
| # Get sender name | |
| try: | |
| sender_name = message["from"]["user"]["displayName"] | |
| sender_role = "user" | |
| except: | |
| sender_role = "assistant" | |
| # Get text | |
| content_text = message.get("body", {}).get("content", "").strip() | |
| # Clean text, Teams adds a lot of extra html like this: "text": "Kyler Middleton says: <p>Hey Vera, what's up today? </p>" | |
| content_text = re.sub(r"<[^>]+>", "", content_text) | |
| content_text = content_text.replace(" ", " ") | |
| # Set the content block | |
| if sender_role == "user": | |
| content = [ | |
| { | |
| "text": f"{sender_name} says: {content_text}", | |
| } | |
| ] | |
| else: | |
| content = [ | |
| { | |
| "text": f"{content_text}", | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment