Spaces:
Sleeping
Sleeping
Update src/server.js
Browse files- src/server.js +7 -7
src/server.js
CHANGED
@@ -21,7 +21,7 @@ const upload = multer({ dest: 'uploads/' });
|
|
21 |
// Chat Completions Endpoint
|
22 |
// ------------------------------------------
|
23 |
|
24 |
-
app.post('/
|
25 |
if (req.body.stream) {
|
26 |
// For streaming, the apiHandler manages the response and error handling
|
27 |
apiHandler.createChatCompletion(req.body, res);
|
@@ -42,7 +42,7 @@ app.post('/v1/chat/completions', (req, res) => {
|
|
42 |
// Image Generation Endpoint
|
43 |
// ------------------------------------------
|
44 |
|
45 |
-
app.post('/
|
46 |
try {
|
47 |
const data = await apiHandler.createImage(req.body);
|
48 |
res.json(data);
|
@@ -55,7 +55,7 @@ app.post('/v1/images/generations', async (req, res) => {
|
|
55 |
// Image Editing Endpoint
|
56 |
// ------------------------------------------
|
57 |
|
58 |
-
app.post('/
|
59 |
try {
|
60 |
// Add file paths to request body
|
61 |
req.body.image = req.files['image'][0].path;
|
@@ -76,7 +76,7 @@ app.post('/v1/images/edits', upload.fields([{ name: 'image' }, { name: 'mask' }]
|
|
76 |
// Image Variations Endpoint
|
77 |
// ------------------------------------------
|
78 |
|
79 |
-
app.post('/
|
80 |
try {
|
81 |
// Add file path to request body
|
82 |
req.body.image = req.file.path;
|
@@ -95,7 +95,7 @@ app.post('/v1/images/variations', upload.single('image'), async (req, res) => {
|
|
95 |
// Audio Transcription Endpoint
|
96 |
// ------------------------------------------
|
97 |
|
98 |
-
app.post('/
|
99 |
try {
|
100 |
// Add file path to request body
|
101 |
req.body.file = req.file.path;
|
@@ -114,7 +114,7 @@ app.post('/v1/audio/transcriptions', upload.single('file'), async (req, res) =>
|
|
114 |
// Text to Speech Endpoint
|
115 |
// ------------------------------------------
|
116 |
|
117 |
-
app.post('/
|
118 |
try {
|
119 |
await apiHandler.createSpeech(req.body, res);
|
120 |
} catch (error) {
|
@@ -130,7 +130,7 @@ app.post('/v1/audio/speech', async (req, res) => {
|
|
130 |
// Vision Endpoint
|
131 |
// ------------------------------------------
|
132 |
|
133 |
-
app.post('/
|
134 |
try {
|
135 |
const data = await apiHandler.createVisionAnalysis(req.body);
|
136 |
res.json(data);
|
|
|
21 |
// Chat Completions Endpoint
|
22 |
// ------------------------------------------
|
23 |
|
24 |
+
app.post('/chat/completions', (req, res) => {
|
25 |
if (req.body.stream) {
|
26 |
// For streaming, the apiHandler manages the response and error handling
|
27 |
apiHandler.createChatCompletion(req.body, res);
|
|
|
42 |
// Image Generation Endpoint
|
43 |
// ------------------------------------------
|
44 |
|
45 |
+
app.post('/images/generations', async (req, res) => {
|
46 |
try {
|
47 |
const data = await apiHandler.createImage(req.body);
|
48 |
res.json(data);
|
|
|
55 |
// Image Editing Endpoint
|
56 |
// ------------------------------------------
|
57 |
|
58 |
+
app.post('/images/edits', upload.fields([{ name: 'image' }, { name: 'mask' }]), async (req, res) => {
|
59 |
try {
|
60 |
// Add file paths to request body
|
61 |
req.body.image = req.files['image'][0].path;
|
|
|
76 |
// Image Variations Endpoint
|
77 |
// ------------------------------------------
|
78 |
|
79 |
+
app.post('/images/variations', upload.single('image'), async (req, res) => {
|
80 |
try {
|
81 |
// Add file path to request body
|
82 |
req.body.image = req.file.path;
|
|
|
95 |
// Audio Transcription Endpoint
|
96 |
// ------------------------------------------
|
97 |
|
98 |
+
app.post('/audio/transcriptions', upload.single('file'), async (req, res) => {
|
99 |
try {
|
100 |
// Add file path to request body
|
101 |
req.body.file = req.file.path;
|
|
|
114 |
// Text to Speech Endpoint
|
115 |
// ------------------------------------------
|
116 |
|
117 |
+
app.post('/audio/speech', async (req, res) => {
|
118 |
try {
|
119 |
await apiHandler.createSpeech(req.body, res);
|
120 |
} catch (error) {
|
|
|
130 |
// Vision Endpoint
|
131 |
// ------------------------------------------
|
132 |
|
133 |
+
app.post('/vision', async (req, res) => {
|
134 |
try {
|
135 |
const data = await apiHandler.createVisionAnalysis(req.body);
|
136 |
res.json(data);
|