Jayashree Sridhar
commited on
Commit
·
37bbb29
1
Parent(s):
074e905
process func in crew_config.py
Browse files- 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 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 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 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 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 |
+
}
|