@@ -162,57 +162,111 @@ async def demonstrate_profile_analysis(preference_agent, user_history,
162162 display_analysis_results (analyzed_profile )
163163
164164
165- def display_analysis_results (profile : Dict [str , Any ]):
166- """Display the analyzed profile results in a readable format."""
167-
165+ def display_analysis_results (profile ):
166+ """Display the analysis results in a formatted way."""
168167 print ("\n 📊 AI Analysis Results:" )
169168 print ("=" * 30 )
170169
171- if not profile or 'profile_summary' not in profile :
170+ # Handle both dict and Pydantic model formats
171+ if hasattr (profile , 'profile_summary' ):
172+ # Pydantic model format
173+ summary = profile .profile_summary
174+ interests = [interest .value if hasattr (interest , 'value' ) else str (interest ) for interest in summary .interests ]
175+
176+ print (f"🎯 Identified Interests ({ len (interests )} ):" )
177+ for interest in interests :
178+ print (f" • { interest } " )
179+
180+ # Display preferences
181+ if summary .preferences :
182+ prefs = summary .preferences
183+ print (f"\n ✍️ Content Style:" )
184+ print (f" Description: { prefs .content_style or 'N/A' } " )
185+
186+ # Handle content style tags
187+ content_tags = []
188+ if prefs .content_style_tags :
189+ content_tags = [tag .value if hasattr (tag , 'value' ) else str (tag ) for tag in prefs .content_style_tags ]
190+ print (f" Tags: { content_tags } " )
191+
192+ print (f"\n 💬 Interaction Style:" )
193+ print (f" Description: { prefs .interaction_style or 'N/A' } " )
194+
195+ # Handle interaction style tags
196+ interaction_tags = []
197+ if prefs .interaction_style_tags :
198+ interaction_tags = [tag .value if hasattr (tag , 'value' ) else str (tag ) for tag in prefs .interaction_style_tags ]
199+ print (f" Tags: { interaction_tags } " )
200+
201+ # Handle active periods
202+ active_periods = []
203+ if prefs .active_periods :
204+ active_periods = [period .value if hasattr (period , 'value' ) else str (period ) for period in prefs .active_periods ]
205+ print (f"\n 🕒 Active Periods: { active_periods } " )
206+
207+ # Display behavioral summary
208+ if summary .behavioral_summary :
209+ print (f"\n 🧠 Behavioral Analysis:" )
210+ print (f" { summary .behavioral_summary } " )
211+
212+ # Handle behavioral archetype tags
213+ if summary .behavioral_archetype_tags :
214+ behavioral_tags = [tag .value if hasattr (tag , 'value' ) else str (tag ) for tag in summary .behavioral_archetype_tags ]
215+ print (f" Archetype Tags: { behavioral_tags } " )
216+
217+ # Display community profile
218+ if summary .community_profile :
219+ cp = summary .community_profile
220+ print (f"\n 👥 Community Profile:" )
221+ print (f" Affinity: { cp .affinity or 'N/A' } " )
222+ print (f" Potential Role: { cp .potential_role or 'N/A' } " )
223+
224+ # Handle role tags
225+ role_tags = []
226+ if cp .potential_role_tags :
227+ role_tags = [tag .value if hasattr (tag , 'value' ) else str (tag ) for tag in cp .potential_role_tags ]
228+ print (f" Role Tags: { role_tags } " )
229+
230+ elif isinstance (profile , dict ) and 'profile_summary' in profile :
231+ # Original dict format (fallback)
232+ summary = profile ['profile_summary' ]
233+ interests = summary .get ('interests' , [])
234+ print (f"🎯 Identified Interests ({ len (interests )} ):" )
235+ for interest in interests :
236+ print (f" • { interest } " )
237+
238+ # Display preferences
239+ if 'preferences' in summary :
240+ prefs = summary ['preferences' ]
241+ print (f"\n ✍️ Content Style:" )
242+ print (f" Description: { prefs .get ('content_style' , 'N/A' )} " )
243+ print (f" Tags: { prefs .get ('content_style_tags' , [])} " )
244+
245+ print (f"\n 💬 Interaction Style:" )
246+ print (f" Description: { prefs .get ('interaction_style' , 'N/A' )} " )
247+ print (f" Tags: { prefs .get ('interaction_style_tags' , [])} " )
248+
249+ print (f"\n 🕒 Active Periods: { prefs .get ('active_periods' , [])} " )
250+
251+ # Display behavioral summary
252+ behavioral_summary = summary .get ('behavioral_summary' , '' )
253+ if behavioral_summary :
254+ print (f"\n 🧠 Behavioral Analysis:" )
255+ print (f" { behavioral_summary } " )
256+
257+ behavioral_tags = summary .get ('behavioral_archetype_tags' , [])
258+ if behavioral_tags :
259+ print (f" Archetype Tags: { behavioral_tags } " )
260+
261+ # Display community profile
262+ if 'community_profile' in summary :
263+ cp = summary ['community_profile' ]
264+ print (f"\n 👥 Community Profile:" )
265+ print (f" Affinity: { cp .get ('affinity' , 'N/A' )} " )
266+ print (f" Potential Role: { cp .get ('potential_role' , 'N/A' )} " )
267+ print (f" Role Tags: { cp .get ('potential_role_tags' , [])} " )
268+ else :
172269 print ("❌ No valid profile data received" )
173- return
174-
175- summary = profile ['profile_summary' ]
176-
177- # Display interests
178- interests = summary .get ('interests' , [])
179- print (f"🎯 Identified Interests ({ len (interests )} ):" )
180- for interest in interests :
181- print (f" • { interest } " )
182-
183- # Display preferences
184- if 'preferences' in summary :
185- prefs = summary ['preferences' ]
186- print (f"\n ✍️ Content Style:" )
187- print (f" Description: { prefs .get ('content_style' , 'N/A' )} " )
188- print (f" Tags: { prefs .get ('content_style_tags' , [])} " )
189-
190- print (f"\n 💬 Interaction Style:" )
191- print (f" Description: { prefs .get ('interaction_style' , 'N/A' )} " )
192- print (f" Tags: { prefs .get ('interaction_style_tags' , [])} " )
193-
194- print (f"\n 🕒 Active Periods: { prefs .get ('active_periods' , [])} " )
195-
196- # Display behavioral summary
197- behavioral_summary = summary .get ('behavioral_summary' , '' )
198- if behavioral_summary :
199- print (f"\n 🧠 Behavioral Analysis:" )
200- print (f" { behavioral_summary } " )
201-
202- behavioral_tags = summary .get ('behavioral_archetype_tags' , [])
203- if behavioral_tags :
204- print (f" Archetype Tags: { behavioral_tags } " )
205-
206- # Display community profile
207- if 'community_profile' in summary :
208- cp = summary ['community_profile' ]
209- print (f"\n 👥 Community Profile:" )
210- print (f" Affinity: { cp .get ('affinity' , 'N/A' )} " )
211- print (f" Potential Role: { cp .get ('potential_role' , 'N/A' )} " )
212- print (f" Role Tags: { cp .get ('potential_role_tags' , [])} " )
213-
214- print (f"\n 💾 Complete Profile Structure:" )
215- print (json .dumps (profile , indent = 2 , ensure_ascii = False ))
216270
217271
218272async def demonstrate_new_user_scenario (preference_agent ):
0 commit comments