feat: add additional metadata: endpoint, author ID

This commit is contained in:
Danny Avila 2024-05-19 12:41:35 -04:00
parent fb6e87c36d
commit 84f68f9a15
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
3 changed files with 14 additions and 4 deletions

View file

@ -43,7 +43,7 @@ const ten_minutes = 1000 * 60 * 10;
* @param {Express.Response} res - The response object, used to send back a response.
* @returns {void}
*/
const chatV2 = async (req, res) => {
const chatV1 = async (req, res) => {
logger.debug('[/assistants/chat/] req.body', req.body);
const {
@ -647,4 +647,4 @@ const chatV2 = async (req, res) => {
}
};
module.exports = chatV2;
module.exports = chatV1;

View file

@ -17,7 +17,7 @@ const createAssistant = async (req, res) => {
try {
const { openai } = await getOpenAIClient({ req, res });
const { tools = [], endpoint: _e, ...assistantData } = req.body;
const { tools = [], endpoint, ...assistantData } = req.body;
assistantData.tools = tools
.map((tool) => {
if (typeof tool !== 'string') {
@ -34,6 +34,11 @@ const createAssistant = async (req, res) => {
assistantData.model = openai.locals.azureOptions.azureOpenAIApiDeploymentName;
}
assistantData.metadata = {
author: req.user.id,
endpoint,
};
const assistant = await openai.beta.assistants.create(assistantData);
if (azureModelIdentifier) {
assistant.model = azureModelIdentifier;

View file

@ -14,7 +14,7 @@ const createAssistant = async (req, res) => {
/** @type {{ openai: OpenAIClient }} */
const { openai } = await getOpenAIClient({ req, res });
const { tools = [], endpoint: _e, ...assistantData } = req.body;
const { tools = [], endpoint, ...assistantData } = req.body;
assistantData.tools = tools
.map((tool) => {
if (typeof tool !== 'string') {
@ -31,6 +31,11 @@ const createAssistant = async (req, res) => {
assistantData.model = openai.locals.azureOptions.azureOpenAIApiDeploymentName;
}
assistantData.metadata = {
author: req.user.id,
endpoint,
};
const assistant = await openai.beta.assistants.create(assistantData);
if (azureModelIdentifier) {
assistant.model = azureModelIdentifier;