Team Ai
Apppublic

Tribh/devops-copilot

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
standard_tools.py38 linesDownload Raw Back to tools
1from devops_copilot.tools.registry import registry2from devops_copilot.core.observability import track_tool_metrics3import httpx4import json5 6@registry.register(name="web_search", description="Search the web for information.")7@track_tool_metrics("web_search")8def web_search(query: str) -> str:9    """Simulates a web search tool."""10    return f"Search results for: {query}. (Mocked response: Found info about Multi-Agent LLMs)"11 12from simpleeval import SimpleEval13 14@registry.register(name="calculator", description="Perform basic math operations securely.")15@track_tool_metrics("calculator")16def calculator(expression: str) -> float:17    """Evaluates a math expression securely using simpleeval."""18    try:19        s = SimpleEval()20        return float(s.eval(expression))21    except Exception as e:22        return f"Error evaluating expression: {str(e)}"23 24@registry.register(name="idempotent_write", description="Write data to a file safely.")25@track_tool_metrics("idempotent_write")26def idempotent_write(filename: str, content: str) -> str:27    """An idempotent file write operation."""28    # Check if content is same to avoid unnecessary writes29    import os30    if os.path.exists(filename):31        with open(filename, 'r') as f:32            if f.read() == content:33                return "File already contains this content. No change."34    35    with open(filename, 'w') as f:36        f.write(content)37    return f"Successfully wrote to {filename}"38