-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added version API and test case (#37)
- Added version.js - Added versionGet.js - Modified index.js - Modified test_apis.py Signed-off-by: Murkeee <[email protected]>
- Loading branch information
Showing
4 changed files
with
108 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,53 @@ | ||
// coding=utf-8 | ||
|
||
// Copyright [2024] [SkywardAI] | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Router } from "express"; | ||
|
||
import inferenceRoute from "./inference.js"; | ||
import tokenRoute from "./token.js"; | ||
import tracingRoute from "./tracing.js"; | ||
import embeddingRoute from "./embedding.js"; | ||
import encoderRoute from "./encoder.js"; | ||
import decoderRoute from "./decoder.js"; | ||
|
||
function indexRoute() { | ||
const router = Router(); | ||
|
||
router.get('/healthy', (_, res)=>{ | ||
res.status(200).send('ok') | ||
}) | ||
|
||
return router; | ||
} | ||
|
||
function generateAPIRouters() { | ||
const api_router = Router(); | ||
|
||
api_router.use('/chat', inferenceRoute()); | ||
api_router.use('/token', tokenRoute()); | ||
api_router.use('/tracing', tracingRoute()); | ||
api_router.use('/embeddings', embeddingRoute()); | ||
api_router.use('/encoder', encoderRoute()); | ||
api_router.use('/decoder', decoderRoute()); | ||
|
||
return api_router; | ||
} | ||
|
||
export default function buildRoutes(app) { | ||
app.use('/', indexRoute()); | ||
app.use('/v1', generateAPIRouters()); | ||
// coding=utf-8 | ||
|
||
// Copyright [2024] [SkywardAI] | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Router } from "express"; | ||
|
||
import inferenceRoute from "./inference.js"; | ||
import tokenRoute from "./token.js"; | ||
import tracingRoute from "./tracing.js"; | ||
import embeddingRoute from "./embedding.js"; | ||
import encoderRoute from "./encoder.js"; | ||
import decoderRoute from "./decoder.js"; | ||
import versionRoute from "./version.js"; | ||
|
||
function indexRoute() { | ||
const router = Router(); | ||
|
||
router.get('/healthy', (_, res)=>{ | ||
res.status(200).send('ok') | ||
}) | ||
|
||
return router; | ||
} | ||
|
||
function generateAPIRouters() { | ||
const api_router = Router(); | ||
|
||
api_router.use('/chat', inferenceRoute()); | ||
api_router.use('/token', tokenRoute()); | ||
api_router.use('/tracing', tracingRoute()); | ||
api_router.use('/embedding', embeddingRoute()); | ||
api_router.use('/encoder', encoderRoute()); | ||
api_router.use('/decoder', decoderRoute()); | ||
api_router.use('/version', versionRoute()); | ||
|
||
return api_router; | ||
} | ||
|
||
export default function buildRoutes(app) { | ||
app.use('/', indexRoute()); | ||
app.use('/v1', generateAPIRouters()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// coding=utf-8 | ||
|
||
// Copyright [2024] [SkywardAI] | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Router } from "express"; | ||
import { fetchVersions } from "../tools/versionGet.js"; | ||
|
||
export default function versionRoute() { | ||
const router = Router(); | ||
|
||
router.get('', (_, res)=>{ | ||
res.send({inference_engine_version: fetchVersions().inferenceEngVersion}) | ||
}) | ||
|
||
return router; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// coding=utf-8 | ||
|
||
// Copyright [2024] [SkywardAI] | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
export function fetchVersions(){ | ||
const versionArray = {}; //Object to store versions | ||
//When a new service version is added just define a new object property and | ||
//call process.env to fetch the value from the environment. | ||
versionArray.inferenceEngVersion = process.env.INFERENCE_ENG_VERSION; | ||
return versionArray; | ||
} | ||
|