-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.json
1 lines (1 loc) · 4.05 KB
/
tools.json
1
[{"id":"image_gen","user_id":"b37295bf-e323-4f98-b405-4b65f91f4731","name":"Image Gen","content":"\"\"\"\ntitle: Image Gen\nauthor: open-webui\nauthor_url: https://github.com/open-webui\nfunding_url: https://github.com/open-webui\nversion: 0.1\nrequired_open_webui_version: 0.3.9\n\"\"\"\n\nimport os\nimport requests\nfrom datetime import datetime\nfrom typing import Callable\n\nfrom open_webui.apps.images.main import image_generations, GenerateImageForm\nfrom open_webui.apps.webui.models.users import Users\n\n\nclass Tools:\n def __init__(self):\n pass\n\n async def generate_image(\n self, prompt: str, __user__: dict, __event_emitter__=None\n ) -> str:\n \"\"\"\n Generate an image given a prompt\n\n :param prompt: prompt to use for image generation\n \"\"\"\n\n await __event_emitter__(\n {\n \"type\": \"status\",\n \"data\": {\"description\": \"Generating an image\", \"done\": False},\n }\n )\n\n try:\n images = await image_generations(\n GenerateImageForm(**{\"prompt\": prompt}),\n Users.get_user_by_id(__user__[\"id\"]),\n )\n await __event_emitter__(\n {\n \"type\": \"status\",\n \"data\": {\"description\": \"Generated an image\", \"done\": True},\n }\n )\n\n for image in images:\n await __event_emitter__(\n {\n \"type\": \"message\",\n \"data\": {\"content\": f\"![Generated Image]({image['url']})\"},\n }\n )\n\n return f\"Notify the user that the image has been successfully generated\"\n\n except Exception as e:\n await __event_emitter__(\n {\n \"type\": \"status\",\n \"data\": {\"description\": f\"An error occured: {e}\", \"done\": True},\n }\n )\n\n return f\"Tell the user: {e}\"\n","specs":[{"name":"generate_image","description":"Generate an image given a prompt","parameters":{"type":"object","properties":{"prompt":{"type":"str","description":"prompt to use for image generation"}},"required":["prompt"]}}],"meta":{"description":"This tool generates images based on text prompts using the built-in methods of Open WebUI. Setup your image generation engine in Admin Settings > Images","manifest":{"title":"Image Gen","author":"open-webui","author_url":"https://github.com/open-webui","funding_url":"https://github.com/open-webui","version":"0.1","required_open_webui_version":"0.3.9"}},"updated_at":1728684008,"created_at":1728684008},{"id":"enhanced_calculator","user_id":"b37295bf-e323-4f98-b405-4b65f91f4731","name":"Enhanced Calculator","content":"import sympy as sp\n\n\nclass Tools:\n def __init__(self):\n pass\n\n def calculator(self, equation: str) -> str:\n \"\"\"\n Calculate the result of an equation safely.\n :param equation: The equation to calculate.\n :return: The result of the equation.\n \"\"\"\n try:\n # Parse the equation using sympy\n expr = sp.sympify(equation)\n result = expr.evalf()\n return f\"{equation} = {result}\"\n except (sp.SympifyError, ValueError) as e:\n print(e)\n return \"Invalid equation\"\n\n\n# Example usage\ntools = Tools()\nresult = tools.calculator(\"3 + 5 * (2 - 8)\")\nprint(result) # Output: 3 + 5 * (2 - 8) = -25.0000000000000\n","specs":[{"name":"calculator","description":"Calculate the result of an equation safely.","parameters":{"type":"object","properties":{"equation":{"type":"str","description":"The equation to calculate."}},"required":["equation"]}}],"meta":{"description":"This calculator will work with better capabilities and since it's using sympy there no security issues, making it very good for privacy and more complex math problems.","manifest":{}},"updated_at":1728684841,"created_at":1728684841}]