update
Browse files- lib/@randydev/together/qwen-ai.js +25 -8
- plugins/gptold.js +45 -0
lib/@randydev/together/qwen-ai.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import got from 'got';
|
2 |
|
3 |
-
async function CloudFlareQwenTogether(message, { system_prompt = "" } = {}) {
|
4 |
const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/qwen/qwen1.5-1.8b-chat`, {
|
5 |
headers: {
|
6 |
'Authorization': `Bearer ${process.env['CLOUDFLARE_API_KEY']}`,
|
@@ -20,7 +20,7 @@ async function CloudFlareQwenTogether(message, { system_prompt = "" } = {}) {
|
|
20 |
return run.result.response;
|
21 |
}
|
22 |
|
23 |
-
async function DeepseekQwenTogether(message, { system_prompt = "" } = {}) {
|
24 |
const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/deepseek-ai/deepseek-r1-distill-qwen-32b`, {
|
25 |
headers: {
|
26 |
'Authorization': `Bearer ${process.env['CLOUDFLARE_API_KEY']}`,
|
@@ -38,7 +38,7 @@ async function DeepseekQwenTogether(message, { system_prompt = "" } = {}) {
|
|
38 |
return run.result.response;
|
39 |
}
|
40 |
|
41 |
-
async function AlibabaTogether(message, { system_prompt = "" } = {}) {
|
42 |
const response = await got.post('https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions', {
|
43 |
headers: {
|
44 |
'Authorization': 'Bearer ' + process.env['ALIBABA_API_KEY'],
|
@@ -59,8 +59,25 @@ async function AlibabaTogether(message, { system_prompt = "" } = {}) {
|
|
59 |
}).json();
|
60 |
return response.choices[0].message.content;
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import got from 'got';
|
2 |
|
3 |
+
export async function CloudFlareQwenTogether(message, { system_prompt = "" } = {}) {
|
4 |
const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/qwen/qwen1.5-1.8b-chat`, {
|
5 |
headers: {
|
6 |
'Authorization': `Bearer ${process.env['CLOUDFLARE_API_KEY']}`,
|
|
|
20 |
return run.result.response;
|
21 |
}
|
22 |
|
23 |
+
export async function DeepseekQwenTogether(message, { system_prompt = "" } = {}) {
|
24 |
const run = await got.post(`https://api.cloudflare.com/client/v4/accounts/${process.env['ACCOUNT_ID']}/ai/run/@cf/deepseek-ai/deepseek-r1-distill-qwen-32b`, {
|
25 |
headers: {
|
26 |
'Authorization': `Bearer ${process.env['CLOUDFLARE_API_KEY']}`,
|
|
|
38 |
return run.result.response;
|
39 |
}
|
40 |
|
41 |
+
export async function AlibabaTogether(message, { system_prompt = "" } = {}) {
|
42 |
const response = await got.post('https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions', {
|
43 |
headers: {
|
44 |
'Authorization': 'Bearer ' + process.env['ALIBABA_API_KEY'],
|
|
|
59 |
}).json();
|
60 |
return response.choices[0].message.content;
|
61 |
}
|
62 |
+
|
63 |
+
export async function AlibabaTurboTogether(message, { system_prompt = "" } = {}) {
|
64 |
+
const response = await got.post('https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions', {
|
65 |
+
headers: {
|
66 |
+
'Authorization': 'Bearer ' + process.env['ALIBABA_API_KEY'],
|
67 |
+
'Content-Type': 'application/json'
|
68 |
+
},
|
69 |
+
json: {
|
70 |
+
'model': 'qwen-turbo-latest',
|
71 |
+
'messages': [
|
72 |
+
{"role": "system", "content": system_prompt},
|
73 |
+
|
74 |
+
{'role': 'user', 'content': message}
|
75 |
+
],
|
76 |
+
'temperature': 0.7,
|
77 |
+
'top_p': 0.7,
|
78 |
+
'repetition_penalty': 1,
|
79 |
+
'stream': false
|
80 |
+
}
|
81 |
+
}).json();
|
82 |
+
return response.choices[0].message.content;
|
83 |
+
}
|
plugins/gptold.js
CHANGED
@@ -19,6 +19,7 @@ import {
|
|
19 |
} from '../models.js';
|
20 |
import {
|
21 |
AlibabaTogether,
|
|
|
22 |
CloudFlareQwenTogether,
|
23 |
DeepseekQwenTogether,
|
24 |
} from '../lib/@randydev/together/qwen-ai.js';
|
@@ -736,6 +737,50 @@ GptRoutes.get('/api/v1/ai/akenox/lu-sunda', authenticateApiKeyPremium, apiLimite
|
|
736 |
}
|
737 |
});
|
738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
/**
|
740 |
* @swagger
|
741 |
* /api/v1/ai/alibaba/qwen-plus:
|
|
|
19 |
} from '../models.js';
|
20 |
import {
|
21 |
AlibabaTogether,
|
22 |
+
AlibabaTurboTogether,
|
23 |
CloudFlareQwenTogether,
|
24 |
DeepseekQwenTogether,
|
25 |
} from '../lib/@randydev/together/qwen-ai.js';
|
|
|
737 |
}
|
738 |
});
|
739 |
|
740 |
+
/**
|
741 |
+
* @swagger
|
742 |
+
* /api/v1/ai/alibaba/qwen-turbo-latest:
|
743 |
+
* get:
|
744 |
+
* summary: Alibaba Qwen Turbo Latest AI
|
745 |
+
* tags: [AI]
|
746 |
+
* parameters:
|
747 |
+
* - in: query
|
748 |
+
* name: query
|
749 |
+
* required: true
|
750 |
+
* description: User's input query
|
751 |
+
* schema:
|
752 |
+
* type: string
|
753 |
+
* - in: query
|
754 |
+
* name: system_prompt
|
755 |
+
* required: false
|
756 |
+
* description: Custom system prompt
|
757 |
+
* schema:
|
758 |
+
* type: string
|
759 |
+
* - in: header
|
760 |
+
* name: x-api-key
|
761 |
+
* required: true
|
762 |
+
* description: API key for authentication
|
763 |
+
* schema:
|
764 |
+
* type: string
|
765 |
+
* responses:
|
766 |
+
* 200:
|
767 |
+
* description: Success
|
768 |
+
*/
|
769 |
+
GptRoutes.get('/api/v1/ai/alibaba/qwen-turbo-latest', authenticateApiKeyPremium, apiLimiter, async (req, res) => {
|
770 |
+
try {
|
771 |
+
const query = req.query.query;
|
772 |
+
const system_prompt = req.query.system_prompt || "Your name is AkenoX AI A kind and friendly AI assistant that answers in a short and concise answer. Give short step-by-step reasoning if required.";
|
773 |
+
|
774 |
+
const results = await AlibabaTurboTogether(query, {
|
775 |
+
system_prompt: system_prompt
|
776 |
+
});
|
777 |
+
|
778 |
+
res.json({ results });
|
779 |
+
} catch (error) {
|
780 |
+
res.status(401).json({ error: error.message });
|
781 |
+
}
|
782 |
+
});
|
783 |
+
|
784 |
/**
|
785 |
* @swagger
|
786 |
* /api/v1/ai/alibaba/qwen-plus:
|