- RAG & SPIN Specialist improvements
This commit is contained in:
@@ -65,7 +65,6 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
"language": arguments.language,
|
||||
"query": arguments.query,
|
||||
"context": formatted_context,
|
||||
"citations": citations,
|
||||
"history": self.formatted_history,
|
||||
"name": self.specialist.configuration.get('name', ''),
|
||||
"company": self.specialist.configuration.get('company', ''),
|
||||
|
||||
@@ -124,7 +124,6 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
|
||||
"language": arguments.language,
|
||||
"query": arguments.query,
|
||||
"context": formatted_context,
|
||||
"citations": citations,
|
||||
"history": self.formatted_history,
|
||||
"historic_spin": json.dumps(self.latest_spin, indent=2),
|
||||
"historic_lead_info": json.dumps(self.latest_lead_info, indent=2),
|
||||
@@ -217,7 +216,9 @@ class SPINFlow(EveAICrewAIFlow[SPINFlowState]):
|
||||
async def execute_rag(self):
|
||||
inputs = self.state.input.model_dump()
|
||||
try:
|
||||
current_app.logger.debug("In execute_rag")
|
||||
crew_output = await self.rag_crew.kickoff_async(inputs=inputs)
|
||||
current_app.logger.debug(f"Crew execution ended with output:\n{crew_output}")
|
||||
self.specialist_executor.log_tuning("RAG Crew Output", crew_output.model_dump())
|
||||
output_pydantic = crew_output.pydantic
|
||||
if not output_pydantic:
|
||||
@@ -276,13 +277,16 @@ class SPINFlow(EveAICrewAIFlow[SPINFlowState]):
|
||||
if self.state.spin:
|
||||
additional_questions = additional_questions + self.state.spin.questions
|
||||
inputs["additional_questions"] = additional_questions
|
||||
current_app.logger.debug(f"Prepared Answers: \n{inputs['prepared_answers']}")
|
||||
current_app.logger.debug(f"Additional Questions: \n{additional_questions}")
|
||||
try:
|
||||
crew_output = await self.rag_consolidation_crew.kickoff_async(inputs=inputs)
|
||||
current_app.logger.debug(f"Consolidation output after crew execution:\n{crew_output}")
|
||||
self.specialist_executor.log_tuning("RAG Consolidation Crew Output", crew_output.model_dump())
|
||||
output_pydantic = crew_output.pydantic
|
||||
if not output_pydantic:
|
||||
raw_json = json.loads(crew_output.raw)
|
||||
output_pydantic = LeadInfoOutput.model_validate(raw_json)
|
||||
output_pydantic = RAGOutput.model_validate(raw_json)
|
||||
self.state.final_output = output_pydantic
|
||||
return crew_output
|
||||
except Exception as e:
|
||||
|
||||
@@ -314,7 +314,10 @@ class CrewAIBaseSpecialistExecutor(BaseSpecialistExecutor):
|
||||
])
|
||||
|
||||
# Return document_ids for citations
|
||||
citations = [ctx.metadata.document_id for ctx in unique_contexts]
|
||||
citations = [{"document_id": ctx.metadata.document_id,
|
||||
"document_version_id": ctx.metadata.version_id,
|
||||
"url": ctx.metadata.url}
|
||||
for ctx in unique_contexts]
|
||||
|
||||
self.log_tuning("Context Retrieval Results",
|
||||
{"Formatted Context": formatted_context,
|
||||
@@ -345,6 +348,7 @@ class CrewAIBaseSpecialistExecutor(BaseSpecialistExecutor):
|
||||
|
||||
modified_result = {
|
||||
"detailed_query": detailed_query,
|
||||
"citations": citations,
|
||||
}
|
||||
final_result = result.model_copy(update=modified_result)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user