- Minor changes to the SPIN_SPECIALIST
This commit is contained in:
@@ -126,7 +126,9 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
"query": arguments.query,
|
||||
"context": formatted_context,
|
||||
"citations": citations,
|
||||
"history": self._formatted_history,
|
||||
"history": self.formatted_history,
|
||||
"historic_spin": json.dumps(self.latest_spin, indent=2),
|
||||
"historic_lead_info": json.dumps(self.latest_lead_info, indent=2),
|
||||
"name": self.specialist.configuration.get('name', ''),
|
||||
"company": self.specialist.configuration.get('company', ''),
|
||||
"products": self.specialist.configuration.get('products', ''),
|
||||
@@ -134,6 +136,7 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
"engagement_options": self.specialist.configuration.get('engagement_options', ''),
|
||||
"tenant_language": self.specialist.configuration.get('tenant_language', ''),
|
||||
"nr_of_questions": self.specialist.configuration.get('nr_of_questions', ''),
|
||||
"identification": arguments.identification,
|
||||
}
|
||||
# crew_results = self.rag_crew.kickoff(inputs=flow_inputs)
|
||||
# current_app.logger.debug(f"Test Crew Output received: {crew_results}")
|
||||
@@ -167,6 +170,8 @@ class SPINSpecialistInput(BaseModel):
|
||||
context: Optional[str] = Field(None, alias="context")
|
||||
citations: Optional[List[int]] = Field(None, alias="citations")
|
||||
history: Optional[str] = Field(None, alias="history")
|
||||
historic_spin: Optional[str] = Field(None, alias="historic_spin")
|
||||
historic_lead_info: Optional[str] = Field(None, alias="historic_lead_info")
|
||||
name: Optional[str] = Field(None, alias="name")
|
||||
company: Optional[str] = Field(None, alias="company")
|
||||
products: Optional[str] = Field(None, alias="products")
|
||||
@@ -174,6 +179,7 @@ class SPINSpecialistInput(BaseModel):
|
||||
engagement_options: Optional[str] = Field(None, alias="engagement_options")
|
||||
tenant_language: Optional[str] = Field(None, alias="tenant_language")
|
||||
nr_of_questions: Optional[int] = Field(None, alias="nr_of_questions")
|
||||
identification: Optional[str] = Field(None, alias="identification")
|
||||
|
||||
|
||||
class SPINSpecialistResult(SpecialistResult):
|
||||
@@ -266,6 +272,7 @@ class SPINFlow(EveAICrewAIFlow[SPINFlowState]):
|
||||
additional_questions = self.state.lead_info.questions + "\n"
|
||||
if self.state.spin:
|
||||
additional_questions = additional_questions + self.state.spin.questions
|
||||
current_app.logger.debug(f"Additional Questions: {additional_questions}")
|
||||
inputs["additional_questions"] = additional_questions
|
||||
try:
|
||||
crew_output = self.rag_consolidation_crew.kickoff(inputs=inputs)
|
||||
|
||||
@@ -71,6 +71,14 @@ class CrewAIBaseSpecialistExecutor(BaseSpecialistExecutor):
|
||||
for interaction in self._cached_session.interactions
|
||||
])
|
||||
|
||||
@property
|
||||
def formatted_history(self) -> str:
|
||||
formatted_history = "\n\n".join([
|
||||
f"HUMAN:\n{interaction.specialist_results.get('query')}\n\n"
|
||||
f"AI:\n{interaction.specialist_results.get('rag_output').get('answer', '')}"
|
||||
for interaction in self._cached_session.interactions
|
||||
])
|
||||
|
||||
def _add_task_agent(self, task_name: str, agent_name: str):
|
||||
self._task_agents[task_name.lower()] = agent_name
|
||||
|
||||
@@ -155,7 +163,10 @@ class CrewAIBaseSpecialistExecutor(BaseSpecialistExecutor):
|
||||
pass
|
||||
|
||||
def __getattr__(self, name: str) -> Any:
|
||||
"""Enable dynamic access to agents as attributes"""
|
||||
"""
|
||||
- Enable dynamic access to agents, tasks or tools as attributes
|
||||
- Enable dynamic access to latest information in interactions in the cached session
|
||||
"""
|
||||
try:
|
||||
if name.endswith('_agent'):
|
||||
return self._agents[name]
|
||||
@@ -166,6 +177,13 @@ class CrewAIBaseSpecialistExecutor(BaseSpecialistExecutor):
|
||||
if name.endswith('_tool'):
|
||||
return self._tools[name]
|
||||
|
||||
if name.startswith('latest_'):
|
||||
element = name[len('latest_'):]
|
||||
if self._cached_session.interactions:
|
||||
return self._cached_session.interactions[-1].get(element, '')
|
||||
else:
|
||||
return {}
|
||||
|
||||
# Not a known component request
|
||||
raise AttributeError(f"'{self.__class__.__name__}' has no attribute '{name}'")
|
||||
except KeyError:
|
||||
|
||||
Reference in New Issue
Block a user