It is a pity that openai does not have a programmatic way of listing threads. I had to devise a whole new way of using assistants to list threads of specific types. The demo is from within the betaassi framework; as I need it to do streaming with the Assistant API.
SPOILER ALERT: This way of enablement is fairly limiting. YMMV. But someone might find it helpful. Also the streaming is with Assistant API; but under the hoofd it makes use of chat completion. This streaming is NOT part of the framework. Just core components are.
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from openai_session_handler.models.threads.multithread_basethread import MultiThreadBaseThread
>>>
>>>
>>>
>>> MultiThreadBaseThread.list()
[]
>>>
>>>
>>>
>>> MultiThreadBaseThread.create()
MultiThreadBaseThread(id='thread_Ayzpqw7gaGCWaDrN83YPspUm', object='thread', created_at=1708489530, metadata={'pub_thread': 'thread_qq96g4sDYSV71L34PSL483bq', 'thread_type': 'MultiThreadBaseThread'}, thread_type='MultiThreadBaseThread', pub_thread='thread_qq96g4sDYSV71L34PSL483bq')
>>>
>>>
>>>
>>> MultiThreadBaseThread.list()
[Thread(thread_id='thread_Ayzpqw7gaGCWaDrN83YPspUm')]
>>>
>>>
>>> MultiThreadBaseThread.create()
MultiThreadBaseThread(id='thread_AMvRbkpR9L1LqFuv0YGwwgiT', object='thread', created_at=1708489570, metadata={'pub_thread': 'thread_6TD04iWFtIYpc8H4bK1jYbkb', 'thread_type': 'MultiThreadBaseThread'}, thread_type='MultiThreadBaseThread', pub_thread='thread_6TD04iWFtIYpc8H4bK1jYbkb')
>>>
>>>
>>> MultiThreadBaseThread.list()
[Thread(thread_id='thread_Ayzpqw7gaGCWaDrN83YPspUm'), Thread(thread_id='thread_AMvRbkpR9L1LqFuv0YGwwgiT')]
>>>
>>>
>>> MultiThreadBaseThread.delete('thread_Ayzpqw7gaGCWaDrN83YPspUm')
ThreadDeleted(id='thread_Ayzpqw7gaGCWaDrN83YPspUm', deleted=True, object='thread.deleted')
>>>
>>>
>>> MultiThreadBaseThread.list()
[Thread(thread_id='thread_AMvRbkpR9L1LqFuv0YGwwgiT')]
>>>
>>> MultiThreadBaseThread.delete('thread_AMvRbkpR9L1LqFuv0YGwwgiT')
ThreadDeleted(id='thread_AMvRbkpR9L1LqFuv0YGwwgiT', deleted=True, object='thread.deleted')
>>>
>>> MultiThreadBaseThread.list()
For the interested, here the github link (GitHub - icdev2dev/betaassi: "betaassi: An innovative Python package for seamless integration and management of OpenAI sessions, designed to enhance developer experience with asynchronous server support and extendable classes).