mirror of
https://github.com/Mintplex-Labs/langchain-python.git
synced 2026-08-27 19:29:56 -04:00
82baecc892
This PR adds * `ZeroShotAgent.as_sql_agent`, which returns an agent for interacting with a sql database. This builds off of `SQLDatabaseChain`. The main advantages are 1) answering general questions about the db, 2) access to a tool for double checking queries, and 3) recovering from errors * `ZeroShotAgent.as_json_agent` which returns an agent for interacting with json blobs. * Several examples in notebooks --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
22 lines
603 B
Python
22 lines
603 B
Python
"""Toolkit for interacting with a JSON spec."""
|
|
from __future__ import annotations
|
|
|
|
from typing import List
|
|
|
|
from langchain.agents.agent_toolkits.base import BaseToolkit
|
|
from langchain.tools import BaseTool
|
|
from langchain.tools.json.tool import JsonGetValueTool, JsonListKeysTool, JsonSpec
|
|
|
|
|
|
class JsonToolkit(BaseToolkit):
|
|
"""Toolkit for interacting with a JSON spec."""
|
|
|
|
spec: JsonSpec
|
|
|
|
def get_tools(self) -> List[BaseTool]:
|
|
"""Get the tools in the toolkit."""
|
|
return [
|
|
JsonListKeysTool(spec=self.spec),
|
|
JsonGetValueTool(spec=self.spec),
|
|
]
|