From 3cd4a39c4947d50dd93f29f122c7b0922c122a62 Mon Sep 17 00:00:00 2001
From: Jarno Ensio Hakulinen <jhakulin@microsoft.com>
Date: Sun, 5 May 2024 08:55:32 -0700
Subject: [PATCH] update

---
 .../async_conversation_thread_client.py       | 28 +++++++++++++------
 .../management/conversation_thread_client.py  | 28 +++++++++++++------
 2 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/sdk/azure-ai-assistant/azure/ai/assistant/management/async_conversation_thread_client.py b/sdk/azure-ai-assistant/azure/ai/assistant/management/async_conversation_thread_client.py
index 2d74c2c..e67913e 100644
--- a/sdk/azure-ai-assistant/azure/ai/assistant/management/async_conversation_thread_client.py
+++ b/sdk/azure-ai-assistant/azure/ai/assistant/management/async_conversation_thread_client.py
@@ -275,15 +275,25 @@ async def create_conversation_thread_message(
             thread_id = self._thread_config.get_thread_id_by_name(thread_name)
             attachments = await self._update_message_attachments(thread_id, attachments) if attachments is not None else []
 
-            # Create the message with the attachments
-            await self._ai_client.beta.threads.messages.create(
-                thread_id,
-                role=role,
-                metadata=metadata,
-                attachments=attachments,
-                content=message,
-                timeout=timeout
-            )
+            if attachments:
+                # Create the message with the attachments
+                await self._ai_client.beta.threads.messages.create(
+                    thread_id,
+                    role=role,
+                    metadata=metadata,
+                    attachments=attachments,
+                    content=message,
+                    timeout=timeout
+                )
+            else:
+                # Create the message without attachments
+                await self._ai_client.beta.threads.messages.create(
+                    thread_id,
+                    role=role,
+                    metadata=metadata,
+                    content=message,
+                    timeout=timeout
+                )
 
             logger.info(f"Created message: {message} in thread: {thread_id}, attachments: {attachments}")
         except Exception as e:
diff --git a/sdk/azure-ai-assistant/azure/ai/assistant/management/conversation_thread_client.py b/sdk/azure-ai-assistant/azure/ai/assistant/management/conversation_thread_client.py
index f4354c5..c696cbd 100644
--- a/sdk/azure-ai-assistant/azure/ai/assistant/management/conversation_thread_client.py
+++ b/sdk/azure-ai-assistant/azure/ai/assistant/management/conversation_thread_client.py
@@ -275,15 +275,25 @@ def create_conversation_thread_message(
             thread_id = self._thread_config.get_thread_id_by_name(thread_name)
             attachments = self._update_message_attachments(thread_id, attachments) if attachments is not None else []
 
-            # Create the message with the attachments
-            self._ai_client.beta.threads.messages.create(
-                thread_id,
-                role=role,
-                metadata=metadata,
-                attachments=attachments,
-                content=message,
-                timeout=timeout
-            )
+            if attachments:
+                # Create the message with the attachments
+                self._ai_client.beta.threads.messages.create(
+                    thread_id,
+                    role=role,
+                    metadata=metadata,
+                    attachments=attachments,
+                    content=message,
+                    timeout=timeout
+                )
+            else:
+                # Create the message without attachments
+                self._ai_client.beta.threads.messages.create(
+                    thread_id,
+                    role=role,
+                    metadata=metadata,
+                    content=message,
+                    timeout=timeout
+                )
 
             logger.info(f"Created message: {message} in thread: {thread_id}, attachments: {attachments}")
         except Exception as e: