Skip to content

Commit a6a5a85

Browse files
authored
Merge pull request #912 from Support-pl/dev-fixes
Dev fixes
2 parents 6883235 + 76bb47c commit a6a5a85

File tree

8 files changed

+202
-33
lines changed

8 files changed

+202
-33
lines changed

src/components/services/openai/draw.vue

+183-30
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
<template>
22
<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-
173
<a-col span="24">
184
<div class="token-title">
195
Token API:
@@ -36,21 +22,130 @@
3622
</a-col>
3723

3824
<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>
4745

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>
54149
</a-col>
55150

56151
<a-col span="24" style="margin-top: 10px">
@@ -134,6 +229,7 @@ const chats = computed(() => {
134229
message: chat.meta.lastMessage?.content ?? "",
135230
status: capitalized,
136231
unread: chat.meta.unread,
232+
attachments: chat.meta.lastMessage?.attachments ?? [],
137233
});
138234
});
139235
@@ -147,10 +243,11 @@ function moduleEnter() {
147243
148244
const isVisible = ref(false);
149245
const isLoading = ref(false);
246+
const activeApiTab = ref("1");
150247
const token = ref("-");
151-
const endpoint = `${VUE_APP_BASE_URL}nocloud/chat/completions`;
152248
153-
const example = `
249+
const endpointv1 = `${VUE_APP_BASE_URL}nocloud/chat/completions`;
250+
const exampleV1 = `
154251
curl \`<endpoint>\`
155252
-X POST
156253
-H "Content-Type: application/json"
@@ -163,6 +260,62 @@ const example = `
163260
}'
164261
`;
165262
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+
166319
async function fetch() {
167320
try {
168321
isLoading.value = true;

src/components/support/ticketItem.vue

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</div>
1616
<div class="ticket__lower">
1717
<div class="ticket__message">
18-
{{ beauty(ticket.message) }}
18+
{{ beauty(ticket) }}
1919
</div>
2020
<div class="ticket__time">
2121
{{ toDate(ticket.date / 1000 || ticket.date, ".", "00:00") }}
@@ -31,6 +31,7 @@ import { useRoute, useRouter } from "vue-router";
3131
import { useChatsStore } from "@/stores/chats.js";
3232
import { toDate } from "@/functions.js";
3333
import config from "@/appconfig.js";
34+
import { useI18n } from "vue-i18n";
3435
3536
const props = defineProps({
3637
ticket: { type: Object, required: true },
@@ -41,6 +42,7 @@ const props = defineProps({
4142
const router = useRouter();
4243
const route = useRoute();
4344
const chatsStore = useChatsStore();
45+
const { t } = useI18n();
4446
4547
const offset = computed(() => {
4648
if (props.ticket.unread > 9) {
@@ -82,13 +84,16 @@ function ticketClick(id) {
8284
router.push({ path: `/ticket/${id}`, query });
8385
}
8486
85-
function beauty(message) {
87+
function beauty(ticket) {
88+
let message = ticket.message;
8689
message = decode(message);
8790
message = message.replace(/-{2,}.*/gi, "");
8891
message = message.replace(/IP Address.*/gi, "");
8992
message = message.replace(/<\/?[a-zA-Zа-яА-Я1-9 #-:=";_!?]+>/gi, "");
9093
91-
return message.trim() || "empty";
94+
return message.trim() || ticket.attachments?.length > 0
95+
? t("attachedFiles")
96+
: "empty";
9297
}
9398
9499
function decode(text) {

src/i18n/locales/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@
383383
"token": "token",
384384
"Token expiration date": "Token expiration date",
385385
"Refresh token": "Refresh token",
386+
"moreExamples": "More examples",
386387
"openai description": "You can use ChatGPT by OpenAI in the Multi-cloud service Support.by with a transparent payment system and without VPN. To start using the feature you need to register in our service, top up your balance and choose the ChatGPT service. \n\n After ordering the service, you get access to ChatGPT through this application and start using the chat. You also receive a ChatGPT API token for use in your software development.",
387388
"openai description 2": "Your balance is debited according to the number of tokens required for your work or the functionality of your product, depending on the complexity and length of the conversation. Payment is made for the total number of input and output tokens, amounting to thousands. \n\n Think of a \"token\" as a word fragment used for natural language processing. For English text, 1 token is approximately 4 characters or 0.75 words. For the Russian language, one token is approximately equal to 2 characters or 0.25 words.",
388389
"enter": "Enter",
@@ -750,6 +751,7 @@
750751
"disk detach": "Disk detach",
751752
"assign to VM": "Assign to VM",
752753
"NIC attach": "NIC attach",
754+
"attachedFiles": "Attached files",
753755
"private": "Private",
754756
"available intervals": "Available intervals:",
755757
"enter new private IP": "Enter new private IP:",

src/i18n/locales/fr.json

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
"years": "ans",
8080
"Network": "Réseau",
8181
"Total": "Total",
82+
"moreExamples": "Plus d'exemples",
83+
"attachedFiles": "Fichiers joints",
8284
"Ready made servers": "Forfaits VPS SSD",
8385
"Windows is paid": "Windows est payant",
8486
"Payment will be made immediately after purchase": "Le paiement sera effectué immédiatement après l'achat",

src/i18n/locales/pl.json

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214
"invoice_Returned": "Zwrócone",
215215
"invoice_Draft": "Projekt",
216216
"Active": "Aktywny",
217+
"moreExamples": "Więcej przykładów",
218+
"attachedFiles": "Załączone pliki",
217219
"Suspended": "Zawieszony",
218220
"Canceled": "Odwołany",
219221
"Pay": "Zaplać",

src/i18n/locales/ru.json

+2
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@
336336
"select location": "Выберите локацию",
337337
"select service": "Select service",
338338
"select OS": "Выберите ОС",
339+
"moreExamples": "Больше примеров",
340+
"attachedFiles": "Прикреплённые файлы",
339341
"select tariff": "Выберите тариф",
340342
"loading": "Загрузка...",
341343
"bot is typing": "бот печатает",

src/i18n/locales/vi.json

+2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@
217217
"Servers": "Virtual Servers",
218218
"Virtual": "Web Hosting",
219219
"info": "Thông tin",
220+
"moreExamples": "Thêm ví dụ",
221+
"attachedFiles": "Tập tin đính kèm",
220222
"enter": "Truy cập",
221223
"all fields are required": "Vui lòng điền vào tất cả các trường",
222224
"field must contain more characters": "Chưa nhập đủ ký tự cho trường",

src/routes/services/servicePage.vue

+1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ async function onStart() {
349349
);
350350
351351
domain.resources = {
352+
...products,
352353
period: t("PayG"),
353354
recurringamount: 0,
354355
inputKilotoken: products.input_kilotoken,

0 commit comments

Comments
 (0)