You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**OpenAI plugins** are tools that extend the capabilities of ChatGPT by allowing it to access real-time data, perform actions, or connect with external services via APIs.
1
+
**OpenAI plugins** are tools that extend the capabilities of ChatGPT by allowing it to access real-time data, perform actions, or connect with external services via APIs. .
2
2
3
3
Instead of being limited to its pre-trained knowledge, ChatGPT can use plugins to retrieve up-to-date information (like live weather, stock prices, or databases) or perform tasks (like booking a flight or running a query).
4
4
@@ -16,8 +16,7 @@ This is to explore:
16
16
17
17
A value prop might be summarized: *instantly expose legacy DBs to Natural Language, including critical business logic and security, to simplify user discovery and operation.*
18
18
19
-
20
-
19
+
<br>
21
20
22
21
## Status: Technology Exploration
23
22
@@ -27,19 +26,18 @@ We welcome participation in this exploration. Please contact us via [discord](h
27
26
28
27
This exploration is changing rapidly. For updates, replace `integration/mcp` from [integration/msp](https://github.com/ApiLogicServer/ApiLogicServer-src/tree/main/api_logic_server_cli/prototypes/nw_no_cust/integration/openai_plugin)
29
28
30
-
29
+
<br>
31
30
32
31
## Nat Lang ALS Access using OpenAI Plugin
33
32
34
-
Tunnel to local host with ngrok
35
33
36
34
Requires tunnel to local host such as [ngrok](https://ngrok.com/downloads/mac-os?tab=download), then
37
35
38
36
```
39
37
ngrok config add-authtoken <obtain from https://dashboard.ngrok.com/get-started/setup/macos>
and note the url like: `https://mcp_url_eg_bca3_2601.ngrok-free.app -> http://localhost:5656`
49
+
and note the url like: `https://42da-2601-644-4900-etc.ngrok-free.app -> http://localhost:5656`
52
50
53
51
We'll call it `tunnel_url`
54
52
55
-
<br>
53
+
Enter this into `config/default.env`
56
54
57
-
### Create ai_plug_in.json
55
+
<br>
58
56
59
-
Prepare `ai_plug_in.json` as shown in this directory. It identifies the url for finding the openapi through the tunnel.
57
+
### Obtain swagger_3
60
58
61
-
Note: both ALS and and `ai_plug_in.json` presume the swagger and api are consistent:
59
+
Obtain swagger 2 from API Logic Server, eg, http://localhost:5656/api/swagger.json)
62
60
63
-
* swagger is at `http://localhost:5656/api/swagger.json`,
64
-
* typical API at `http://localhost:5656/api/Category`
61
+
Convert to 3: https://converter.swagger.io or other.
65
62
66
63
<br>
67
64
68
-
###Add APIs for openapi and openai_plugin
65
+
#### Reduce Operations
69
66
70
-
OpenAI requires a openai document, so create a custom endpoint - `api/api_discovery/openapi.py` - for swagger 3:
71
-
* swagger is at `http://localhost:5656/api/openai.json`
67
+
Reduce down to 30 operations (genai_demo has 69).
72
68
73
-
Note: the url needs to be the tunnelled version.
69
+
For testing, you can copy `integration/openai_plugin/swagger_3_genai_demo.json` or `integration/openai_plugin/nw-swagger_3.json` over `integration/openai_plugin/swagger_3.json`.
74
70
75
-
Fix servers in the `openai.json`
71
+
This was obtained using ChatGPT with prompts like:
72
+
73
+
1. Optionally collapse GET by ID and GET collection into a single endpoint using query params
74
+
2. remove POST from relationship endpoints
75
+
3. remove delete
76
+
4. collapse relationship endpoints further
77
+
78
+
then fix the result:
79
+
80
+
1. ensure servers and paths is retained (got deleted for me), and includes https:
81
+
2. version 3.1.0
82
+
83
+
Still seeing (fix with Chat):
84
+
85
+
```
86
+
In path /Customer, method get is missing operationId; skipping
87
+
In path /Customer, method post is missing operationId; skipping
88
+
In path /Order, method get is missing operationId; skipping
89
+
In path /Order, method post is missing operationId; skipping
90
+
In path /Item, method get is missing operationId; skipping
91
+
In path /Item, method post is missing operationId; skipping
92
+
In path /Product, method get is missing operationId; skipping
93
+
In path /Product, method post is missing operationId; skipping
94
+
```
76
95
77
96
<br>
97
+
### Custom endpoint for openapi
98
+
99
+
OpenAI requires a openai document, so observe the custom endpoint - `api/api_discovery/openapi` - eg, to test locally: `http://localhost:5656/api/openai`
100
+
101
+
Note: the url for use in ChatGPT is the tunnelled version, from the env variable.
78
102
103
+
<br>
79
104
### Configure in ChatGPT
80
105
81
-
ChatGPT -> Create > Configure > Add Action > url
106
+
Then, upload it to the Web version of ChatGPT:
107
+
108
+
1. Explore GPTs
109
+
2. Create
110
+
3. Configure
111
+
4. Create New Action
82
112
83
113
Provide the url of the openai endpoint:
84
114
85
115
https://tunnel_url.ngrok-free.app/api/openapi
86
116
87
-
which worked, but: **OpenAPI spec can have a maximum of 30 operations**, so, created a "pruned" version with just Customer: `integration/openai_plugin/nw-swagger_3.json`
88
117
89
-
fix openai version, url
118
+
Retrieval worked:
119
+
120
+
* list customers
121
+
122
+
* list the items of order 1 with their product names
123
+
124
+
<br>
125
+
126
+
## Appendices
127
+
128
+
<br>
129
+
130
+
### Create ai_plug_in.json
131
+
132
+
Prepare `ai_plug_in.json` as shown in this directory. Observe that it It identifies the url for finding the openapi through the tunnel.
133
+
134
+
Note: both ALS and and `ai_plug_in.json` presume the swagger and api are consistent:
135
+
136
+
* swagger is at `http://localhost:5656/api/swagger.json`,
137
+
* typical API at `http://localhost:5656/api/Category`
90
138
91
-
retrieval worked:
139
+
Not required for function - **Settings / Beta / Plugins > Plugin install → expects the ai-plugin.json manifest URL**
0 commit comments