diff --git a/wren-ai-service/src/pipelines/indexing/instructions.py b/wren-ai-service/src/pipelines/indexing/instructions.py index bcb417f675..4c376f2310 100644 --- a/wren-ai-service/src/pipelines/indexing/instructions.py +++ b/wren-ai-service/src/pipelines/indexing/instructions.py @@ -43,7 +43,9 @@ def run(self, instructions: list[Instruction], project_id: Optional[str] = ""): "is_default": instruction.is_default, **addition, }, - content=instruction.question, + content="this is a global instruction, so no question is provided" + if instruction.is_default + else instruction.question, ) for instruction in instructions ] diff --git a/wren-ai-service/src/web/v1/services/instructions.py b/wren-ai-service/src/web/v1/services/instructions.py index 393175f03f..cb6d17442d 100644 --- a/wren-ai-service/src/web/v1/services/instructions.py +++ b/wren-ai-service/src/web/v1/services/instructions.py @@ -74,16 +74,27 @@ async def index( trace_id = kwargs.get("trace_id") try: - instructions = [ - Instruction( - id=instruction.id, - instruction=instruction.instruction, - question=question, - is_default=instruction.is_default, - ) - for instruction in request.instructions - for question in instruction.questions - ] + instructions = [] + for instruction in request.instructions: + if instruction.is_default: + instructions.append( + Instruction( + id=instruction.id, + instruction=instruction.instruction, + question="", + is_default=True, + ) + ) + else: + for question in instruction.questions: + instructions.append( + Instruction( + id=instruction.id, + instruction=instruction.instruction, + question=question, + is_default=False, + ) + ) await self._pipelines["instructions_indexing"].run( project_id=request.project_id,