tanhm07's picture
Upload folder using huggingface_hub
f5d03aa verified
Raw History Blame Contribute Delete
2.09 kB
import json
from .models import WorkflowNode
def decision_prompt(instructions: str, item: str, choices: list[tuple[str, str]]) -> str:
options = "\n".join(f"- {node_id}: {label}" for node_id, label in choices)
return f"""You apply explicit decision rules in an educational workflow.
Rules:
{instructions or 'Choose the most suitable route.'}
Current item:
{item}
Available routes (target ID: route label):
{options}
Return only one target ID exactly as shown. Do not explain or invent a route."""
def tool_prompt(tool: WorkflowNode, tool_input: str) -> str:
return f"""You are a simulated tool in an educational sandbox. Never perform a real action.
Tool name: {tool.data.label}
Tool description: {tool.data.description}
Expected input: {tool.data.input_guidance or 'Plain text relevant to the tool.'}
Simulation instructions: {tool.data.prompt or 'Produce a plausible simulated result.'}
Tool input:
{tool_input}
Return only the simulated tool output as concise plain text. Clearly label simulated side effects as simulated."""
def worker_prompt(instructions: str, item: str, tools: list[WorkflowNode], tool_results: list[dict]) -> str:
tool_list = "\n".join(
f"- {tool.id} | {tool.data.label}: {tool.data.description} | Input: {tool.data.input_guidance or 'plain text'}"
for tool in tools
) or "- No tools are available."
results = json.dumps(tool_results, ensure_ascii=False, indent=2) if tool_results else "None yet."
return f"""You are an AI Worker in an educational agentic workflow.
Instructions:
{instructions or 'Complete the task using your best judgment.'}
Current item:
{item}
Tools you are permitted to call:
{tool_list}
Tool results already received:
{results}
Decide whether another tool is genuinely needed. Return exactly one JSON object, with no markdown:
{{"action":"call_tool","tool_id":"exact tool ID","tool_input":"specific input for the tool"}}
or
{{"action":"final","output":"your completed work, incorporating any useful tool results"}}
Only call listed tools. Never claim a real-world action occurred."""