Closed orenneiberg closed 1 month ago
Great suggesstion! I faced the same issue and was thinking of using async thread instead of thread in agency class
This issue is stale because it has been open for 30 days with no activity. Please upgrade to the latest version and test it again.
This issue was closed because it has been inactive for 14 days since being marked as stale. If the issue still persists, please reopen.
I have encountered a limitation in the
Agncy
class, specifically within theget_completion
method. This method interacts with the Assistant API but does not currently support managing multiple threads effectively when several users interact with the same agency simultaneously.The core of the issue lies in the inability to manage conversation threads and shared states uniquely for each user. This leads to potential conflicts or incorrect handling of state when multiple users interact with the agency concurrently.
Proposed Change: I propose adding an enhancement to the
get_completion
method allowing it to accept athread_id
argument. This would enable:Thread-specific interaction history management: By passing a unique
thread_id
per user session, the library can maintain separate interaction histories, ensuring that responses and states are correctly handled on a per-user basis.State management enhancement: Alongside the thread management, modifying the shared state handling to be thread-specific would prevent users from affecting each other’s state during concurrent interactions.
Example: Here's a simple example of how the enhanced method could be called:
response = agency.get_completion(prompt="Hello, how can I assist you today?", thread_id=user_session_id)