{"id":13486912,"url":"https://github.com/mpaepper/llm_agents","last_synced_at":"2025-05-14T15:06:33.938Z","repository":{"id":150972220,"uuid":"623679404","full_name":"mpaepper/llm_agents","owner":"mpaepper","description":"Build agents which are controlled by LLMs","archived":false,"fork":false,"pushed_at":"2025-01-03T10:33:32.000Z","size":17,"stargazers_count":974,"open_issues_count":2,"forks_count":79,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-13T16:50:24.709Z","etag":null,"topics":["deep-learning","langchain","llms","machine-learning"],"latest_commit_sha":null,"homepage":"https://www.paepper.com/blog/posts/intelligent-agents-guided-by-llms/","language":"Python","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/mpaepper.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":"2023-04-04T21:25:35.000Z","updated_at":"2025-04-12T18:27:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"689e0ac2-a5de-4e4d-9805-b81eb1545588","html_url":"https://github.com/mpaepper/llm_agents","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"804bc70e4eeb895bb8f3ab19eb90a2cab849c88a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaepper%2Fllm_agents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaepper%2Fllm_agents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaepper%2Fllm_agents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaepper%2Fllm_agents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpaepper","download_url":"https://codeload.github.com/mpaepper/llm_agents/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169076,"owners_count":22026208,"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":["deep-learning","langchain","llms","machine-learning"],"created_at":"2024-07-31T18:00:52.879Z","updated_at":"2025-05-14T15:06:33.895Z","avatar_url":"https://github.com/mpaepper.png","language":"Python","funding_links":[],"categories":["Python","[LLM Agents](https://github.com/mpaepper/llm_agents)","Automation","Table of Open-Source AI Agents Projects","[↑](#table-of-contents) Code|Apps|Tools","其他LLM框架","Building","Agent Categories","Other LLM Frameworks"],"sub_categories":["Links","文章","Frameworks","\u003ca name=\"Unclassified\"\u003e\u003c/a\u003eUnclassified","Videos Playlists"],"readme":"## LLM Agents\n\nSmall library to build agents which are controlled by large language models (LLMs) which is heavily inspired by \u003ca href=\"https://github.com/hwchase17/langchain/\" target=\"_blank\"\u003elangchain\u003c/a\u003e.\n\nThe goal was to get a better grasp of how such an agent works and understand it all in very few lines of code.\n\nLangchain is great, but it already has a few more files and abstraction layers, so I thought it would be nice to build the most important parts of a simple agent from scratch.\n\nSome more infos are in \u003ca href=\"https://news.ycombinator.com/item?id=35446171\"\u003ethis Hacker News discussion from April 5th 2023\u003c/a\u003e and the \u003ca href=\"https://www.paepper.com/blog/posts/intelligent-agents-guided-by-llms/\"\u003erelated blog post\u003c/a\u003e.\n\n### How it works\n\nThe agent works like this:\n\n* It gets instructed by a prompt which tells it the basic way to solve a task using tools\n* Tools are custom build components which the agent can use\n    * So far, I've implemented the ability to execute Python code in a REPL, to use the Google search and to search on Hacker News\n* The agent runs in a loop of Thought, Action, Observation, Thought, ...\n    * The Thought and Action (with the Action Input to the action) are the parts which are generated by an LLM\n    * The Observation is generated by using a tool (for example the print outputs of Python or the text result of a Google search)\n* The LLM gets the new information appended to the prompt in each loop cycle and thus can act on that information\n* Once the agent has enough information it provides the final answer\n\nFor more details on how it works, check out \u003ca href=\"https://www.paepper.com/blog/posts/intelligent-agents-guided-by-llms/\"\u003ethis blog post\u003c/a\u003e\n\n### How to use it\n\nYou can install this library locally by running: \n\n```\npip install -r requirements.txt\npip install -e .\n```\n\ninside it's directory after cloning it.\n\nYou also need to provide the following env variables:\n\n* `OPENAI_API_KEY` to use the OpenAI API (obtainable at: https://platform.openai.com/account/api-keys)\n* `SERPAPI_API_KEY` to use the Google Search in case you use that tool (obtainable at: https://serpapi.com/)\n\nYou can simply export them in bash like: `export OPENAI_API_KEY='sh-lsdf....'`\n\nThen you can run the script `python run_agent.py` and ask your question.\n\nTo construct your own agent do it like this:\n\n```python\nfrom llm_agents import Agent, ChatLLM, PythonREPLTool, HackerNewsSearchTool, SerpAPITool\n\nagent = Agent(llm=ChatLLM(), tools=[PythonREPLTool(), SerpAPITool(), HackerNewsSearchTool()])\nresult = agent.run(\"Your question to the agent\")\n\nprint(f\"Final answer is {result}\")\n```\n\nOf course, you can also build your custom tools or omit tools, for exmaple if you don't want to create a SERPAPI key.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpaepper%2Fllm_agents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpaepper%2Fllm_agents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpaepper%2Fllm_agents/lists"}