MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / AgentHelper

Class AgentHelper

gpt/agent.py:14–102  ·  view source on GitHub ↗

Add agent to help docGPT can be perfonm better.

Source from the content-addressed store, hash-verified

12
13
14class AgentHelper:
15 """Add agent to help docGPT can be perfonm better."""
16 def __init__(self) -> None:
17 self._llm = None
18 self.agent_ = None
19 self.tools = []
20
21 @property
22 def llm(self):
23 return self._llm
24
25 @llm.setter
26 def llm(self, llm) -> None:
27 self._llm = llm
28
29 @property
30 def get_calculate_chain(self) -> Tool:
31 from langchain import LLMMathChain
32
33 llm_math_chain = LLMMathChain.from_llm(llm=self.llm, verbose=True)
34 tool = Tool(
35 name='Calculator',
36 func=llm_math_chain.run,
37 description='useful for when you need to answer questions about math'
38 )
39 return tool
40
41 @property
42 def get_searp_chain(self) -> Tool:
43 from langchain import SerpAPIWrapper
44
45 search = SerpAPIWrapper()
46 tool = Tool(
47 name='Search',
48 func=search.run,
49 description='useful for when you need to answer questions about current events'
50 )
51 return tool
52
53 def create_doc_chat(self, docGPT) -> Tool:
54 """Add a custom docGPT tool"""
55 tool = Tool(
56 name='DocumentGPT',
57 func=docGPT.run,
58 description="""
59 useful for when you need to answer questions from the context of PDF
60 """
61 )
62 return tool
63
64 def create_llm_chain(self) -> Tool:
65 """Add a llm tool"""
66 prompt = PromptTemplate(
67 input_variables = ['query'],
68 template = '{query}'
69 )
70 llm_chain = LLMChain(llm=self.llm, prompt=prompt)
71

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected