1
1
<template >
2
2
<a-row class =" module" style =" margin-top : 10px " :gutter =" [10, 10]" >
3
- <a-col span =" 12" >
4
- <div style =" padding-bottom : 0 ; font-weight : 700 " >Input kilotoken:</div >
5
- <div style =" padding-top : 0 ; font-size : 18px " >
6
- {{ service.resources.inputKilotoken }} {{ currency.title }}
7
- </div >
8
- </a-col >
9
-
10
- <a-col span =" 12" >
11
- <div style =" padding-bottom : 0 ; font-weight : 700 " >Output kilotoken:</div >
12
- <div style =" padding-top : 0 ; font-size : 18px " >
13
- {{ service.resources.outputKilotoken }} {{ currency.title }}
14
- </div >
15
- </a-col >
16
-
17
3
<a-col span =" 24" >
18
4
<div class =" token-title" >
19
5
Token API:
36
22
</a-col >
37
23
38
24
<a-col span =" 24" >
39
- <div class =" token-title" >
40
- API endpoint:
41
- <copy-icon style =" font-size : 18px " @click =" addToClipboard(endpoint)" />
42
- </div >
43
- <div style =" padding-top : 0 ; font-size : 18px " >
44
- {{ endpoint }}
45
- </div >
46
- </a-col >
25
+ <a-tabs v-model:activeKey =" activeApiTab" >
26
+ <a-tab-pane key =" 1" tab =" API v1" >
27
+ <a-row style =" padding : 0px 5px ; margin-bottom : 10px " >
28
+ <a-col span =" 12" >
29
+ <div style =" padding-bottom : 0 ; font-weight : 700 " >
30
+ Input kilotoken:
31
+ </div >
32
+ <div style =" padding-top : 0 ; font-size : 18px " >
33
+ {{ service.resources.inputKilotoken }} {{ currency.title }}
34
+ </div >
35
+ </a-col >
36
+ <a-col span =" 12" >
37
+ <div style =" padding-bottom : 0 ; font-weight : 700 " >
38
+ Output kilotoken:
39
+ </div >
40
+ <div style =" padding-top : 0 ; font-size : 18px " >
41
+ {{ service.resources.outputKilotoken }} {{ currency.title }}
42
+ </div >
43
+ </a-col >
44
+ </a-row >
47
45
48
- <a-col span =" 24" >
49
- <div class =" token-title" >
50
- API example:
51
- <copy-icon style =" font-size : 18px " @click =" addToClipboard(example)" />
52
- </div >
53
- <code >{{ example }}</code >
46
+ <a-col span =" 24" >
47
+ <div class =" token-title" >
48
+ API endpoint:
49
+ <copy-icon
50
+ style =" font-size : 18px "
51
+ @click =" addToClipboard(endpointv1)"
52
+ />
53
+ </div >
54
+ <div style =" padding-top : 0 ; font-size : 18px " >
55
+ {{ endpointv1 }}
56
+ </div >
57
+ </a-col >
58
+
59
+ <a-col span =" 24" >
60
+ <div class =" token-title" >
61
+ API example:
62
+ <copy-icon
63
+ style =" font-size : 18px "
64
+ @click =" addToClipboard(exampleV1)"
65
+ />
66
+ </div >
67
+ <code >{{ exampleV1 }}</code >
68
+ </a-col >
69
+ </a-tab-pane >
70
+ <a-tab-pane key =" 2" tab =" API v2 (BETA)" >
71
+ <a-row style =" padding : 0px 5px " >
72
+ <a-col span =" 12" >
73
+ <a-select
74
+ style =" width : 100% ; margin-right : 5px "
75
+ v-model:value =" selectedTypeV2"
76
+ :options =" typesOptionsV2"
77
+ ></a-select >
78
+ </a-col >
79
+
80
+ <a-col span =" 12" >
81
+ <a-select
82
+ style =" margin-left : 5px ; margin-right : 10px ; width : 100% "
83
+ v-model:value =" selectedModelV2"
84
+ :options =" modelsOptionsV2"
85
+ ></a-select >
86
+ </a-col >
87
+
88
+ <a-col span =" 12" >
89
+ <div style =" padding-bottom : 0 ; font-weight : 700 " >
90
+ Input kilotoken:
91
+ </div >
92
+ <div style =" padding-top : 0 ; font-size : 18px " >
93
+ {{
94
+ service.resources[
95
+ `${selectedTypeV2}|${selectedModelV2}|input`
96
+ ]
97
+ }}
98
+ {{ currency.title }}
99
+ </div >
100
+ </a-col >
101
+ <a-col span =" 12" >
102
+ <div style =" padding-bottom : 0 ; font-weight : 700 " >
103
+ Output kilotoken:
104
+ </div >
105
+ <div style =" padding-top : 0 ; font-size : 18px " >
106
+ {{
107
+ service.resources[
108
+ `${selectedTypeV2}|${selectedModelV2}|output`
109
+ ]
110
+ }}
111
+ {{ currency.title }}
112
+ </div >
113
+ </a-col >
114
+ </a-row >
115
+
116
+ <a-col span =" 24" >
117
+ <div class =" token-title" >
118
+ Base URL:
119
+ <copy-icon
120
+ style =" font-size : 18px "
121
+ @click =" addToClipboard(baseUrlV2)"
122
+ />
123
+ </div >
124
+ <div style =" padding-top : 0 ; font-size : 18px " >
125
+ {{ baseUrlV2 }}
126
+ </div >
127
+ </a-col >
128
+
129
+ <a-col span =" 24" >
130
+ <div
131
+ class =" token-title"
132
+ style =" display : flex ; justify-content : space-between "
133
+ >
134
+ <div >
135
+ <span > API example: </span >
136
+ <copy-icon
137
+ style =" font-size : 18px "
138
+ @click =" addToClipboard(exampleV2)"
139
+ />
140
+ </div >
141
+ <a-button @click =" openOpenAiDocs" type =" link" >{{
142
+ $t("moreExamples")
143
+ }}</a-button >
144
+ </div >
145
+ <code >{{ exampleV2 }}</code >
146
+ </a-col >
147
+ </a-tab-pane >
148
+ </a-tabs >
54
149
</a-col >
55
150
56
151
<a-col span =" 24" style =" margin-top : 10px " >
@@ -134,6 +229,7 @@ const chats = computed(() => {
134
229
message: chat .meta .lastMessage ? .content ?? " " ,
135
230
status: capitalized,
136
231
unread: chat .meta .unread ,
232
+ attachments: chat .meta .lastMessage ? .attachments ?? [],
137
233
});
138
234
});
139
235
@@ -147,10 +243,11 @@ function moduleEnter() {
147
243
148
244
const isVisible = ref (false );
149
245
const isLoading = ref (false );
246
+ const activeApiTab = ref (" 1" );
150
247
const token = ref (" -" );
151
- const endpoint = ` ${ VUE_APP_BASE_URL } nocloud/chat/completions` ;
152
248
153
- const example = `
249
+ const endpointv1 = ` ${ VUE_APP_BASE_URL } nocloud/chat/completions` ;
250
+ const exampleV1 = `
154
251
curl \` <endpoint>\`
155
252
-X POST
156
253
-H "Content-Type: application/json"
@@ -163,6 +260,62 @@ const example = `
163
260
}'
164
261
` ;
165
262
263
+ const selectedModelV2 = ref (" gpt-4o" );
264
+ const selectedTypeV2 = ref (" text" );
265
+ const baseUrlV2 = ` ${ VUE_APP_BASE_URL } nocloud/api` ;
266
+ const exampleV2 = computed (
267
+ () => `
268
+ curl <baseUrl>/v1/chat/completions \
269
+ -H "Content-Type: application/json" \
270
+ -H "Authorization: Bearer <token>" \
271
+ -d '{
272
+ "model": "${ selectedModelV2 .value } ",
273
+ "messages": [
274
+ {
275
+ "role": "developer",
276
+ "content": "You are a helpful assistant."
277
+ },
278
+ {
279
+ "role": "user",
280
+ "content": "Hello!"
281
+ }
282
+ ]
283
+ }'
284
+ `
285
+ );
286
+
287
+ const modelsOptionsV2 = computed (() => {
288
+ const resources = Object .keys (props .service .resources )
289
+ .filter (
290
+ (key ) =>
291
+ key .split (" |" ).length > 1 ?? key .split (" |" )[0 ] === selectedTypeV2 .value
292
+ )
293
+ .map ((key ) => key .split (" |" )[1 ]);
294
+
295
+ return [... new Set (resources).values ()].map ((key ) => ({
296
+ value: key,
297
+ label: key,
298
+ }));
299
+ });
300
+
301
+ const typesOptionsV2 = computed (() => {
302
+ const resources = Object .keys (props .service .resources )
303
+ .filter ((key ) => key .split (" |" ).length > 1 )
304
+ .map ((key ) => key .split (" |" )[0 ]);
305
+
306
+ return [... new Set (resources).values ()].map ((key ) => ({
307
+ value: key,
308
+ label: key,
309
+ }));
310
+ });
311
+
312
+ function openOpenAiDocs () {
313
+ window .open (
314
+ " https://platform.openai.com/docs/api-reference/chat/create" ,
315
+ " _blanc"
316
+ );
317
+ }
318
+
166
319
async function fetch () {
167
320
try {
168
321
isLoading .value = true ;
0 commit comments