Skip to content

Commit 1dadc0b

Browse files
committed
🐛 FIX: threads implementation
1 parent a963d8b commit 1dadc0b

File tree

7 files changed

+9
-14
lines changed

7 files changed

+9
-14
lines changed

examples/threads/threads.append.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main():
1919
lb = Langbase(api_key=langbase_api_key)
2020

2121
# Thread ID to append messages to
22-
thread_id = "thread_123456789" # Replace with your actual thread ID
22+
thread_id = "thread_123" # Replace with your actual thread ID
2323

2424
# Messages to append
2525
messages = [

examples/threads/threads.delete.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ def main():
1919
lb = Langbase(api_key=langbase_api_key)
2020

2121
# Thread ID to delete
22-
thread_id = (
23-
"431bac51-929c-4257-8251-baefcd251d3a" # Replace with your actual thread ID
24-
)
22+
thread_id = "thread_123" # Replace with your actual thread ID
2523

2624
# Delete the thread
2725
try:

examples/threads/threads.get.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main():
2020
lb = Langbase(api_key=langbase_api_key)
2121

2222
# Thread ID to retrieve
23-
thread_id = "thread-123" # Replace with your thread ID
23+
thread_id = "thread_123" # Replace with your thread ID
2424

2525
# Get the specific thread
2626
try:

examples/threads/threads.messages.list.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def main():
2121

2222
# List all threads
2323
try:
24-
threads = lb.threads.messages.list(
25-
thread_id="3a958893-6175-4d96-9053-876ff1b37227"
26-
)
24+
threads = lb.threads.messages.list(thread_id="thread_123")
2725

2826
print(json.dumps(threads, indent=2))
2927

examples/threads/threads.update.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main():
2020
lb = Langbase(api_key=langbase_api_key)
2121

2222
# Thread ID to update
23-
thread_id = "thread_123456789" # Replace with your actual thread ID
23+
thread_id = "thread_123" # Replace with your actual thread ID
2424

2525
# New metadata to set for the thread
2626
updated_metadata = {
@@ -31,7 +31,8 @@ def main():
3131
# Update the thread metadata
3232
try:
3333
updated_thread = lb.threads.update(
34-
{"thread_id": thread_id, "metadata": updated_metadata}
34+
thread_id=thread_id,
35+
metadata=updated_metadata,
3536
)
3637

3738
print(json.dumps(updated_thread, indent=2))

langbase/primitives/threads.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ def append(
121121
Returns:
122122
List of added messages
123123
"""
124-
options = {"messages": messages}
125-
126124
return self.request.post(
127-
THREAD_MESSAGES_ENDPOINT.format(thread_id=thread_id), options
125+
THREAD_MESSAGES_ENDPOINT.format(thread_id=thread_id), messages
128126
)

tests/test_threads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def test_threads_append(self, langbase_client, mock_responses):
224224
assert len(responses.calls) == 1
225225
request = responses.calls[0].request
226226
validate_response_headers(request.headers, AUTH_AND_JSON_CONTENT_HEADER)
227-
assert json.loads(request.body) == {"messages": request_body["messages"]}
227+
assert json.loads(request.body) == request_body["messages"]
228228
assert (
229229
request.url
230230
== f"{BASE_URL}{THREAD_MESSAGES_ENDPOINT.format(thread_id=thread_id)}"

0 commit comments

Comments
 (0)