a digital person for bluesky

Minor fixes

+15 -11
+7 -4
bsky.py
··· 23 23 logger = logging.getLogger("void_bot") 24 24 25 25 26 - # Create a client 26 + # Create a client with extended timeout for LLM operations 27 27 CLIENT= Letta( 28 - token=os.environ["LETTA_API_KEY"] 28 + token=os.environ["LETTA_API_KEY"], 29 + timeout=300 # 5 minutes timeout for API calls 29 30 ) 30 31 31 32 # Use the "Bluesky" project ··· 110 111 # Get thread context as YAML string 111 112 thread_context = thread_to_yaml_string(thread) 112 113 114 + print(thread_context) 115 + 113 116 # Create a prompt for the Letta agent with thread context 114 117 prompt = f"""You received a mention on Bluesky from @{author_handle} ({author_name or author_handle}). 115 118 ··· 183 186 logger.error(f"Failed to send reply to @{author_handle}") 184 187 return False 185 188 else: 186 - logger.warning(f"No reply generated for mention from @{author_handle}") 187 - return False 189 + logger.warning(f"No reply generated for mention from @{author_handle}, removing notification from queue") 190 + return True 188 191 189 192 except Exception as e: 190 193 logger.error(f"Error processing mention: {e}")
+8 -7
bsky_utils.py
··· 33 33 "tags", 34 34 "associated", 35 35 "thread_context", 36 - "image", 37 36 "aspect_ratio", 38 37 "thumb", 39 38 "fullsize", ··· 59 58 "muted", 60 59 "muted_by_list", 61 60 "root_author_like", 62 - "embed", 63 61 "entities", 62 + "ref", 63 + "mime_type", 64 + "size", 64 65 ] 65 66 def convert_to_basic_types(obj): 66 67 """Convert complex Python objects to basic types for JSON/YAML serialization.""" ··· 116 117 def thread_to_yaml_string(thread, strip_metadata=True): 117 118 """ 118 119 Convert thread data to a YAML-formatted string for LLM parsing. 119 - 120 + 120 121 Args: 121 122 thread: The thread data from get_post_thread 122 123 strip_metadata: Whether to strip metadata fields for cleaner output 123 - 124 + 124 125 Returns: 125 126 YAML-formatted string representation of the thread 126 127 """ 127 128 # First convert complex objects to basic types 128 129 basic_thread = convert_to_basic_types(thread) 129 - 130 + 130 131 if strip_metadata: 131 132 # Create a copy and strip unwanted fields 132 133 cleaned_thread = strip_fields(basic_thread, STRIP_FIELDS) 133 134 else: 134 135 cleaned_thread = basic_thread 135 - 136 + 136 137 return yaml.dump(cleaned_thread, indent=2, allow_unicode=True, default_flow_style=False) 137 138 138 139 ··· 279 280 else: 280 281 post_uri = None 281 282 post_cid = None 282 - 283 + 283 284 if not post_uri or not post_cid: 284 285 logger.error("Notification doesn't have required uri/cid fields") 285 286 return None