-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Pawel/eng 651 threads management #29
Conversation
ENG-651 Update the Thread management in the sdk
Right now the We need to:
|
d27295e
to
b0b3619
Compare
chainlit_client/thread.py
Outdated
): | ||
self.client = client | ||
if thread_id is None: | ||
thread_id = str(uuid.uuid4()) | ||
self.thread_id = thread_id | ||
active_thread_id_var.set(thread_id) | ||
self.thread = Thread(id=thread_id) | ||
needs_upsert = kwargs != {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of the needs_upsert concept. Plus this check is always false because it is going to do a reference comparison right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is" keyword is for reference comparison.
>>> k = {}
>>> k == {}
True
>>> k is {}
False
>>> k = {"foo": "bar"}
>>> k == {}
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started by doing a hash comparision and only update on exit when the hash is different but decided against it because this solution seems simpler.
Do you have any preferences on how to do this ?
chainlit_client/thread.py
Outdated
async def save(self): | ||
thread = active_thread_var.get() | ||
thread_data = thread.to_dict() | ||
thread_data.pop("steps", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we keep the steps in the thread class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is to programatically browser the thread's steps
I have no strong opinion about this
be5b87c
to
5a18e5f
Compare
8ec22c9
to
5a9e466
Compare
chainlit_client/thread.py
Outdated
@@ -34,6 +36,7 @@ def __init__( | |||
self.metadata = metadata | |||
self.tags = tags | |||
self.user = user | |||
self.needs_upsert = bool(metadata or tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think user should trigger an uspert
chainlit_client/thread.py
Outdated
thread_data = { | ||
"id": thread_data["id"], | ||
"metadata": thread_data.get("metadata"), | ||
"tags": thread_data.get("tags"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, why we do not account for user?
5a9e466
to
a9c0826
Compare
a9c0826
to
c33ddcd
Compare
Can you provide an example of what is now possible ? Should we also add this example in the docs? |
No description provided.