""" HTML templates, used when the info endpoint is accessed from the browser. """ import json from copilotkit.sdk import InfoDict HEAD_HTML = """ CopilotKit Remote Endpoint v0.1.12 """ INFO_TEMPLATE= """ {head_html}

🪁CopilotKit Remote Endpoint (v{version})

Actions

{action_html}

Agents

{agent_html}
""" ACTION_TEMPLATE = """

{name}

{description}

Arguments:

{arguments}
""" AGENT_TEMPLATE = """

{name} {type}

{description}

""" NO_ACTIONS_FOUND_HTML = """

No actions found

""" NO_AGENTS_FOUND_HTML = """

No agents found

""" def generate_info_html(info: InfoDict) -> str: """ Generate HTML for the info endpoint """ print(info, flush=True) action_html = "" for action in info["actions"]: action_html += ACTION_TEMPLATE.format( name=action["name"], description=action["description"], arguments=json.dumps(action.get("parameters", []), indent=2), ) agent_html = "" for agent in info["agents"]: agent_type = agent.get("type", "Unknown") if agent_type == "langgraph": agent_type = "LangGraph" elif agent_type == "crewai": agent_type = "CrewAI" agent_html += AGENT_TEMPLATE.format( name=agent["name"], type=agent_type, description=agent["description"], ) return INFO_TEMPLATE.format( head_html=HEAD_HTML, version=info["sdkVersion"], action_html=action_html or NO_ACTIONS_FOUND_HTML, agent_html=agent_html or NO_AGENTS_FOUND_HTML, )