Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,25 @@
|
|
1 |
-
from langchain import
|
2 |
-
from langchain.agents import
|
3 |
-
from
|
4 |
-
from
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
1 |
+
from langchain.chat_models import ChatOpenAI
|
2 |
+
from langchain.agents import create_json_agent
|
3 |
+
from langchain.agents.agent_toolkits import JsonToolkit
|
4 |
+
from langchain.tools.json.tool import JsonSpec
|
5 |
+
import json
|
6 |
|
7 |
+
# file="output.json"
|
8 |
+
# with open(file,"r") as f1:
|
9 |
+
# data=json.load(f1)
|
10 |
+
# f1.close()
|
11 |
+
data ={
|
12 |
+
"openapi": "3.0.0",
|
13 |
+
"info": {
|
14 |
+
"title": "OpenAI API",
|
15 |
+
"description": "The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.",
|
16 |
+
"version": "2.0.0",
|
17 |
+
"termsOfService": "https://openai.com/policies/terms-of-use",
|
18 |
+
"contact": {
|
19 |
+
"name": "OpenAI Support",
|
20 |
+
"url": "https://help.openai.com/"
|
21 |
+
}}}
|
22 |
+
spec=JsonSpec(dict_=data,max_value_length=4000)
|
23 |
+
toolkit=JsonToolkit(spec=spec)
|
24 |
+
agent=create_json_agent(llm=ChatOpenAI(openai_api_key="sk-nAqoChT9cmkAxALwMLdWT3BIbkFJcNHsH5Z5LN2ixPcDAopT",temperature=0,model="gpt-4"),toolkit=toolkit,max_iterations=1000,verbose=True)
|
25 |
+
print(agent.run("what are the request method for openapi endpoint"))
|