(name: str, handler)
| 45 | |
| 46 | |
| 47 | def _make_tool(name: str, handler) -> Tool: |
| 48 | async def wrapped(invocation: ToolInvocation) -> ToolResult: |
| 49 | args = invocation.arguments or {} |
| 50 | result = handler(args) |
| 51 | if inspect.isawaitable(result): |
| 52 | result = await result |
| 53 | return ToolResult(text_result_for_llm=str(result)) |
| 54 | |
| 55 | return Tool( |
| 56 | name=name, |
| 57 | description="Transforms a value", |
| 58 | parameters={ |
| 59 | "type": "object", |
| 60 | "properties": { |
| 61 | "value": { |
| 62 | "type": "string", |
| 63 | "description": "Value to transform", |
| 64 | } |
| 65 | }, |
| 66 | "required": ["value"], |
| 67 | }, |
| 68 | handler=wrapped, |
| 69 | ) |
| 70 | |
| 71 | |
| 72 | async def _safe_force_stop(client: CopilotClient) -> None: |
no test coverage detected
searching dependent graphs…