randydev commited on
Commit
ef305bf
·
verified ·
1 Parent(s): d7e5cb8

Update plugins/gptold.js

Browse files
Files changed (1) hide show
  1. plugins/gptold.js +53 -0
plugins/gptold.js CHANGED
@@ -2,9 +2,62 @@ import express from 'express';
2
  import { OpenaiRes } from '../lib/scrapper.js';
3
  import { NvidiaTogether } from '../lib/@randydev/together/llama.js';
4
  import { CohereAI } from '../lib/@randydev/together/cohere.js';
 
5
  import { authenticateApiKey, authenticateApiKeyPremium, apiLimiter } from '../middleware/midware.js';
6
  const GptRoutes = express.Router();
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  /**
9
  * @swagger
10
  * /api/v1/ai/cohere/command-plus:
 
2
  import { OpenaiRes } from '../lib/scrapper.js';
3
  import { NvidiaTogether } from '../lib/@randydev/together/llama.js';
4
  import { CohereAI } from '../lib/@randydev/together/cohere.js';
5
+ import { AlibabaTogether } from '../lib/@randyev/together/qwen-ai';
6
  import { authenticateApiKey, authenticateApiKeyPremium, apiLimiter } from '../middleware/midware.js';
7
  const GptRoutes = express.Router();
8
 
9
+
10
+ /**
11
+ * @swagger
12
+ * /api/v1/ai/alibaba/qwen-plus:
13
+ * get:
14
+ * summary: Alibaba Qwen AI
15
+ * tags: [AI]
16
+ * parameters:
17
+ * - in: query
18
+ * name: query
19
+ * required: true
20
+ * description: User's input query
21
+ * schema:
22
+ * type: string
23
+ * - in: query
24
+ * name: system_prompt
25
+ * required: false
26
+ * description: Custom system prompt
27
+ * schema:
28
+ * type: string
29
+ * - in: query
30
+ * name: chatHistory
31
+ * required: false
32
+ * description: Previous chat history in JSON format
33
+ * schema:
34
+ * type: string
35
+ * - in: header
36
+ * name: x-api-key
37
+ * required: true
38
+ * description: API key for authentication
39
+ * schema:
40
+ * type: string
41
+ * responses:
42
+ * 200:
43
+ * description: Success
44
+ */
45
+ GptRoutes.get('/api/v1/ai/alibaba/qwen-plus', authenticateApiKeyPremium, apiLimiter, async (req, res) => {
46
+ try {
47
+ const query = req.query.query;
48
+ const chatHistory = req.query.chatHistory ? JSON.parse(req.query.chatHistory) : [];
49
+ 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.";
50
+
51
+ const results = await AlibabaTogether(query, {
52
+ system_prompt: system_prompt
53
+ });
54
+
55
+ res.json({ results });
56
+ } catch (error) {
57
+ res.status(401).json({ error: error.message });
58
+ }
59
+ });
60
+
61
  /**
62
  * @swagger
63
  * /api/v1/ai/cohere/command-plus: