@@ -10,15 +10,23 @@ const spec_1_2_0 = readYaml(path.join(__dirname, "./openAI_v1.2.0.yaml"));
10
10
const spec_2_3_0 = readYaml ( path . join ( __dirname , "./openAI_v2.3.0.yaml" ) ) ;
11
11
12
12
const specs = {
13
- "v1.2. 0" : spec_1_2_0 ,
14
- "v2.3.0 " : spec_2_3_0 ,
13
+ "v1.0" : spec_1_2_0 ,
14
+ "v2.3" : spec_2_3_0 ,
15
15
}
16
16
17
17
const dataSourceConfig = {
18
18
type : "dataSource" ,
19
19
params : [
20
20
{
21
- key : "ApiKey.value" ,
21
+ key : "serverURL" ,
22
+ type : "textInput" ,
23
+ label : "Service URL" ,
24
+ rules : [ { required : true } ] ,
25
+ placeholder : "https://<your-cloud-instance>" ,
26
+ tooltip : "Input the Service url of your OpenAI or compatible instance. For OpenAI, it is https://api.openai.com/v1" ,
27
+ } ,
28
+ {
29
+ key : "apiKey" ,
22
30
type : "password" ,
23
31
label : "API Key" ,
24
32
rules : [ { required : true } ] ,
@@ -64,10 +72,13 @@ const openAiPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
64
72
} ;
65
73
} ,
66
74
run : function ( actionData , dataSourceConfig ) : Promise < any > {
75
+ const { serverURL, apiKey } = dataSourceConfig ;
67
76
const runApiDsConfig = {
68
77
url : "" ,
69
- serverURL : "" ,
70
- dynamicParamsConfig : dataSourceConfig ,
78
+ serverURL : serverURL ,
79
+ dynamicParamsConfig : {
80
+ "ApiKeyAuth.value" : apiKey ,
81
+ } ,
71
82
specVersion : dataSourceConfig . specVersion ,
72
83
} ;
73
84
return runOpenApi ( actionData , runApiDsConfig , version2spec ( specs , dataSourceConfig . specVersion ) as OpenAPIV3 . Document ) ;
0 commit comments