Skip to content

Commit 3956a97

Browse files
author
Jarno Ensio Hakulinen
committed
remove threads config file writing by default
1 parent d9f6fba commit 3956a97

5 files changed

Lines changed: 41 additions & 11 deletions

File tree

sdk/azure-ai-assistant/azure/ai/assistant/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "0.3.4a1"
9+
VERSION = "0.3.5a1"

sdk/azure-ai-assistant/azure/ai/assistant/management/assistant_config_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def load_configs(self) -> None:
158158
try:
159159
config_files = os.listdir(self._config_folder)
160160
except FileNotFoundError:
161-
logger.warning("No assistant configurations found in the config folder.")
161+
logger.warning(f"No assistant configurations found in the folder '{self._config_folder}'")
162162
return
163163

164164
loaded_assistants = set() # Track loaded assistant names to prevent duplicates

sdk/azure-ai-assistant/azure/ai/assistant/management/async_conversation_thread_client.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,36 @@ class AsyncConversationThreadClient:
2626
2727
:param ai_client_type: The type of the AI client to use.
2828
:type ai_client_type: AIClientType
29+
:param config_folder: The folder to save the thread config to.
30+
:type config_folder: str, optional
2931
:param client_args: The arguments to pass to the AI client.
3032
:type client_args: dict
3133
"""
32-
def __init_private(self, ai_client_type, **client_args):
34+
def __init_private(
35+
self,
36+
ai_client_type,
37+
config_folder : Optional[str] = None,
38+
**client_args
39+
):
3340
self._ai_client_type = ai_client_type
3441
self._ai_client : Union[AsyncOpenAI, AsyncAzureOpenAI] = AIClientFactory.get_instance().get_client(self._ai_client_type, **client_args)
35-
self._thread_config = ConversationThreadConfig(self._ai_client_type, 'config/threads.json')
42+
self._thread_config = ConversationThreadConfig(self._ai_client_type, config_folder)
3643
self._assistant_config_manager = AssistantConfigManager.get_instance()
3744

3845
@classmethod
3946
def get_instance(
4047
cls,
4148
ai_client_type : AsyncAIClientType,
49+
config_folder : Optional[str] = None,
4250
**client_args
4351
) -> 'AsyncConversationThreadClient':
4452
"""
4553
Get the singleton instance of the AsyncConversationThreadClient.
4654
4755
:param ai_client_type: The type of the AI client to use.
4856
:type ai_client_type: AsyncAIClientType
57+
:param config_folder: The folder to save the thread config to.
58+
:type config_folder: str, optional
4959
:param client_args: The arguments to pass to the AI client.
5060
:type client_args: dict
5161
@@ -56,7 +66,7 @@ def get_instance(
5666
with cls._lock:
5767
if ai_client_type not in cls._instances:
5868
instance = cls.__new__(cls)
59-
instance.__init_private(ai_client_type, **client_args)
69+
instance.__init_private(ai_client_type, config_folder, **client_args)
6070
cls._instances[ai_client_type] = instance
6171
return cls._instances[ai_client_type]
6272

sdk/azure-ai-assistant/azure/ai/assistant/management/conversation_thread_client.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,36 @@ class ConversationThreadClient:
2626
2727
:param ai_client_type: The type of the AI client to use.
2828
:type ai_client_type: AIClientType
29+
:param config_folder: The folder to save the thread config to.
30+
:type config_folder: str, optional
2931
:param client_args: The arguments to pass to the AI client.
3032
:type client_args: dict
3133
"""
32-
def __init_private(self, ai_client_type, **client_args):
34+
def __init_private(
35+
self,
36+
ai_client_type,
37+
config_folder : Optional[str] = None,
38+
**client_args
39+
):
3340
self._ai_client_type = ai_client_type
3441
self._ai_client : Union[OpenAI, AzureOpenAI] = AIClientFactory.get_instance().get_client(self._ai_client_type, **client_args)
35-
self._thread_config = ConversationThreadConfig(self._ai_client_type, 'config/threads.json')
42+
self._thread_config = ConversationThreadConfig(self._ai_client_type, config_folder)
3643
self._assistant_config_manager = AssistantConfigManager.get_instance()
3744

3845
@classmethod
3946
def get_instance(
4047
cls,
4148
ai_client_type : AIClientType,
49+
config_folder : Optional[str] = None,
4250
**client_args
4351
) -> 'ConversationThreadClient':
4452
"""
4553
Get the singleton instance of the ConversationThreadClient.
4654
4755
:param ai_client_type: The type of the AI client to use.
4856
:type ai_client_type: AIClientType
57+
:param config_folder: The folder to save the thread config to.
58+
:type config_folder: str, optional
4959
:param client_args: The arguments to pass to the AI client.
5060
:type client_args: dict
5161
@@ -56,7 +66,7 @@ def get_instance(
5666
with cls._lock:
5767
if ai_client_type not in cls._instances:
5868
instance = cls.__new__(cls)
59-
instance.__init_private(ai_client_type, **client_args)
69+
instance.__init_private(ai_client_type, config_folder, **client_args)
6070
cls._instances[ai_client_type] = instance
6171
return cls._instances[ai_client_type]
6272

sdk/azure-ai-assistant/azure/ai/assistant/management/conversation_thread_config.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from azure.ai.assistant.management.logger_module import logger
66

77
import json, os
8+
from typing import Optional
89

910

1011
class ConversationThreadConfig:
@@ -18,11 +19,14 @@ class ConversationThreadConfig:
1819
"""
1920
def __init__(
2021
self,
21-
ai_client_type: AIClientType,
22-
config_file
22+
ai_client_type: AIClientType,
23+
config_folder : Optional[str] = None,
2324
) -> None:
2425
self._ai_client_type = ai_client_type.name
25-
self._config_file = config_file
26+
if config_folder:
27+
self._config_file = os.path.join(config_folder, 'threads.json')
28+
else:
29+
self._config_file = None
2630
self._config_data = {}
2731
self._current_thread_id = None
2832
self._threads = []
@@ -185,6 +189,9 @@ def get_all_threads(self) -> list:
185189
:rtype: list
186190
"""
187191
# create config file if it doesn't exist
192+
if self._config_file is None:
193+
return []
194+
188195
try:
189196
with open(self._config_file, 'r') as f:
190197
pass
@@ -310,6 +317,9 @@ def save_to_json(self) -> None:
310317
"""
311318
Save the configuration for the specific ai_client_type to a JSON file.
312319
"""
320+
if self._config_file is None:
321+
return
322+
313323
# Ensure the directory exists
314324
os.makedirs(os.path.dirname(self._config_file), exist_ok=True)
315325

0 commit comments

Comments
 (0)