-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserv.js
74 lines (51 loc) · 2.22 KB
/
serv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// // import express from 'express';
// // import cors from 'cors';
// // import bodyParser from 'body-parser';
// // // Initialize the app
// // const app = express();
// // const PORT = 9000;
// // // Middleware
// // app.use(cors());
// // app.use(bodyParser.json());
// // // Dummy translation logic (replace this with actual translation logic)
// // const translateText = (text, targetLanguage) => {
// // return `${text} in ${targetLanguage}`; // Dummy response; implement actual translation logic
// // };
// // // Translation endpoint
// // app.post('/translate', (req, res) => {
// // const { text, target } = req.body; // Updated to match the request body
// // // Validate input
// // if (!text || !target) {
// // return res.status(400).json({ error: 'Text and target language are required.' });
// // }
// // // Call the translation logic
// // const translatedText = translateText(text, target);
// // res.json({ translatedText });
// // });
// // // Start the server
// // app.listen(PORT, () => {
// // console.log(`Server is running on http://localhost:${PORT}`);
// // });
// import { Client } from "@gradio/client";
// try {
// // Connect to the API endpoint with your Hugging Face token
// const client = await Client.connect("VideoSys/CogVideoX", {
// hf_token: "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" // Replace with your tokeny
// });
// // Make a prediction using the specified parameters
// const result = await client.predict("/generate_vs", {
// model_name: "THUDM/CogVideoX-2b", // Specify the model name
// prompt: "Hello!!", // Replace with your desired prompt
// num_inference_steps: 30, // Reduce inference steps
// guidance_scale: 6, // Set the guidance scale
// threshold_start: 850, // Set the start timestep
// threshold_end: 100, // Set the end timestep
// gap: 2, // Define the broadcast range
// });
// // Log the result data
// console.log(result.data);
// } catch (error) {
// // Log any errors
// console.error("API Request failed:", error.message);
// }
//