{"data":{"slug":"mpaepper-llm-agents","name":"llm_agents","tagline":"Build agents which are controlled by LLMs","github_url":"https://github.com/mpaepper/llm_agents","owner":"mpaepper","repo":"llm_agents","owner_avatar_url":"https://avatars.githubusercontent.com/u/4135790?v=4","primary_language":"Python","stars":1050,"forks":85,"topics":["deep-learning","langchain","llms","machine-learning"],"archived":false,"github_pushed_at":"2025-06-23T14:01:18+00:00","maintenance_label":"Dormant","url":"https://www.graphcanon.com/tools/mpaepper-llm-agents","markdown_url":"https://www.graphcanon.com/tools/mpaepper-llm-agents.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/mpaepper-llm-agents","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=mpaepper-llm-agents","description":"Build agents which are controlled by LLMs","homepage_url":"https://www.paepper.com/blog/posts/intelligent-agents-guided-by-llms/","license":"MIT","open_issues":3,"watchers":9,"ai_summary":null,"readme_excerpt":"## LLM Agents\n\nSmall library to build agents which are controlled by large language models (LLMs) which is heavily inspired by <a href=\"https://github.com/hwchase17/langchain/\" target=\"_blank\">langchain</a>.\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 <a href=\"https://news.ycombinator.com/item?id=35446171\">this Hacker News discussion from April 5th 2023</a> and the <a href=\"https://www.paepper.com/blog/posts/intelligent-agents-guided-by-llms/\">related blog post</a>.\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 <a href=\"https://www.paepper.com/blog/posts/intelligent-agents-guided-by-llms/\">this blog post</a>\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.","github_created_at":"2023-04-04T21:25:35+00:00","created_at":"2026-07-11T10:53:24.464997+00:00","updated_at":"2026-07-11T10:53:36.016518+00:00","categories":[{"slug":"ai-agents","name":"AI Agents","url":"https://www.graphcanon.com/categories/ai-agents","markdown_url":"https://www.graphcanon.com/categories/ai-agents.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/ai-agents"},{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"}],"tags":[{"slug":"deep-learning","name":"deep-learning"},{"slug":"langchain","name":"langchain"},{"slug":"llms","name":"llms"},{"slug":"machine-learning","name":"machine-learning"},{"slug":"python","name":"python"}],"trust":{"provenance":{"is_fork":false,"github_id":623679404,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-07-11T10:53:25.288Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":382,"last_release_at":null},"security_summary":{"status":"findings","scanner":"osv@v1","low_count":32,"high_count":0,"last_scan_at":"2026-07-11T10:53:32.820Z","medium_count":0,"scan_profile":"deps","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-07-11T10:53:32.242Z"},"has_cli":{"value":true,"source":"pyproject.toml:[project.scripts]","observed_at":"2026-07-11T10:53:32.242Z"},"languages":{"value":["python"],"source":"github.language+pyproject.toml","observed_at":"2026-07-11T10:53:32.242Z"},"license_spdx":{"value":"MIT","source":"github.license","observed_at":"2026-07-11T10:53:32.242Z"}}}}