tangled
alpha
login
or
join now
zzstoatzz.io
/
bot
1
fork
atom
a digital entity named phi that roams bsky
1
fork
atom
overview
issues
pulls
1
pipelines
Add thread context test script
zzstoatzz.io
7 months ago
d22a4d30
7ea3a88e
+56
1 changed file
expand all
collapse all
unified
split
scripts
test_thread_context.py
+56
scripts/test_thread_context.py
···
1
1
+
#!/usr/bin/env python
2
2
+
"""Test thread context by simulating a conversation"""
3
3
+
4
4
+
import asyncio
5
5
+
from bot.database import thread_db
6
6
+
7
7
+
8
8
+
async def test_thread_context():
9
9
+
"""Test thread database and context generation"""
10
10
+
print("🧪 Testing Thread Context")
11
11
+
12
12
+
# Test thread URI
13
13
+
thread_uri = "at://did:example:123/app.bsky.feed.post/abc123"
14
14
+
15
15
+
# Add some messages
16
16
+
print("\n📝 Adding messages to thread...")
17
17
+
thread_db.add_message(
18
18
+
thread_uri=thread_uri,
19
19
+
author_handle="alice.bsky",
20
20
+
author_did="did:alice",
21
21
+
message_text="@phi What's your take on consciousness?",
22
22
+
post_uri="at://did:alice/app.bsky.feed.post/msg1"
23
23
+
)
24
24
+
25
25
+
thread_db.add_message(
26
26
+
thread_uri=thread_uri,
27
27
+
author_handle="phi",
28
28
+
author_did="did:bot",
29
29
+
message_text="Consciousness fascinates me! It's the integration of information creating subjective experience.",
30
30
+
post_uri="at://did:bot/app.bsky.feed.post/msg2"
31
31
+
)
32
32
+
33
33
+
thread_db.add_message(
34
34
+
thread_uri=thread_uri,
35
35
+
author_handle="bob.bsky",
36
36
+
author_did="did:bob",
37
37
+
message_text="@phi But how do we know if something is truly conscious?",
38
38
+
post_uri="at://did:bob/app.bsky.feed.post/msg3"
39
39
+
)
40
40
+
41
41
+
# Get thread context
42
42
+
print("\n📖 Thread context:")
43
43
+
context = thread_db.get_thread_context(thread_uri)
44
44
+
print(context)
45
45
+
46
46
+
# Get raw messages
47
47
+
print("\n🗂️ Raw messages:")
48
48
+
messages = thread_db.get_thread_messages(thread_uri)
49
49
+
for msg in messages:
50
50
+
print(f" - @{msg['author_handle']}: {msg['message_text'][:50]}...")
51
51
+
52
52
+
print("\n✅ Thread context test complete!")
53
53
+
54
54
+
55
55
+
if __name__ == "__main__":
56
56
+
asyncio.run(test_thread_context())