-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlangchain_example.py
More file actions
41 lines (31 loc) · 1.3 KB
/
langchain_example.py
File metadata and controls
41 lines (31 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from src.toolfuzz.agent_executors.langchain.react_new import ReactAgentNew
from src.toolfuzz.correctness.correctness_fuzzer import CorrectnessTester
from src.toolfuzz.runtime.runtime_fuzzer import RuntimeErrorTester
def example_runtime_failure_fuzzing():
from langchain_community.tools import ShellTool
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model='gpt-4o-mini')
tool = ShellTool()
agent = ReactAgentNew(tool, llm)
tester = RuntimeErrorTester(llm=llm,
tool=tool,
agent=agent,
fuzzer_iters=500)
tester.test()
tester.save('langchain_runtime_results')
def example_correctness_usage():
from langchain_community.tools import ShellTool
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model='gpt-4o-mini')
tool = ShellTool()
agent = ReactAgentNew(tool, llm)
tester = CorrectnessTester(llm=llm,
tool=tool,
agent=agent,
additional_context='',
prompt_set_iters=5)
tester.test()
tester.save('langchain_correctness_results')
if __name__ == '__main__':
example_runtime_failure_fuzzing()
example_correctness_usage()