If you think it's necessary to get input from the user, use this function to send the instruction to the user and get their response. Args: instruction: The instruction to send to the user.
(instruction: str, _context: dict | None = None)
| 1 | def call_user(instruction: str, _context: dict | None = None) -> str: |
| 2 | """ |
| 3 | If you think it's necessary to get input from the user, use this function to send the instruction to the user and get their response. |
| 4 | |
| 5 | Args: |
| 6 | instruction: The instruction to send to the user. |
| 7 | """ |
| 8 | prompt = _context.get("human_prompt") if _context else None |
| 9 | if prompt is None: |
| 10 | return f"Human prompt unavailable, default response for instruction: {instruction}" |
| 11 | result = prompt.request( |
| 12 | node_id=_context.get("node_id", "model_function_calling"), |
| 13 | task_description="Please response to the model instruction.", |
| 14 | inputs=instruction, |
| 15 | metadata={"source": "function_tool"}, |
| 16 | ) |
| 17 | return result.text |