-
-
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.
Rag inference & embedding route (#31)
* add boilerplate Signed-off-by: cbh778899 <[email protected]> * implement rag inference Signed-off-by: cbh778899 <[email protected]> * init db when app loads Signed-off-by: cbh778899 <[email protected]> * implement embeddings route Signed-off-by: cbh778899 <[email protected]> * update swagger documentation Signed-off-by: cbh778899 <[email protected]> * delete doc.html as we don't need it anymore Signed-off-by: cbh778899 <[email protected]> --------- Signed-off-by: cbh778899 <[email protected]>
- Loading branch information
Showing
11 changed files
with
434 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// coding=utf-8 | ||
|
||
import { post } from "../tools/request.js"; | ||
|
||
// 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 async function embeddings(req, res) { | ||
if(!req.headers.authorization) { | ||
res.status(401).send("Not Authorized!"); | ||
return; | ||
} | ||
|
||
const { input } = req.body; | ||
if(!input) { | ||
res.status(400).send("Input sentence not specified!"); | ||
} | ||
|
||
const { embedding, http_error } = await post('embedding', {body: { | ||
content: input | ||
}}, { eng: "embedding" }); | ||
|
||
if(http_error) { | ||
res.status(500).send("Embedding Engine Internal Server Error") | ||
return; | ||
} | ||
|
||
res.status(200).send({ | ||
object: "list", | ||
data: [ | ||
{ | ||
object: "embedding", | ||
embedding, | ||
index: 0 | ||
} | ||
], | ||
model: "all-MiniLM-L6-v2", | ||
usage: { | ||
prompt_tokens: 0, | ||
total_tokens: 0 | ||
} | ||
}) | ||
} |
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
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,2 +1,17 @@ | ||
// 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 const SYSTEM_TABLE = 'system'; | ||
export const DATASET_TABLE = 'dataset'; |
Oops, something went wrong.