{"id":16278579,"url":"https://github.com/sigoden/llm-functions","last_synced_at":"2025-04-12T22:29:36.143Z","repository":{"id":240016576,"uuid":"801296196","full_name":"sigoden/llm-functions","owner":"sigoden","description":"Easily create LLM tools and agents using Bash/JavaScript/Python, also a library of commonly used LLM tools and agents.","archived":false,"fork":false,"pushed_at":"2024-10-21T00:01:29.000Z","size":212,"stargazers_count":166,"open_issues_count":0,"forks_count":22,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-21T03:42:29.244Z","etag":null,"topics":["ai","ai-agents","ai-tools","function-calling","llm","llm-agents","llm-functions","llm-tools","tool-use"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigoden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-16T00:46:23.000Z","updated_at":"2024-10-21T00:01:31.000Z","dependencies_parsed_at":"2024-07-29T01:03:34.319Z","dependency_job_id":"76b0e0f8-6916-4be8-9b84-fdc431710ad5","html_url":"https://github.com/sigoden/llm-functions","commit_stats":null,"previous_names":["sigoden/llm-functions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fllm-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fllm-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fllm-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fllm-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigoden","download_url":"https://codeload.github.com/sigoden/llm-functions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248639481,"owners_count":21137849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-agents","ai-tools","function-calling","llm","llm-agents","llm-functions","llm-tools","tool-use"],"created_at":"2024-10-10T18:59:03.028Z","updated_at":"2025-04-12T22:29:36.118Z","avatar_url":"https://github.com/sigoden.png","language":"Shell","funding_links":[],"categories":["Shell","📚 Projects (1974 total)","MCP Clients"],"sub_categories":["MCP Servers","CLI Tools"],"readme":"# LLM Functions\n\nThis project empowers you to effortlessly build powerful LLM tools and agents using familiar languages like Bash, JavaScript, and Python. \n\nForget complex integrations, **harness the power of [function calling](https://platform.openai.com/docs/guides/function-calling)** to connect your LLMs directly to custom code and unlock a world of possibilities. Execute system commands, process data, interact with APIs –  the only limit is your imagination.\n\n**Tools Showcase**\n![llm-function-tool](https://github.com/user-attachments/assets/40c77413-30ba-4f0f-a2c7-19b042a1b507)\n\n**Agents showcase**\n![llm-function-agent](https://github.com/user-attachments/assets/6e380069-8211-4a16-8592-096e909b921d)\n\n## Prerequisites\n\nMake sure you have the following tools installed:\n\n- [argc](https://github.com/sigoden/argc): A bash command-line framework and command runner\n- [jq](https://github.com/jqlang/jq): A JSON processor\n\n## Getting Started with [AIChat](https://github.com/sigoden/aichat)\n\n**Currently, AIChat is the only CLI tool that supports `llm-functions`. We look forward to more tools supporting `llm-functions`.**\n\n### 1. Clone the repository\n\n```sh\ngit clone https://github.com/sigoden/llm-functions\ncd llm-functions\n```\n\n### 2. Build tools and agents\n\n#### I. Create a `./tools.txt` file with each tool filename on a new line.\n\n```\nget_current_weather.sh\nexecute_command.sh\n#execute_py_code.py\n``` \n\n\u003cdetails\u003e\n\u003csummary\u003eWhere is the web_search tool?\u003c/summary\u003e\n\u003cbr\u003e\n\nThe `web_search` tool itself doesn't exist directly, Instead, you can choose from a variety of web search tools.\n\nTo use one as the `web_search` tool, follow these steps:\n\n1. **Choose a Tool:** Available tools include:\n    * `web_search_cohere.sh`\n    * `web_search_perplexity.sh`\n    * `web_search_tavily.sh`\n    * `web_search_vertexai.sh`\n\n2. **Link Your Choice:** Use the `argc` command to link your chosen tool as `web_search`. For example, to use `web_search_perplexity.sh`:\n\n    ```sh\n    $ argc link-web-search web_search_perplexity.sh\n    ```\n\n    This command creates a symbolic link, making `web_search.sh` point to your selected `web_search_perplexity.sh` tool. \n\nNow there is a `web_search.sh` ready to be added to your `./tools.txt`.\n\n\u003c/details\u003e\n\n#### II. Create a `./agents.txt` file with each agent name on a new line.\n\n```\ncoder\ntodo\n```\n\n#### III. Build `bin` and `functions.json`\n\n```sh\nargc build\n```\n\n#### IV. Ensure that everything is ready (environment variables, Node/Python dependencies, mcp-bridge server)\n\n```sh\nargc check\n```\n\n### 3. Link LLM-functions and AIChat\n\nAIChat expects LLM-functions to be placed in AIChat's **functions_dir** so that AIChat can use the tools and agents that LLM-functions provides.\n\nYou can symlink this repository directory to AIChat's **functions_dir** with:\n\n```sh\nln -s \"$(pwd)\" \"$(aichat --info | sed -n 's/^functions_dir\\s\\+//p')\"\n# OR\nargc link-to-aichat\n```\n\nAlternatively, you can tell AIChat where the LLM-functions directory is by using an environment variable:\n\n```sh\nexport AICHAT_FUNCTIONS_DIR=\"$(pwd)\"\n```\n\n### 4. Start using the functions\n\nDone! Now you can use the tools and agents with AIChat.\n\n```sh\naichat --role %functions% what is the weather in Paris?\naichat --agent todo list all my todos\n```\n\n## Writing Your Own Tools\n\nBuilding tools for our platform is remarkably straightforward. You can leverage your existing programming knowledge, as tools are essentially just functions written in your preferred language.\n\nLLM Functions automatically generates the JSON declarations for the tools based on **comments**. Refer to `./tools/demo_tool.{sh,js,py}` for examples of how to use comments for autogeneration of declarations.\n\n### Bash\n\nCreate a new bashscript in the [./tools/](./tools/) directory (.e.g. `execute_command.sh`).\n\n```sh\n#!/usr/bin/env bash\nset -e\n\n# @describe Execute the shell command.\n# @option --command! The command to execute.\n\nmain() {\n    eval \"$argc_command\" \u003e\u003e \"$LLM_OUTPUT\"\n}\n\neval \"$(argc --argc-eval \"$0\" \"$@\")\"\n```\n\n### Javascript\n\nCreate a new javascript in the [./tools/](./tools/) directory (.e.g. `execute_js_code.js`).\n\n```js\n/**\n * Execute the javascript code in node.js.\n * @typedef {Object} Args\n * @property {string} code - Javascript code to execute, such as `console.log(\"hello world\")`\n * @param {Args} args\n */\nexports.run = function ({ code }) {\n  eval(code);\n}\n\n```\n\n### Python\n\nCreate a new python script in the [./tools/](./tools/) directory (e.g. `execute_py_code.py`).\n\n```py\ndef run(code: str):\n    \"\"\"Execute the python code.\n    Args:\n        code: Python code to execute, such as `print(\"hello world\")`\n    \"\"\"\n    exec(code)\n\n```\n\n## Writing Your Own Agents\n\nAgent = Prompt + Tools (Function Calling) + Documents (RAG), which is equivalent to OpenAI's GPTs.\n\nThe agent has the following folder structure:\n```\n└── agents\n    └── myagent\n        ├── functions.json                  # JSON declarations for functions (Auto-generated)\n        ├── index.yaml                      # Agent definition\n        ├── tools.txt                       # Shared tools\n        └── tools.{sh,js,py}                # Agent tools \n```\n\nThe agent definition file (`index.yaml`) defines crucial aspects of your agent:\n\n```yaml\nname: TestAgent                             \ndescription: This is test agent\nversion: 0.1.0\ninstructions: You are a test ai agent to ... \nconversation_starters:\n  - What can you do?\nvariables:\n  - name: foo\n    description: This is a foo\ndocuments:\n  - local-file.txt\n  - local-dir/\n  - https://example.com/remote-file.txt\n```\n\nRefer to [./agents/demo](https://github.com/sigoden/llm-functions/tree/main/agents/demo) for examples of how to implement a agent.\n\n## MCP (Model Context Protocol)\n\n- [mcp/server](https://github.com/sigoden/llm-functions/tree/main/mcp/server): Let LLM-Functions tools/agents be used through the Model Context Protocol. \n- [mcp/bridge](https://github.com/sigoden/llm-functions/tree/main/mcp/bridge): Let external MCP tools be used by LLM-Functions.\n\n## Documents\n\n- [Tool Guide](https://github.com/sigoden/llm-functions/blob/main/docs/tool.md)\n- [Agent Guide](https://github.com/sigoden/llm-functions/blob/main/docs/agent.md)\n- [Argc Commands](https://github.com/sigoden/llm-functions/blob/main/docs/argcfile.md)\n\n## License\n\nThe project is under the MIT License, Refer to the [LICENSE](https://github.com/sigoden/llm-functions/blob/main/LICENSE) file for detailed information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigoden%2Fllm-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigoden%2Fllm-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigoden%2Fllm-functions/lists"}