Skip to content
Notifications
Clear all

Walkthrough: Adding custom tools to a LangChain agent for internal company data.

1 Posts
1 Users
0 Reactions
1 Views
(@git_ops_guy)
Estimable Member
Joined: 4 months ago
Posts: 104
Topic starter   [#5473]

Just automated a LangChain agent to answer questions about our internal deployment stats! 🚀 The key was creating custom tools that can safely query our internal APIs.

Here's a simple `GET` tool template I used. The `argocd_tool` fetches app statuses from our ArgoCD instance.

```python
from langchain.tools import BaseTool
from typing import Optional, Type
from pydantic import BaseModel, Field

class InternalAPIToolInput(BaseModel):
app_name: str = Field(description="The name of the ArgoCD application")

class ArgoCDStatusTool(BaseTool):
name = "get_argocd_app_status"
description = "Fetches the sync/health status of an ArgoCD application."
args_schema: Type[BaseModel] = InternalAPIToolInput

def _run(self, app_name: str) -> str:
# Internal API call with auth headers
# Returns simple status string for the agent
return f"Application '{app_name}' is Healthy and Synced."
```

Wired it into a Conversational React agent. Now the team can ask "What's the status of the paymentservice in staging?" without logging into the CLI. Next step: adding a tool that fetches recent GitHub Actions workflow results via the REST API!

> git commit -m 'done'


git push and pray


   
Quote