Jayashree Sridhar commited on
Commit
37bbb29
·
1 Parent(s): 074e905

process func in crew_config.py

Browse files
Files changed (1) hide show
  1. crew_config.py +25 -22
crew_config.py CHANGED
@@ -72,26 +72,29 @@ class PersonalCoachCrew:
72
  ]
73
  )
74
  def process(self, inputs: dict):
75
- """
76
- Orchestrates conversation:
77
- 1. conversation_handler gets initial message
78
- 2. wisdom_advisor enriches/advises
79
- 3. validator checks response
80
- 4. (optionally) interaction_manager tweaks flow/summary
81
- Returns dict with 'final_response' (name matches app.py usage)
82
- """
83
- print(dir(self.conversation_handler))
84
- # 1. Empathetic dialog
85
- conversation_response = self.conversation_handler.kickoff()(inputs)
86
- # 2. Wisdom/advice
87
- wisdom_response = self.wisdom_advisor.kickoff()(inputs)
88
- # (You may mix/compose these based on your agent logic)
89
- combined_response = f"{conversation_response}\n{wisdom_response}"
90
- # 3. Validate response
91
- validator_result = self.response_validator.kickoff()({'response': combined_response})
92
 
93
- # You may want to use a more sophisticated process (context, better merging, etc)
94
- # For MVP, just return this:
95
- return {
96
- "final_response": combined_response
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
72
  ]
73
  )
74
  def process(self, inputs: dict):
75
+ user_message = inputs.get("user_message", "")
76
+ # Optionally, add conversation history entries as prior messages.
77
+ messages = []
78
+ for his in inputs.get("conversation_history", []):
79
+ if len(his) == 2:
80
+ messages.append({"role": "user", "content": his[0]})
81
+ messages.append({"role": "assistant", "content": his[1]})
82
+ # Add current user message
83
+ messages.append({"role": "user", "content": user_message})
 
 
 
 
 
 
 
 
84
 
85
+ # 1. Empathetic dialog
86
+ conversation_response = self.conversation_handler.kickoff(messages)
87
+
88
+ # 2. Wisdom/advice — also provide messages (same as for conversation_handler)
89
+ wisdom_response = self.wisdom_advisor.kickoff(messages)
90
+
91
+ # Combine/mix as fits your logic
92
+ combined_response = f"{conversation_response}\n{wisdom_response}"
93
+
94
+ # For validation, create appropriate messages object
95
+ validation_messages = [{"role": "assistant", "content": combined_response}]
96
+ validator_result = self.response_validator.kickoff(validation_messages)
97
+
98
+ return {
99
+ "final_response": combined_response
100
+ }