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